List of usage examples for javafx.scene.control ListCell ListCell
public ListCell()
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }/*from w w w . j av a 2 s. c o m*/ optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:Jigs_Desktop_Client.GUI.FXMLDocumentController.java
@Override public void initialize(URL url, ResourceBundle rb) { this.alert("resources/app_launch.mp3"); this.user_name.requestFocus(); this.btn_logout.setDisable(true); this.jc.setStatus(from_user, "online"); this.my_circle_list.setCellFactory(new Callback<ListView<UserStatus>, ListCell<UserStatus>>() { @Override//w w w.ja v a2 s. c o m public ListCell<UserStatus> call(ListView<UserStatus> userObj) { ListCell<UserStatus> cell = new ListCell<UserStatus>() { @Override protected void updateItem(UserStatus usrObj, boolean btnl) { super.updateItem(usrObj, btnl); if (usrObj != null) { String filename = usrObj.getStatus(); if (filename == null || filename.equals("") || filename.equals("null")) filename = "offline"; else System.out.println(filename); Image img = new Image( getClass().getResource("resources/" + filename + ".png").toExternalForm()); ImageView imv = new ImageView(img); setGraphic(imv); setText(usrObj.getUsername()); } } }; return cell; } }); this.main_panel.setBackground(Background.EMPTY); this.text_message.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { sendMessage(null); keyEvent.consume(); } } }); }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java
private void initializeDateSelectionMethodComboBox() { dateSelectionMethodComboBox.setCellFactory((param) -> { final ListCell<DateSelectionMethod> cell = new ListCell<DateSelectionMethod>() { @Override//from w w w . ja v a2 s . c o m protected void updateItem(DateSelectionMethod selectionMethod, boolean emptyRow) { super.updateItem(selectionMethod, emptyRow); if (selectionMethod == null) { setText(null); } else { setText(selectionMethod.getDisplayName()); } } }; return cell; }); dateSelectionMethodComboBox.setButtonCell(new ListCell<DateSelectionMethod>() { @Override protected void updateItem(DateSelectionMethod selectionMethod, boolean emptyRow) { super.updateItem(selectionMethod, emptyRow); if (emptyRow) { setText(""); } else { switch (selectionMethod) { case SPECIFY: runLaterIfNotFXApplicationThread(() -> datePicker.setVisible(true)); setText(selectionMethod.getDisplayName()); // log.debug("dateSelectorComboBox button cell set to " + getText() + ", datePicker has value=" + datePicker.getValue() + ", selectionMode=" + dateSelectionMethodComboBox.getSelectionModel().getSelectedItem() + " and current time=" + currentTimeProperty.get()); // This should change if default time ever changes runLaterIfNotFXApplicationThread( () -> dateSelectionMethodComboBox.setTooltip(new Tooltip(getText() + " is selected. Use date picker control to specify a date\nin the past representing an historical snapshot version of the database\nor click and select " + DateSelectionMethod.USE_LATEST.getDisplayName() + " to always use latest.\nDefault is " + DateSelectionMethod.USE_LATEST.getDisplayName() + "."))); break; case USE_LATEST: runLaterIfNotFXApplicationThread(() -> datePicker.setVisible(false)); setText(selectionMethod.getDisplayName()); // log.debug("dateSelectorComboBox button cell set to " + getText() + ", datePicker has value=" + datePicker.getValue() + ", selectionMode=" + dateSelectionMethodComboBox.getSelectionModel().getSelectedItem() + " and current time=" + currentTimeProperty.get()); runLaterIfNotFXApplicationThread( () -> dateSelectionMethodComboBox.setTooltip(new Tooltip(getText() + " is selected, so latest (most recent) date will always be used.\nClick and select " + DateSelectionMethod.SPECIFY.getDisplayName() + " to use date picker control to specify a date\nin the past representing an historical snapshot version of the database.\nDefault is " + DateSelectionMethod.USE_LATEST.getDisplayName() + "."))); break; default: // Should never happen throw new IllegalArgumentException( "Failed setting dateSelectorComboBox ButtonCell. Unsupported " + selectionMethod.getClass().getName() + " value " + selectionMethod.name() + ". Must be " + DateSelectionMethod.SPECIFY.name() + " or " + DateSelectionMethod.USE_LATEST.name() + "."); } } } }); dateSelectionMethodComboBox.setOnAction((event) -> { // log.debug("dateSelectorComboBox activated. datePicker has value=" + datePicker.getValue() + ", selectionMode=" + dateSelectionMethodComboBox.getSelectionModel().getSelectedItem() + " and current time=" + currentTimeProperty.get()); switch (dateSelectionMethodComboBox.getSelectionModel().getSelectedItem()) { case SPECIFY: if (currentTimeProperty.get() == Long.MAX_VALUE) { setCurrentTimePropertyFromDatePicker(); } else { setDatePickerFromCurrentTimeProperty(); } break; case USE_LATEST: currentTimeProperty.set(Long.MAX_VALUE); break; default: // Should never happen throw new IllegalArgumentException("Unsupported " + dateSelectionMethodComboBox.getSelectionModel().getSelectedItem().getClass().getName() + " value " + dateSelectionMethodComboBox.getSelectionModel().getSelectedItem().name() + ". Must be " + DateSelectionMethod.SPECIFY.name() + " or " + DateSelectionMethod.USE_LATEST.name() + "."); } }); dateSelectionMethodComboBox.getItems().addAll(DateSelectionMethod.values()); dateSelectionMethodComboBox.getSelectionModel().select(DateSelectionMethod.USE_LATEST); }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java
private void initializePathComboBox() { pathComboBox.setCellFactory((param) -> { final ListCell<UUID> cell = new ListCell<UUID>() { @Override//from w w w . java 2s .c o m protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c, panelViewCoordinate); setText(desc); } } }; return cell; }); pathComboBox.setButtonCell(new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c, panelViewCoordinate); // log.debug("Setting path button cell to \"" + desc + "\""); setText(desc); } } }); pathComboBox.setConverter(new StringConverter<UUID>() { @Override public String toString(UUID uuid) { if (uuid == null) { return null; } else { return OTFUtility.getDescription(uuid, panelViewCoordinate); } } @Override public UUID fromString(String userId) { return null; } }); currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); }
From source file:com.chart.SwingChart.java
/** * Series edition//from w ww . ja v a 2 s. com * @param series Series to edit */ void editSeries(final Series series) { String[] style = series.getStyle().split(";"); String strColor = "black"; final TextField editWidth = new TextField(); String tempS = "null"; for (String e : style) { if (e.contains("color: ")) { strColor = e.replace("color: ", ""); } else if (e.contains("width: ")) { editWidth.setText(e.replace("width: ", "")); } else if (e.contains("shape: ")) { tempS = e.replace("shape: ", ""); } } final String symbol = tempS; final List<SeriesShape> symbolList = new ArrayList<>(); final ObservableList<SeriesShape> symbolListModel; final ListView<SeriesShape> comboSymbol = new ListView(); symbolList.add(new SeriesShape("null", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("crux", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(strColor))); symbolListModel = FXCollections.observableList(symbolList); comboSymbol.setItems(symbolListModel); comboSymbol.setCellFactory(new Callback<ListView<SeriesShape>, ListCell<SeriesShape>>() { @Override public ListCell<SeriesShape> call(ListView<SeriesShape> p) { ListCell<SeriesShape> cell = new ListCell<SeriesShape>() { @Override protected void updateItem(SeriesShape t, boolean bln) { super.updateItem(t, bln); if (t != null) { setText(""); setGraphic(t.getShapeGraphic()); } } }; return cell; } }); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } final ColorPicker colorPicker = new ColorPicker(javafx.scene.paint.Color.web(strColor)); colorPicker.setOnAction((ActionEvent t) -> { String sc = colorPicker.getValue().toString(); symbolListModel.clear(); symbolListModel.add(new SeriesShape("null", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("crux", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(sc))); comboSymbol.setItems(symbolListModel); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } }); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Series"), 0, 0); grid.add(new Label(series.getKey().toString()), 1, 0); grid.add(new Label("Color"), 0, 1); grid.add(colorPicker, 1, 1); grid.add(new Label("Width"), 0, 2); grid.add(editWidth, 1, 2); grid.add(new Label("Shape"), 0, 3); grid.add(comboSymbol, 1, 3); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { String strColor = colorPicker.getValue().toString(); String strWidth = editWidth.getText(); double dWidth = Double.valueOf(strWidth); String strSimbolo = "null"; SeriesShape simb = new SeriesShape(comboSymbol.getSelectionModel().getSelectedItem().toString(), javafx.scene.paint.Color.web(strColor)); XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(series.getAxisIndex()); renderer.setSeriesPaint(series.getSeriesIndex(), scene2awtColor(colorPicker.getValue())); try { if (Double.valueOf(strWidth) > 0) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), true); renderer.setSeriesStroke(series.getSeriesIndex(), new BasicStroke(Integer.valueOf(strWidth))); } else { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), false); } } catch (NumberFormatException ex) { } if (simb.getName().contains("null")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), false); renderer.setSeriesShape(series.getSeriesIndex(), null); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), true); renderer.setSeriesShape(series.getSeriesIndex(), simb.getShapeAWT()); if (simb.getName().contains("empty")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), true); } } series.setStyle( "color: " + strColor + ";width: " + editWidth.getText() + ";shape: " + strSimbolo + ";"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { if (((Label) nn).getText().equals(series.getKey().toString())) { ((Label) nn).setGraphic(simb.getShapeGraphic()); } } } } } return true; } }.show(); }
From source file:com.rvantwisk.cnctools.controllers.CNCToolsController.java
@FXML // This method is called by the FXMLLoader when initialization is complete void initialize() { assert addMillTask != null : "fx:id=\"addMillTask\" was not injected: check your FXML file 'CNCTools.fxml'."; assert btnMoveTaskDown != null : "fx:id=\"btnMoveTaskDown\" was not injected: check your FXML file 'CNCTools.fxml'."; assert btnMoveTaskUp != null : "fx:id=\"btnMoveTaskUp\" was not injected: check your FXML file 'CNCTools.fxml'."; assert btnPostProcessor != null : "fx:id=\"btnPostProcessor\" was not injected: check your FXML file 'CNCTools.fxml'."; assert btnView != null : "fx:id=\"btnView\" was not injected: check your FXML file 'CNCTools.fxml'."; assert deleteProject != null : "fx:id=\"deleteProject\" was not injected: check your FXML file 'CNCTools.fxml'."; assert descriptionValue != null : "fx:id=\"descriptionValue\" was not injected: check your FXML file 'CNCTools.fxml'."; assert details != null : "fx:id=\"details\" was not injected: check your FXML file 'CNCTools.fxml'."; assert displayedIssueLabel != null : "fx:id=\"displayedIssueLabel\" was not injected: check your FXML file 'CNCTools.fxml'."; assert editMilltask != null : "fx:id=\"editMilltask\" was not injected: check your FXML file 'CNCTools.fxml'."; assert generateGCode != null : "fx:id=\"generateGCode\" was not injected: check your FXML file 'CNCTools.fxml'."; //assert millTaskDescription != null : "fx:id=\"millTaskDescription\" was not injected: check your FXML file 'CNCTools.fxml'."; //assert millTaskName != null : "fx:id=\"millTaskName\" was not injected: check your FXML file 'CNCTools.fxml'."; //assert millTaskOperation != null : "fx:id=\"millTaskOperation\" was not injected: check your FXML file 'CNCTools.fxml'."; assert milltaskEnabled != null : "fx:id=\"milltaskEnabled\" was not injected: check your FXML file 'CNCTools.fxml'."; assert removeMilltask != null : "fx:id=\"removeMilltask\" was not injected: check your FXML file 'CNCTools.fxml'."; assert tbl_millTasks != null : "fx:id=\"tbl_millTasks\" was not injected: check your FXML file 'CNCTools.fxml'."; assert v_projectList != null : "fx:id=\"v_projectList\" was not injected: check your FXML file 'CNCTools.fxml'."; v_projectList.setItems(projectModel.projectsProperty()); projectModel.loadPostProcessors();/* w w w .j av a 2 s .c om*/ if (projectModel.postProcessorsProperty().size() == 0) { addDefaultPostprocessorSet(); projectModel.savePostProcessors(); MonologFX dialog = new MonologFX(MonologFX.Type.INFO); dialog.setTitleText("Postprocessor defaults loaded"); dialog.setMessage("No Post Processors where found, a new a new post processor set has been created."); dialog.show(); } projectModel.loadToolsFromDB(); if (projectModel.toolDBProperty().size() == 0) { addDefaultToolSet(); projectModel.saveToolDB(); MonologFX dialog = new MonologFX(MonologFX.Type.INFO); dialog.setTitleText("Tools defaults loaded"); dialog.setMessage("No tools where found, a new a new toolset has been created."); dialog.show(); } projectModel.loadProjectsFromDB(); if (projectModel.projectsProperty().size() == 0) { addProjectDefaults(); projectModel.saveProjects(); MonologFX dialog = new MonologFX(MonologFX.Type.INFO); dialog.setTitleText("Project defaults loaded"); dialog.setMessage( "No project was found, a new template project was created. Feel free to delete or modify"); dialog.show(); } deleteProject.disableProperty().bind(v_projectList.getSelectionModel().selectedItemProperty().isNull()); btnPostProcessor.disableProperty().bind(v_projectList.getSelectionModel().selectedItemProperty().isNull()); btnView.disableProperty().bind(v_projectList.getSelectionModel().selectedItemProperty().isNull()); removeMilltask.disableProperty().bind(tbl_millTasks.getSelectionModel().selectedItemProperty().isNull()); addMillTask.disableProperty().bind(v_projectList.getSelectionModel().selectedItemProperty().isNull()); editMilltask.disableProperty().bind(tbl_millTasks.getSelectionModel().selectedItemProperty().isNull()); generateGCode.disableProperty().bind(v_projectList.getSelectionModel().selectedItemProperty().isNull()); // Update description when project changes by means of databinding v_projectList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Project>() { @Override public void changed(ObservableValue<? extends Project> observable, Project oldValue, Project newValue) { if (oldValue != null) { descriptionValue.textProperty().unbindBidirectional(oldValue.descriptionProperty()); } if (projectModel.projectsProperty().size() == 0) { tbl_millTasks.getItems().clear(); } else { tbl_millTasks.setItems(newValue.millTasksProperty()); descriptionValue.textProperty().bindBidirectional(newValue.descriptionProperty()); } } }); // Enable/Disable up/Down arrows tbl_millTasks.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TaskRunnable>() { @Override public void changed(ObservableValue<? extends TaskRunnable> observable, TaskRunnable o, TaskRunnable o2) { if (o2 != null) { final int index = tbl_millTasks.getSelectionModel().getSelectedIndex(); btnMoveTaskUp.setDisable(index == 0 ? true : false); btnMoveTaskDown.setDisable((index + 1) == tbl_millTasks.getItems().size() ? true : false); } else { btnMoveTaskUp.setDisable(true); btnMoveTaskDown.setDisable(true); } } }); btnMoveTaskUp.setDisable(true); btnMoveTaskDown.setDisable(true); // Set text in ListView v_projectList.setCellFactory(new Callback<ListView<Project>, ListCell<Project>>() { @Override public ListCell<Project> call(ListView<Project> p) { ListCell<Project> cell = new ListCell<Project>() { @Override protected void updateItem(Project t, boolean bln) { super.updateItem(t, bln); if (t != null) { setText(t.nameProperty().getValue()); } else { setText(null); } } }; return cell; } }); // checkbox renderer for milltasks milltaskEnabled.setCellFactory( new Callback<TableColumn<TaskRunnable, Boolean>, TableCell<TaskRunnable, Boolean>>() { @Override public TableCell<TaskRunnable, Boolean> call(TableColumn<TaskRunnable, Boolean> p) { CheckBoxTableCell<TaskRunnable, Boolean> cell = new CheckBoxTableCell<>(); cell.setEditable(true); cell.setAlignment(Pos.CENTER); return cell; } }); tbl_millTasks.setEditable(true); // Save DB on exit getDialog().setOnHidden(new EventHandler<WindowEvent>() { public void handle(WindowEvent we) { save(null); } }); }
From source file:net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil.java
public static <T> Callback<ListView<T>, ListCell<T>> simpleListCellFactory(Function<T, String> converter, Function<T, String> toolTipMaker) { return collection -> new ListCell<T>() { @Override//from w w w .j a v a 2 s . c o m protected void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (empty || item == null) { setText(null); setGraphic(null); Tooltip.uninstall(this, getTooltip()); } else { setText(converter.apply(item)); Tooltip.install(this, new Tooltip(toolTipMaker.apply(item))); } } }; }
From source file:org.beryx.viewreka.fxapp.ProjectLibs.java
@Override public void initialize(URL location, ResourceBundle resources) { check("lstLib", lstLib); check("butBundleAdd", butBundleAdd); check("butUncatalogedLibAdd", butUncatalogedLibAdd); check("butLibRemove", butLibRemove); check("lstExistingLib", lstExistingLib); lstLib.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); BooleanBinding libRemoveBinding = Bindings.createBooleanBinding(() -> lstLib.getSelectionModel().isEmpty(), lstLib.getSelectionModel().selectedItemProperty()); butLibRemove.disableProperty().bind(libRemoveBinding); lstLib.setCellFactory(new Callback<ListView<LibListEntry>, ListCell<LibListEntry>>() { @Override/*from ww w . j a v a2 s.com*/ public ListCell<LibListEntry> call(ListView<LibListEntry> entry) { return new ListCell<LibListEntry>() { @Override public void updateItem(LibListEntry item, boolean empty) { super.updateItem(item, empty); if (empty || item == null) { setText(null); setGraphic(null); } else { setText(item.getCellText()); String tooltipText = item.getTooltipText(); if (tooltipText != null && !tooltipText.isEmpty()) { setTooltip(new Tooltip(tooltipText)); } } } }; } }); }
From source file:org.pdfsam.ui.io.PdfVersionCombo.java
public PdfVersionCombo(String ownerModule) { this.ownerModule = ownerModule; Arrays.stream(PdfVersion.values()).filter(v -> v.getVersion() > 2).map(PdfVersionComboItem::new) .forEach(unfilteredItems::add); setCellFactory(new Callback<ListView<PdfVersionComboItem>, ListCell<PdfVersionComboItem>>() { @Override//from w ww.j a va2 s . co m public ListCell<PdfVersionComboItem> call(ListView<PdfVersionComboItem> p) { ListCell<PdfVersionComboItem> cell = new ListCell<PdfVersionComboItem>() { @Override protected void updateItem(PdfVersionComboItem item, boolean bln) { super.updateItem(item, bln); if (item != null) { setText(item.toString()); if (item.sourceVersion) { setTooltip(new Tooltip( DefaultI18nContext.getInstance().i18n("Same as the input document"))); } } } }; return cell; } }); versionsFilter.requiredProperty().addListener((observable, oldVal, newVal) -> { PdfVersionComboItem selected = getSelectionModel().getSelectedItem(); setItems(unfilteredItems.filtered(t -> t.isHigherOrEqual(newVal.intValue()))); int selecedIndex = getItems().indexOf(selected); if (selecedIndex != -1) { getSelectionModel().select(selecedIndex); } else { getSelectionModel().selectLast(); } }); versionsFilter.addFilter(-1); getSelectionModel().selectLast(); eventStudio().addAnnotatedListeners(this); }
From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java
private void createDialog() { dialog = new Stage(); dialog.initOwner(qupath.getStage()); dialog.setTitle("Training sample selector"); pointCreator = new RandomPointCreator(); for (PathClass pathClass : pathClassListModel) { if (pathClass != null && pathClass.getName() != null) pointCreator.addPathClass(pathClass, KeyCode.getKeyCode(pathClass.getName().toUpperCase().substring(0, 1))); // pointCreator.addPathClass(pathClass, KeyStroke.getKeyStroke(new pathClass.getName().toLowerCase().charAt(0), 0).getKeyCode()); }/*from w ww .ja v a 2s .c o m*/ // PathClass tumourClass = PathClassFactory.getDefaultPathClass(PathClasses.TUMOR); // PathClass stromaClass = PathClassFactory.getDefaultPathClass(PathClasses.STROMA); // pointCreator.addPathClass(tumourClass, KeyCode.T); // pointCreator.addPathClass(stromaClass, KeyCode.S); QuPathViewer viewer = qupath.getViewer(); pointCreator.registerViewer(viewer); // Adapt to changing active viewers ImageDataChangeListener<BufferedImage> listener = new ImageDataChangeListener<BufferedImage>() { @Override public void imageDataChanged(ImageDataWrapper<BufferedImage> source, ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) { if (pointCreator != null) { QuPathViewer viewer = qupath.getViewer(); pointCreator.registerViewer(viewer); updateObjectCache(viewer); } refreshList(); updateLabel(); } }; qupath.addImageDataChangeListener(listener); // Remove listeners for cleanup dialog.setOnCloseRequest(e -> { pointCreator.deregisterViewer(); qupath.removeImageDataChangeListener(listener); dialog.setOnCloseRequest(null); dialog = null; // Re-enable mode switching qupath.setModeSwitchingEnabled(true); }); ParameterPanelFX paramPanel = new ParameterPanelFX(params); paramPanel.getPane().setPadding(new Insets(2, 5, 5, 5)); list = new ListView<PathClass>(pathClassListModel); list.setPrefSize(400, 200); // TODO: ADD A SENSIBLE RENDERER! // For now, this is simply duplicated from PathAnnotationPanel list.setCellFactory(new Callback<ListView<PathClass>, ListCell<PathClass>>() { @Override public ListCell<PathClass> call(ListView<PathClass> p) { ListCell<PathClass> cell = new ListCell<PathClass>() { @Override protected void updateItem(PathClass value, boolean bln) { super.updateItem(value, bln); int size = 10; if (value == null) { setText(null); setGraphic(null); } else if (value.getName() == null) { setText("None"); setGraphic(new Rectangle(size, size, ColorToolsFX.getCachedColor(0, 0, 0, 0))); } else { setText(value.getName()); setGraphic(new Rectangle(size, size, ColorToolsFX.getPathClassColor(value))); } } }; return cell; } }); // list.setCellRenderer(new PathClassListCellRendererPoints()); list.setTooltip(new Tooltip("Available classes")); labelCount = new Label(); labelCount.setTextAlignment(TextAlignment.CENTER); labelCount.setPadding(new Insets(5, 0, 5, 0)); BorderPane panelTop = new BorderPane(); panelTop.setTop(paramPanel.getPane()); panelTop.setCenter(list); panelTop.setBottom(labelCount); labelCount.prefWidthProperty().bind(panelTop.widthProperty()); updateLabel(); // panelButtons.add(new JButton(new UndoAction("Undo"))); Action actionAdd = new Action("Add to class", e -> { if (list == null || pointCreator == null) return; PathClass pathClass = list.getSelectionModel().getSelectedItem(); pointCreator.addPoint(pathClass); }); Action actionSkip = new Action("Skip", e -> { if (pointCreator != null) pointCreator.addPoint(null); }); GridPane panelButtons = PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionAdd), ActionUtils.createButton(actionSkip)); BorderPane pane = new BorderPane(); pane.setCenter(panelTop); pane.setBottom(panelButtons); pane.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(pane); dialog.setScene(scene); }