/** * Initializes the controller class. This method is automatically called after fxml file has been * loaded. */ @FXML private void initialize() { // setting up the radioButtons final ToggleGroup timeIntervalGroup = new ToggleGroup(); monthlyRadioButton.setToggleGroup(timeIntervalGroup); dailyRadioButton.setToggleGroup(timeIntervalGroup); hourlyRadioButton.setToggleGroup(timeIntervalGroup); fifteenMinRadioButton.setToggleGroup(timeIntervalGroup); fifteenMinRadioButton.setSelected(true); final ToggleGroup typOfChartGroup = new ToggleGroup(); regularTimeSeriesRadioButton.setToggleGroup(typOfChartGroup); scatterRadioButton.setToggleGroup(typOfChartGroup); dailyTypeOfDayRadioButton.setToggleGroup(typOfChartGroup); regularTimeSeriesRadioButton.setSelected(true); final ToggleGroup typeOfDayGroup = new ToggleGroup(); schoolDayRadioButton.setToggleGroup(typeOfDayGroup); summerDayRadioButton.setToggleGroup(typeOfDayGroup); holidayRadioButton.setToggleGroup(typeOfDayGroup); weekendRadioButton.setToggleGroup(typeOfDayGroup); everyDayRadioButton.setToggleGroup(typeOfDayGroup); everyDayRadioButton.setSelected(true); updateEnabledButtons(); // initialize a unique instance of the database database = Database.getInstance(); // initialize the meter table with all the columns. meterNumberColumn.setCellValueFactory(cellData -> cellData.getValue().getMeterNumber()); meterTable.setEditable(true); meterNumberColumn.setCellFactory(TextFieldTableCell.forTableColumn()); meterNumberColumn.setOnEditCommit( new EventHandler<TableColumn.CellEditEvent<Meter, String>>() { @Override public void handle(CellEditEvent<Meter, String> event) { event .getTableView() .getItems() .get(event.getTablePosition().getRow()) .setMeterNumber(Assistant.parsePropertiesString(event.getNewValue())); } }); startDateColumn.setCellValueFactory( cellData -> Assistant.parsePropertiesString(cellData.getValue().getStartDate().toString())); endDateColumn.setCellValueFactory( cellData -> Assistant.parsePropertiesString(cellData.getValue().getEndDate().toString())); activatedColumn.setCellFactory(cellData -> new CheckBoxCell()); colorColumn.setCellFactory(cellData -> new ColorButtonCell(java.awt.Color.GREEN)); initializeDateTable(); }
public Meter(ObservableList<IntervalData> intervalDataList) { this.intervalDataList = intervalDataList; if (this.intervalDataList.get(0).getMeterNumber() == null) { meterNumber = Assistant.parsePropertiesString("no number"); } else { meterNumber = this.intervalDataList.get(0).getMeterNumber(); } activated = true; startDate = this.intervalDataList.get(0).getDate(); endDate = intervalDataList.get(this.intervalDataList.size() - 1).getDate(); calendar = new GregorianCalendar(); calendar.setTime(startDate); color = Color.GREEN; }
/** This method initializes the DateColumn */ private void initializeDateTable() { // initialize datetable dateTable.setEditable(true); dateTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); ; ContextMenu menu = new ContextMenu(); MenuItem holidayChanger = new MenuItem("Holiday"); MenuItem summerChanger = new MenuItem("Summer Day"); MenuItem schoolDayChanger = new MenuItem("School Day"); MenuItem weekendChanger = new MenuItem("Weekend"); holidayChanger.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.HOLIDAY); updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.HOLIDAY); // update Column dateTable.getColumns().get(1).setVisible(false); dateTable.getColumns().get(1).setVisible(true); dailyDayTypeChartPanel.addNewSeries(dailyIntervalData); } }); summerChanger.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.SUMMER_DAY); updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.SUMMER_DAY); // update Column dateTable.getColumns().get(1).setVisible(false); dateTable.getColumns().get(1).setVisible(true); dailyDayTypeChartPanel.addNewSeries(dailyIntervalData); } }); schoolDayChanger.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.SCHOOL_DAY); updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.SCHOOL_DAY); // update Column dateTable.getColumns().get(1).setVisible(false); dateTable.getColumns().get(1).setVisible(true); dailyDayTypeChartPanel.addNewSeries(dailyIntervalData); } }); weekendChanger.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dateTable.getSelectionModel().getSelectedItem().setDayType(DayType.WEEKEND); updateDayType(dateTable.getSelectionModel().getSelectedItems(), DayType.WEEKEND); // update Column dateTable.getColumns().get(1).setVisible(false); dateTable.getColumns().get(1).setVisible(true); dailyDayTypeChartPanel.addNewSeries(dailyIntervalData); } }); menu.getItems().add(holidayChanger); menu.getItems().add(summerChanger); menu.getItems().add(schoolDayChanger); menu.getItems().add(weekendChanger); dateTable.setContextMenu(menu); dateColumn.setCellValueFactory( cellData -> Assistant.parsePropertiesString(cellData.getValue().getDate().toString())); dayTypeColumn.setCellValueFactory( cellData -> Assistant.parsePropertiesString(cellData.getValue().getDayType().toString())); }
public String getColorForFX() { return Assistant.toRGBCodeAWT(color); }