Search in sources :

Example 1 with ParameterChangeListener

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"));
}
Also used : ParameterChangeListener(qupath.lib.plugins.parameters.ParameterChangeListener) BorderPane(javafx.scene.layout.BorderPane) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) ParameterPanelFX(qupath.lib.gui.dialogs.ParameterPanelFX) ParameterList(qupath.lib.plugins.parameters.ParameterList) HistogramPanelFX(qupath.lib.gui.charts.HistogramPanelFX) ThresholdedChartWrapper(qupath.lib.gui.charts.HistogramPanelFX.ThresholdedChartWrapper)

Example 2 with ParameterChangeListener

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();
}
Also used : ParameterChangeListener(qupath.lib.plugins.parameters.ParameterChangeListener) JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) TextArea(javafx.scene.control.TextArea) Scene(javafx.scene.Scene) Stage(javafx.stage.Stage) ParameterList(qupath.lib.plugins.parameters.ParameterList) Parameter(qupath.lib.plugins.parameters.Parameter) StringParameter(qupath.lib.plugins.parameters.StringParameter) EmptyParameter(qupath.lib.plugins.parameters.EmptyParameter) IntParameter(qupath.lib.plugins.parameters.IntParameter) NumericParameter(qupath.lib.plugins.parameters.NumericParameter) DoubleParameter(qupath.lib.plugins.parameters.DoubleParameter) ChoiceParameter(qupath.lib.plugins.parameters.ChoiceParameter) BooleanParameter(qupath.lib.plugins.parameters.BooleanParameter)

Aggregations

BorderPane (javafx.scene.layout.BorderPane)2 ParameterChangeListener (qupath.lib.plugins.parameters.ParameterChangeListener)2 ParameterList (qupath.lib.plugins.parameters.ParameterList)2 JFXPanel (javafx.embed.swing.JFXPanel)1 Scene (javafx.scene.Scene)1 Label (javafx.scene.control.Label)1 TextArea (javafx.scene.control.TextArea)1 Tooltip (javafx.scene.control.Tooltip)1 Stage (javafx.stage.Stage)1 HistogramPanelFX (qupath.lib.gui.charts.HistogramPanelFX)1 ThresholdedChartWrapper (qupath.lib.gui.charts.HistogramPanelFX.ThresholdedChartWrapper)1 ParameterPanelFX (qupath.lib.gui.dialogs.ParameterPanelFX)1 BooleanParameter (qupath.lib.plugins.parameters.BooleanParameter)1 ChoiceParameter (qupath.lib.plugins.parameters.ChoiceParameter)1 DoubleParameter (qupath.lib.plugins.parameters.DoubleParameter)1 EmptyParameter (qupath.lib.plugins.parameters.EmptyParameter)1 IntParameter (qupath.lib.plugins.parameters.IntParameter)1 NumericParameter (qupath.lib.plugins.parameters.NumericParameter)1 Parameter (qupath.lib.plugins.parameters.Parameter)1 StringParameter (qupath.lib.plugins.parameters.StringParameter)1