use of qupath.lib.plugins.parameters.ParameterChangeListener in project qupath by qupath.
the class PathIntensityClassifierPane method initialize.
private void initialize() {
panelHistogram = new HistogramPanelFX();
panelHistogram.setShowTickLabels(false);
panelHistogram.getChart().getXAxis().setVisible(false);
panelHistogram.getChart().getXAxis().setTickMarkVisible(false);
panelHistogram.getChart().getYAxis().setVisible(false);
panelHistogram.getChart().getYAxis().setTickMarkVisible(false);
panelHistogram.getChart().setMinHeight(10);
panelHistogram.getChart().setMinWidth(10);
panelHistogram.getChart().setVisible(false);
panelHistogram.getChart().setAnimated(false);
thresholdWrapper = new ThresholdedChartWrapper(panelHistogram.getChart());
comboIntensities = new ComboBox<>();
comboIntensities.setOnAction(e -> {
String selected = comboIntensities.getSelectionModel().getSelectedItem();
logger.trace("Intensities selected: {}", selected);
updateIntensityHistogram();
});
comboIntensities.setTooltip(new Tooltip("Select an intensity feature for thresholding, e.g. to sub-classify objects according to levels of positive staining"));
double threshold_1 = 0.2;
double threshold_2 = 0.4;
double threshold_3 = 0.6;
paramsIntensity = new ParameterList().addDoubleParameter("threshold_1", "Threshold 1+", threshold_1, null, 0, 1.5, "Set first intensity threshold, if required (lowest)").addDoubleParameter("threshold_2", "Threshold 2+", threshold_2, null, 0, 1.5, "Set second intensity threshold, if required (intermediate)").addDoubleParameter("threshold_3", "Threshold 3+", threshold_3, null, 0, 1.5, "Set third intensity threshold, if required (highest)").addBooleanParameter("single_threshold", "Use single threshold", false, "Use only the first intensity threshold to separate positive & negative objects");
pane.add(new Label("Intensity feature: "), 0, 0);
pane.add(comboIntensities, 1, 0);
comboIntensities.setMaxWidth(Double.MAX_VALUE);
GridPane.setHgrow(comboIntensities, Priority.ALWAYS);
this.panelParameters = new ParameterPanelFX(paramsIntensity);
this.panelParameters.addParameterChangeListener(new ParameterChangeListener() {
@Override
public void parameterChanged(ParameterList parameterList, String key, boolean isAdjusting) {
if ("single_threshold".equals(key)) {
boolean single = paramsIntensity.getBooleanParameterValue("single_threshold");
panelParameters.setParameterEnabled("threshold_2", !single);
panelParameters.setParameterEnabled("threshold_3", !single);
}
updateHistogramThresholdLines();
}
});
// pane.add(panelParameters.getPane(), 0, 1, 2, 1);
// GridPane.setFillWidth(panelParameters.getPane(), Boolean.FALSE);
//
// pane.add(thresholdWrapper.getPane(), 2, 1, 1, 1);
// // thresholdWrapper.getPane().setMinSize(10, 10);
// // GridPane.setHgrow(thresholdWrapper.getPane(), Priority.ALWAYS);
// GridPane.setFillHeight(thresholdWrapper.getPane(), Boolean.TRUE);
BorderPane paneBorder = new BorderPane();
paneBorder.setLeft(panelParameters.getPane());
paneBorder.setCenter(thresholdWrapper.getPane());
pane.add(paneBorder, 0, 1, 2, 1);
pane.setVgap(5);
pane.setHgap(5);
// if (addTitle)
// setBorder(BorderFactory.createTitledBorder("Intensity feature"));
}
use of qupath.lib.plugins.parameters.ParameterChangeListener in project qupath by qupath.
the class ParameterPanelFX method demoParameterPanel.
static void demoParameterPanel() {
new JFXPanel();
if (!Platform.isFxApplicationThread()) {
Platform.runLater(() -> demoParameterPanel());
return;
}
Stage frame = new Stage();
frame.setTitle("Testing parameter panel");
int k = 0;
final ParameterList params = new ParameterList().addTitleParameter("Parameter list").addEmptyParameter("Here is a list of parameters that I am testing out").addIntParameter(Integer.toString(k++), "Enter an int", 5, "px", "Unbounded int").addDoubleParameter(Integer.toString(k++), "Enter a double", 5.2, "microns", "Unbounded double").addDoubleParameter(Integer.toString(k++), "Enter a double in range", 5.2, null, 1, 10, "Bounded double").addIntParameter(Integer.toString(k++), "Enter an int in range", 5, null, 1, 10, "Bounded int").addStringParameter(Integer.toString(k++), "Enter a string", "Default here").addChoiceParameter(Integer.toString(k++), "Choose a choice", "Two", Arrays.asList("One", "Two", "Three"), "Simple choice").addChoiceParameter(Integer.toString(k++), "Choose a number choice", Integer.valueOf(2), Arrays.asList(1, 2, 3), "Numeric choice").addBooleanParameter(Integer.toString(k++), "Check me out", true);
BorderPane borderPane = new BorderPane();
ParameterPanelFX panel = new ParameterPanelFX(params);
final TextArea textArea = new TextArea();
for (Parameter<?> p : params.getParameters().values()) {
textArea.setText(textArea.getText() + (p + "\n"));
}
panel.addParameterChangeListener(new ParameterChangeListener() {
@Override
public void parameterChanged(ParameterList params, String key, boolean isAdjusting) {
textArea.setText("");
for (Parameter<?> p : params.getParameters().values()) textArea.setText(textArea.getText() + (p + "\n"));
}
});
borderPane.setCenter(panel.getPane());
borderPane.setBottom(textArea);
frame.setScene(new Scene(borderPane));
frame.show();
}
Aggregations