List of usage examples for javafx.scene.control CheckBox selectedProperty
public final BooleanProperty selectedProperty()
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param lstPano/*from www . j a va 2s. c o m*/ * @param numPano * @return */ public Pane affichageHS(String lstPano, int numPano) { Pane panneauHotSpots = new Pane(); panneauHotSpots.setTranslateY(10); panneauHotSpots.setTranslateX(30); VBox vb1 = new VBox(5); panneauHotSpots.getChildren().add(vb1); Label lblPoint; Label sep = new Label(" "); Label sep1 = new Label(" "); int o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspots(); o++) { VBox vbPanneauHS = new VBox(); double deplacement = 20; vbPanneauHS.setLayoutX(deplacement); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HS" + o); lblPoint = new Label("Point n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setTranslateX(-deplacement); lblPoint.setStyle("-fx-background-color : #333;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setTranslateX(-deplacement); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); if (lstPano != null) { Label lblLien = new Label("Panoramique de destination"); ComboBox cbDestPano = new ComboBox(); String[] liste = lstPano.split(";"); cbDestPano.getItems().addAll(Arrays.asList(liste)); cbDestPano.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { valideHS(); } }); cbDestPano.setTranslateX(60); cbDestPano.setId("cbpano" + o); String f1XML = panoramiquesProjet[numPano].getHotspot(o).getFichierXML(); if (f1XML != null) { cbDestPano.setValue(f1XML.split("\\.")[0]); } int num = cbDestPano.getSelectionModel().getSelectedIndex(); vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, sep); } Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspot(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspot(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHS" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("anime" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspot(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } int nbHS = o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspotImage(); o++) { VBox vbPanneauHS = new VBox(); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HSImg" + o); lblPoint = new Label("Image n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setStyle("-fx-background-color : #666;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); Label lblLien = new Label("Image choisie :"); String f1XML = panoramiquesProjet[numPano].getHotspotImage(o).getLienImg(); ImageView IMChoisie = new ImageView( new Image("file:" + repertTemp + File.separator + "images" + File.separator + f1XML, 100, -1, true, true)); IMChoisie.setTranslateX(100); vbPanneauHS.getChildren().addAll(lblLien, IMChoisie, sep); Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspotImage(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspotImage(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHSImage" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("animeImage" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspotImage(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } valideHS(); nbHS += o; // if (nbHS == 0) { // } else { // btnValider.setVisible(true); // } return panneauHotSpots; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param strNomFichierBarre//from ww w . j a v a 2 s . c o m */ public static void creerEditerBarre(String strNomFichierBarre) { apCreationBarre.getChildren().clear(); apCreationBarre.setStyle("-fx-background-color : -fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 8, 0.0 , 0 , 8 );" + "-fx-border-width: 1px;"); AnchorPane apOutilsBarre = new AnchorPane(); Button btnAnnulerBarre = new Button(rbLocalisation.getString("main.quitter"), new ImageView(new Image("file:" + getStrRepertAppli() + "/images/annule.png"))); final Button btnSauverBarre = new Button(rbLocalisation.getString("main.sauver"), new ImageView( new Image("file:" + getStrRepertAppli() + "/images/sauveProjet.png", 24, 24, true, true, true))); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); btnAjouteZone = new Button(rbLocalisation.getString("main.ajouteZone"), new ImageView( new Image("file:" + getStrRepertAppli() + "/images/btn+.png", 24, 24, true, true, true))); apImgBarrePersonnalisee = new AnchorPane(); apImgBarrePersonnalisee.getChildren().clear(); apZoneBarrePersonnalisee = new AnchorPane(); apZoneBarrePersonnalisee.getChildren().clear(); apZoneBarrePersonnalisee.setLayoutX(0); apZoneBarrePersonnalisee.setLayoutY(150); apZoneBarrePersonnalisee.setPrefWidth(300); apZoneBarrePersonnalisee.setPrefHeight(200); int iLargeurEcran = (int) tailleEcran.getWidth(); int iHauteurEcran = (int) tailleEcran.getHeight() - 100; final int iLargeur = 1200; final int iHauteur = 600; mbarPrincipal.setDisable(true); bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); tpEnvironnement.setDisable(true); apCreationBarre.setPrefWidth(iLargeur); apCreationBarre.setMinWidth(iLargeur); apCreationBarre.setMaxWidth(iLargeur); apCreationBarre.setPrefHeight(iHauteur); apCreationBarre.setMinHeight(iHauteur); apCreationBarre.setMaxHeight(iHauteur); apCreationBarre.setLayoutX((iLargeurEcran - iLargeur) / 2); apCreationBarre.setLayoutY((iHauteurEcran - iHauteur) / 2); apCreationBarre.setVisible(true); Label lblBarrePersonnalisee = new Label(rbLocalisation.getString("main.creeBarrePersonnalisee")); lblBarrePersonnalisee.setMinWidth(iLargeur - 10); lblBarrePersonnalisee.setAlignment(Pos.CENTER); lblBarrePersonnalisee.setStyle("-fx-background-color : #777;"); lblBarrePersonnalisee.setTextFill(Color.WHITE); lblBarrePersonnalisee.setLayoutX(5); lblBarrePersonnalisee.setLayoutY(10); lblBarrePersonnalisee.setFont(Font.font(14)); apCreationBarre.getChildren().add(lblBarrePersonnalisee); apOutilsBarre.setPrefWidth(300); apOutilsBarre.setMinWidth(300); apOutilsBarre.setMaxWidth(300); apOutilsBarre.setPrefHeight(iHauteur - 50); apOutilsBarre.setMinHeight(iHauteur - 50); apOutilsBarre.setMaxHeight(iHauteur - 50); apOutilsBarre.setLayoutX(iLargeur - 302); apOutilsBarre.setLayoutY(50); apOutilsBarre.setStyle( "-fx-background-color : -fx-background;-fx-border-width : 1px;-fx-border-color : transparent transparent transparent -fx-outer-border;"); btnAnnulerBarre.setPrefWidth(120); btnAnnulerBarre.setLayoutX(30); btnAnnulerBarre.setLayoutY(iHauteur - 90); btnSauverBarre.setPrefWidth(120); btnSauverBarre.setLayoutX(160); btnSauverBarre.setLayoutY(iHauteur - 90); btnSauverBarre.setDisable(true); Label lblChargeImage = new Label(rbLocalisation.getString("main.chargeImage")); lblChargeImage.setLayoutX(20); lblChargeImage.setLayoutY(10); TextField tfChargeImage = new TextField(""); tfChargeImage.setDisable(true); tfChargeImage.setPrefWidth(200); tfChargeImage.setLayoutX(50); tfChargeImage.setLayoutY(40); Button btnChargeImage = new Button("..."); btnChargeImage.setLayoutX(260); btnChargeImage.setLayoutY(40); final CheckBox cbMasqueZones = new CheckBox(rbLocalisation.getString("main.masqueZones")); cbMasqueZones.setDisable(true); cbMasqueZones.setLayoutX(20); cbMasqueZones.setLayoutY(70); btnAjouteZone.setLayoutX(130); btnAjouteZone.setLayoutY(110); btnAjouteZone.setDisable(true); apOutilsBarre.getChildren().addAll(lblChargeImage, tfChargeImage, btnChargeImage, cbMasqueZones, btnAjouteZone, apZoneBarrePersonnalisee, btnAnnulerBarre, btnSauverBarre); apCreationBarre.getChildren().addAll(apImgBarrePersonnalisee, apOutilsBarre); if (!strNomFichierBarre.equals("")) { lblChargeImage.setVisible(false); tfChargeImage.setVisible(false); btnChargeImage.setVisible(false); String strNomFichier = strNomFichierBarre; strNomFichier = strNomFichier.substring(0, strNomFichier.length() - 4); strNomFichierShp = strNomFichier + ".shp"; String strNomFichierPng = strNomFichier + ".png"; File fichPng = new File(strNomFichierPng); if (fichPng.exists()) { try { btnAjouteZone.setDisable(false); imgBarrePersonnalisee = new Image("file:" + fichPng); iNombreZones = getGestionnaireInterface().lisFichierShp(strNomFichierShp, zones); btnSauverBarre.setDisable(false); if (iNombreZones > 0) { cbMasqueZones.setDisable(false); } afficheBarrePersonnalisee(iLargeur, iHauteur, false); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } btnAnnulerBarre.setOnMouseClicked((t) -> { mbarPrincipal.setDisable(false); bbarPrincipal.setDisable(false); hbBarreBouton.setDisable(false); tpEnvironnement.setDisable(false); apCreationBarre.setVisible(false); }); btnAjouteZone.setOnMouseClicked((t) -> { btnAjouteZone.setDisable(true); ajouterZone(iLargeur, iHauteur, false); }); btnChargeImage.setOnMouseClicked((t) -> { strRepertBarrePersonnalisee = getStrRepertAppli() + "/theme/telecommandes"; File fileRepert; fileRepert = new File(strRepertBarrePersonnalisee); FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter efShpFilter = new FileChooser.ExtensionFilter( "Fichiers barre personnalise (SHP)", "*.shp", "*.png"); fileChooser.setInitialDirectory(fileRepert); fileChooser.getExtensionFilters().addAll(efShpFilter); File fileFichierImage = fileChooser.showOpenDialog(null); if (fileFichierImage != null) { String strNomFichier = fileFichierImage.getAbsolutePath(); strNomFichier = strNomFichier.substring(0, strNomFichier.length() - 4); strNomFichierShp = strNomFichier + ".shp"; String strNomFichierPng = strNomFichier + ".png"; File fileFichierPng = new File(strNomFichierPng); if (fileFichierPng.exists()) { try { btnAjouteZone.setDisable(false); imgBarrePersonnalisee = new Image("file:" + fileFichierPng); iNombreZones = getGestionnaireInterface().lisFichierShp(strNomFichierShp, zones); btnSauverBarre.setDisable(false); if (iNombreZones > 0) { cbMasqueZones.setDisable(false); } afficheBarrePersonnalisee(iLargeur, iHauteur, false); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } }); btnSauverBarre.setOnMouseClicked((t) -> { try { sauverBarre(strNomFichierShp); getGestionnaireInterface().chargeBarrePersonnalisee(strNomFichierBarre); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); cbMasqueZones.selectedProperty() .addListener((ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) -> { afficheBarrePersonnalisee(iLargeur, iHauteur, new_val); }); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private void initialize() { model = new TMATableModel(); groupByIDProperty.addListener((v, o, n) -> refreshTableData()); MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem miOpen = new MenuItem("Open..."); miOpen.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); miOpen.setOnAction(e -> {//from w w w . j a va 2s.c o m File file = QuPathGUI.getDialogHelper(stage).promptForFile(null, null, "TMA data files", new String[] { "qptma" }); if (file == null) return; setInputFile(file); }); MenuItem miSave = new MenuItem("Save As..."); miSave.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miSave.setOnAction( e -> SummaryMeasurementTableCommand.saveTableModel(model, null, Collections.emptyList())); MenuItem miImportFromImage = new MenuItem("Import from current image..."); miImportFromImage.setAccelerator( new KeyCodeCombination(KeyCode.I, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromImage.setOnAction(e -> setTMAEntriesFromOpenImage()); MenuItem miImportFromProject = new MenuItem("Import from current project... (experimental)"); miImportFromProject.setAccelerator( new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromProject.setOnAction(e -> setTMAEntriesFromOpenProject()); MenuItem miImportClipboard = new MenuItem("Import from clipboard..."); miImportClipboard.setOnAction(e -> { String text = Clipboard.getSystemClipboard().getString(); if (text == null) { DisplayHelpers.showErrorMessage("Import scores", "Clipboard is empty!"); return; } int n = importScores(text); if (n > 0) { setTMAEntries(new ArrayList<>(entriesBase)); } DisplayHelpers.showMessageDialog("Import scores", "Number of scores imported: " + n); }); Menu menuEdit = new Menu("Edit"); MenuItem miCopy = new MenuItem("Copy table to clipboard"); miCopy.setOnAction(e -> { SummaryMeasurementTableCommand.copyTableContentsToClipboard(model, Collections.emptyList()); }); combinedPredicate.addListener((v, o, n) -> { // We want any other changes triggered by this to have happened, // so that the data has already been updated Platform.runLater(() -> handleTableContentChange()); }); // Reset the scores for missing cores - this ensures they will be NaN and not influence subsequent results MenuItem miResetMissingScores = new MenuItem("Reset scores for missing cores"); miResetMissingScores.setOnAction(e -> { int changes = 0; for (TMAEntry entry : entriesBase) { if (!entry.isMissing()) continue; boolean changed = false; for (String m : entry.getMeasurementNames().toArray(new String[0])) { if (!TMASummaryEntry.isSurvivalColumn(m) && !Double.isNaN(entry.getMeasurementAsDouble(m))) { entry.putMeasurement(m, null); changed = true; } } if (changed) changes++; } if (changes == 0) { logger.info("No changes made when resetting scores for missing cores!"); return; } logger.info("{} change(s) made when resetting scores for missing cores!", changes); table.refresh(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); }); menuEdit.getItems().add(miResetMissingScores); QuPathGUI.addMenuItems(menuFile, miOpen, miSave, null, miImportClipboard, null, miImportFromImage, miImportFromProject); menuBar.getMenus().add(menuFile); menuEdit.getItems().add(miCopy); menuBar.getMenus().add(menuEdit); menuFile.setOnShowing(e -> { boolean imageDataAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getImageData() != null && QuPathGUI.getInstance().getImageData().getHierarchy().getTMAGrid() != null; miImportFromImage.setDisable(!imageDataAvailable); boolean projectAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getProject() != null && !QuPathGUI.getInstance().getProject().getImageList().isEmpty(); miImportFromProject.setDisable(!projectAvailable); }); // Double-clicking previously used for comments... but conflicts with tree table expansion // table.setOnMouseClicked(e -> { // if (!e.isPopupTrigger() && e.getClickCount() > 1) // promptForComment(); // }); table.setPlaceholder(new Text("Drag TMA data folder onto window, or choose File -> Open")); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); BorderPane pane = new BorderPane(); pane.setTop(menuBar); menuBar.setUseSystemMenuBar(true); // Create options ToolBar toolbar = new ToolBar(); Label labelMeasurementMethod = new Label("Combination method"); labelMeasurementMethod.setLabelFor(comboMeasurementMethod); labelMeasurementMethod .setTooltip(new Tooltip("Method whereby measurements for multiple cores with the same " + TMACoreObject.KEY_UNIQUE_ID + " will be combined")); CheckBox cbHidePane = new CheckBox("Hide pane"); cbHidePane.setSelected(hidePaneProperty.get()); cbHidePane.selectedProperty().bindBidirectional(hidePaneProperty); CheckBox cbGroupByID = new CheckBox("Group by ID"); entriesBase.addListener((Change<? extends TMAEntry> event) -> { if (!event.getList().stream().anyMatch(e -> e.getMetadataValue(TMACoreObject.KEY_UNIQUE_ID) != null)) { cbGroupByID.setSelected(false); cbGroupByID.setDisable(true); } else { cbGroupByID.setDisable(false); } }); cbGroupByID.setSelected(groupByIDProperty.get()); cbGroupByID.selectedProperty().bindBidirectional(groupByIDProperty); CheckBox cbUseSelected = new CheckBox("Use selection only"); cbUseSelected.selectedProperty().bindBidirectional(useSelectedProperty); CheckBox cbSkipMissing = new CheckBox("Hide missing cores"); cbSkipMissing.selectedProperty().bindBidirectional(skipMissingCoresProperty); skipMissingCoresProperty.addListener((v, o, n) -> { table.refresh(); updateSurvivalCurves(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); }); toolbar.getItems().addAll(labelMeasurementMethod, comboMeasurementMethod, new Separator(Orientation.VERTICAL), cbHidePane, new Separator(Orientation.VERTICAL), cbGroupByID, new Separator(Orientation.VERTICAL), cbUseSelected, new Separator(Orientation.VERTICAL), cbSkipMissing); comboMeasurementMethod.getItems().addAll(MeasurementCombinationMethod.values()); comboMeasurementMethod.getSelectionModel().select(MeasurementCombinationMethod.MEDIAN); selectedMeasurementCombinationProperty.addListener((v, o, n) -> table.refresh()); ContextMenu popup = new ContextMenu(); MenuItem miSetMissing = new MenuItem("Set missing"); miSetMissing.setOnAction(e -> setSelectedMissingStatus(true)); MenuItem miSetAvailable = new MenuItem("Set available"); miSetAvailable.setOnAction(e -> setSelectedMissingStatus(false)); MenuItem miExpand = new MenuItem("Expand all"); miExpand.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(true); } }); MenuItem miCollapse = new MenuItem("Collapse all"); miCollapse.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(false); } }); popup.getItems().addAll(miSetMissing, miSetAvailable, new SeparatorMenuItem(), miExpand, miCollapse); table.setContextMenu(popup); table.setRowFactory(e -> { TreeTableRow<TMAEntry> row = new TreeTableRow<>(); // // Make rows invisible if they don't pass the predicate // row.visibleProperty().bind(Bindings.createBooleanBinding(() -> { // TMAEntry entry = row.getItem(); // if (entry == null || (entry.isMissing() && skipMissingCoresProperty.get())) // return false; // return entries.getPredicate() == null || entries.getPredicate().test(entry); // }, // skipMissingCoresProperty, // entries.predicateProperty())); // Style rows according to what they contain row.styleProperty().bind(Bindings.createStringBinding(() -> { if (row.isSelected()) return ""; TMAEntry entry = row.getItem(); if (entry == null || entry instanceof TMASummaryEntry) return ""; else if (entry.isMissing()) return "-fx-background-color:rgb(225,225,232)"; else return "-fx-background-color:rgb(240,240,245)"; }, row.itemProperty(), row.selectedProperty())); // row.itemProperty().addListener((v, o, n) -> { // if (n == null || n instanceof TMASummaryEntry || row.isSelected()) // row.setStyle(""); // else if (n.isMissing()) // row.setStyle("-fx-background-color:rgb(225,225,232)"); // else // row.setStyle("-fx-background-color:rgb(240,240,245)"); // }); return row; }); BorderPane paneTable = new BorderPane(); paneTable.setTop(toolbar); paneTable.setCenter(table); MasterDetailPane mdTablePane = new MasterDetailPane(Side.RIGHT, paneTable, createSidePane(), true); mdTablePane.showDetailNodeProperty().bind(Bindings.createBooleanBinding( () -> !hidePaneProperty.get() && !entriesBase.isEmpty(), hidePaneProperty, entriesBase)); mdTablePane.setDividerPosition(2.0 / 3.0); pane.setCenter(mdTablePane); model.getEntries().addListener(new ListChangeListener<TMAEntry>() { @Override public void onChanged(ListChangeListener.Change<? extends TMAEntry> c) { if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); } }); Label labelPredicate = new Label(); labelPredicate.setPadding(new Insets(5, 5, 5, 5)); labelPredicate.setAlignment(Pos.CENTER); // labelPredicate.setStyle("-fx-background-color: rgba(20, 120, 20, 0.15);"); labelPredicate.setStyle("-fx-background-color: rgba(120, 20, 20, 0.15);"); labelPredicate.textProperty().addListener((v, o, n) -> { if (n.trim().length() > 0) pane.setBottom(labelPredicate); else pane.setBottom(null); }); labelPredicate.setMaxWidth(Double.MAX_VALUE); labelPredicate.setMaxHeight(labelPredicate.getPrefHeight()); labelPredicate.setTextAlignment(TextAlignment.CENTER); predicateMeasurements.addListener((v, o, n) -> { if (n == null) labelPredicate.setText(""); else if (n instanceof TablePredicate) { TablePredicate tp = (TablePredicate) n; if (tp.getOriginalCommand().trim().isEmpty()) labelPredicate.setText(""); else labelPredicate.setText("Predicate: " + tp.getOriginalCommand()); } else labelPredicate.setText("Predicate: " + n.toString()); }); // predicate.set(new TablePredicate("\"Tumor\" > 100")); scene = new Scene(pane); scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> { KeyCode code = e.getCode(); if ((code == KeyCode.SPACE || code == KeyCode.ENTER) && entrySelected != null) { promptForComment(); return; } }); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);/*from w w w . j a v a2s . c om*/ comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane getCustomizeTablePane() { TableView<TreeTableColumn<TMAEntry, ?>> tableColumns = new TableView<>(); tableColumns.setPlaceholder(new Text("No columns available")); tableColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); tableColumns.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); SortedList<TreeTableColumn<TMAEntry, ?>> sortedColumns = new SortedList<>( table.getColumns().filtered(p -> !p.getText().trim().isEmpty())); sortedColumns.setComparator((c1, c2) -> c1.getText().compareTo(c2.getText())); tableColumns.setItems(sortedColumns); sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty()); // sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty()); TableColumn<TreeTableColumn<TMAEntry, ?>, String> columnName = new TableColumn<>("Column"); columnName.setCellValueFactory(v -> v.getValue().textProperty()); TableColumn<TreeTableColumn<TMAEntry, ?>, Boolean> columnVisible = new TableColumn<>("Visible"); columnVisible.setCellValueFactory(v -> v.getValue().visibleProperty()); // columnVisible.setCellValueFactory(col -> { // SimpleBooleanProperty prop = new SimpleBooleanProperty(col.getValue().isVisible()); // prop.addListener((v, o, n) -> col.getValue().setVisible(n)); // return prop; // });/* w w w. j a va2 s. c o m*/ tableColumns.setEditable(true); columnVisible.setCellFactory(v -> new CheckBoxTableCell<>()); tableColumns.getColumns().add(columnName); tableColumns.getColumns().add(columnVisible); ContextMenu contextMenu = new ContextMenu(); Action actionShowSelected = new Action("Show selected", e -> { for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) { if (col != null) col.setVisible(true); else { // Not sure why this happens...? logger.trace("Selected column is null!"); } } }); Action actionHideSelected = new Action("Hide selected", e -> { for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) { if (col != null) col.setVisible(false); else { // Not sure why this happens...? logger.trace("Selected column is null!"); } } }); contextMenu.getItems().addAll(ActionUtils.createMenuItem(actionShowSelected), ActionUtils.createMenuItem(actionHideSelected)); tableColumns.setContextMenu(contextMenu); tableColumns.setTooltip( new Tooltip("Show or hide table columns - right-click to change multiple columns at once")); BorderPane paneColumns = new BorderPane(tableColumns); paneColumns.setBottom(PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionShowSelected), ActionUtils.createButton(actionHideSelected))); VBox paneRows = new VBox(); // Create a box to filter on some metadata text ComboBox<String> comboMetadata = new ComboBox<>(); comboMetadata.setItems(metadataNames); comboMetadata.getSelectionModel().getSelectedItem(); comboMetadata.setPromptText("Select column"); TextField tfFilter = new TextField(); CheckBox cbExact = new CheckBox("Exact"); // Set listeners cbExact.selectedProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); tfFilter.textProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); comboMetadata.getSelectionModel().selectedItemProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); GridPane paneMetadata = new GridPane(); paneMetadata.add(comboMetadata, 0, 0); paneMetadata.add(tfFilter, 1, 0); paneMetadata.add(cbExact, 2, 0); paneMetadata.setPadding(new Insets(10, 10, 10, 10)); paneMetadata.setVgap(2); paneMetadata.setHgap(5); comboMetadata.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(tfFilter, Priority.ALWAYS); GridPane.setFillWidth(comboMetadata, Boolean.TRUE); GridPane.setFillWidth(tfFilter, Boolean.TRUE); TitledPane tpMetadata = new TitledPane("Metadata filter", paneMetadata); tpMetadata.setExpanded(false); // tpMetadata.setCollapsible(false); Tooltip tooltipMetadata = new Tooltip( "Enter text to filter entries according to a selected metadata column"); Tooltip.install(paneMetadata, tooltipMetadata); tpMetadata.setTooltip(tooltipMetadata); paneRows.getChildren().add(tpMetadata); // Add measurement predicate TextField tfCommand = new TextField(); tfCommand.setTooltip(new Tooltip("Predicate used to filter entries for inclusion")); TextFields.bindAutoCompletion(tfCommand, e -> { int ind = tfCommand.getText().lastIndexOf("\""); if (ind < 0) return Collections.emptyList(); String part = tfCommand.getText().substring(ind + 1); return measurementNames.stream().filter(n -> n.startsWith(part)).map(n -> "\"" + n + "\" ") .collect(Collectors.toList()); }); String instructions = "Enter a predicate to filter entries.\n" + "Only entries passing the test will be included in any results.\n" + "Examples of predicates include:\n" + " \"Num Tumor\" > 200\n" + " \"Num Tumor\" > 100 && \"Num Stroma\" < 1000"; // labelInstructions.setTooltip(new Tooltip("Note: measurement names must be in \"inverted commands\" and\n" + // "&& indicates 'and', while || indicates 'or'.")); BorderPane paneMeasurementFilter = new BorderPane(tfCommand); Label label = new Label("Predicate: "); label.setAlignment(Pos.CENTER); label.setMaxHeight(Double.MAX_VALUE); paneMeasurementFilter.setLeft(label); Button btnApply = new Button("Apply"); btnApply.setOnAction(e -> { TablePredicate predicateNew = new TablePredicate(tfCommand.getText()); if (predicateNew.isValid()) { predicateMeasurements.set(predicateNew); } else { DisplayHelpers.showErrorMessage("Invalid predicate", "Current predicate '" + tfCommand.getText() + "' is invalid!"); } e.consume(); }); TitledPane tpMeasurementFilter = new TitledPane("Measurement filter", paneMeasurementFilter); tpMeasurementFilter.setExpanded(false); Tooltip tooltipInstructions = new Tooltip(instructions); tpMeasurementFilter.setTooltip(tooltipInstructions); Tooltip.install(paneMeasurementFilter, tooltipInstructions); paneMeasurementFilter.setRight(btnApply); paneRows.getChildren().add(tpMeasurementFilter); logger.info("Predicate set to: {}", predicateMeasurements.get()); VBox pane = new VBox(); // TitledPane tpColumns = new TitledPane("Select column", paneColumns); // tpColumns.setMaxHeight(Double.MAX_VALUE); // tpColumns.setCollapsible(false); pane.getChildren().addAll(paneColumns, new Separator(), paneRows); VBox.setVgrow(paneColumns, Priority.ALWAYS); return pane; }