Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GUIAppointment extends Rectangle {
- private String customer, service, employee, datetime, price, duration;
- private Appointment appointment;
- private int r, g, b;
- private Color[] allColors;
- private Color c1 = new Color(0.96, 0.31, 0.26, 0.8);
- private Color c2 = new Color(0.77, 0.96, 0.26, 0.8);
- private Color c3 = new Color(0.26, 0.96, 0.6, 0.8);
- private Color c4 = new Color(0.26, 0.58, 0.96, 0.8);
- private Color c5 = new Color(0.66, 0.26, 0.96, 0.8);
- private Color hovc1 = new Color(0.96, 0.31, 0.26, 1);
- private Color hovc2 = new Color(0.77, 0.96, 0.26, 1);
- private Color hovc3 = new Color(0.26, 0.96, 0.6, 1);
- private Color hovc4 = new Color(0.26, 0.58, 0.96, 1);
- private Color hovc5 = new Color(0.66, 0.26, 0.96, 1);
- private String date;
- public GUIAppointment(Appointment appointment) {
- this.appointment = appointment;
- this.customer = appointment.getCustomer();
- this.service = appointment.getService();
- this.employee = appointment.getEmployee();
- this.datetime = appointment.getTime();
- this.price = String.valueOf(appointment.getPrice());
- this.duration = String.valueOf(appointment.getDuration());
- String appDate = appointment.getTime();
- String[] parts1 = appDate.split(" ");
- String[] parts2 = parts1[0].split("-");
- date = parts2[2] + "." + parts2[1] + "." + parts2[0];
- }
- public boolean isRezisable() {
- return true;
- }
- public double minWidth(double height) {
- return 0.0;
- }
- public void compHeight() {
- this.setHeight(appointment.getDuration());
- }
- public void compWidth() {
- this.setWidth(200);
- }
- public void compColor(Appointment appointment) {
- DBConnection dbConnection = new DBConnection();
- ObservableList<String> allEmployees = dbConnection.getAllEmployees();
- int id = appointment.getEmployeeID(appointment.getEmployee());
- switch(id) {
- case 0:
- this.setFill(c1);
- break;
- case 1:
- this.setFill(c2);
- break;
- case 2:
- this.setFill(c3);
- break;
- case 3:
- this.setFill(c4);
- break;
- case 4:
- this.setFill(c5);
- break;
- }
- }
- public Color getColor() {
- return (Color) this.getFill();
- }
- public String getDate() {
- return date;
- }
- public void selectAnchorPane(Appointment appointment) {
- AnchorPane[] apArray = {anchorPane1, anchorPane2, anchorPane3, anchorPane4, anchorPane5};
- String appDate = appointment.getTime();
- String[] parts1 = appDate.split(" ");
- String[] parts2 = parts1[0].split("-");
- String finalDate = parts2[2] + "." + parts2[1] + "." + parts2[0];
- String[] compOffset = parts1[1].split(":");
- String compOffsetHour = compOffset[0];
- String compOffsetMinute = compOffset[1];
- int finalHour = Integer.parseInt(compOffsetHour);
- int finalMinute = Integer.parseInt(compOffsetMinute);
- double offset = finalHour*60 + finalMinute;
- for(int i = 0; i < 5; i++){
- if(finalDate.equals(weekDates[i])) {
- GUIAppointment guiAppointment = new GUIAppointment(appointment);
- allGuiAppointments.add(guiAppointment);
- guiAppointment.compHeight();
- guiAppointment.compColor(appointment);
- apArray[i].getChildren().add(guiAppointment);
- int j = checkCollision(guiAppointment);
- if(j > 1) {
- guiAppointment.widthProperty().bind(apArray[i].widthProperty());
- apArray[i].setTopAnchor(guiAppointment, offset);
- apArray[i].setLeftAnchor(guiAppointment, 0.0);
- apArray[i].setRightAnchor(guiAppointment, apArray[i].getWidth() / j);
- }
- else {
- guiAppointment.widthProperty().bind(apArray[i].widthProperty());
- apArray[i].setTopAnchor(guiAppointment, offset);
- apArray[i].setLeftAnchor(guiAppointment, 0.0);
- apArray[i].setRightAnchor(guiAppointment, 0.0);
- }
- }
- }
- }
- public int checkCollision(GUIAppointment guiApp) {
- List<GUIAppointment> sameDateAppointments = new ArrayList<GUIAppointment>();
- int i = 0;
- for(GUIAppointment GUIapp : allGuiAppointments) {
- if(guiApp.getDate().equals(GUIapp.getDate())) {
- sameDateAppointments.add(GUIapp);
- }
- }
- for(GUIAppointment GUIapp : sameDateAppointments) {
- if(GUIapp.getBoundsInParent().intersects(guiApp.getBoundsInParent())) {
- i++;
- }
- }
- System.out.println("[!] " + i);
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement