Example usage for javafx.scene.control Tooltip setAutoHide

List of usage examples for javafx.scene.control Tooltip setAutoHide

Introduction

In this page you can find the example usage for javafx.scene.control Tooltip setAutoHide.

Prototype

public final void setAutoHide(boolean value) 

Source Link

Usage

From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java

/**
 * Setup an 'INFORMATION' info marker on the component. Automatically displays anytime that the initialControl is disabled.
 * Put the initial control in the provided stack pane
 *///from   w ww. jav a2s. com
public static Node setupDisabledInfoMarker(Control initialControl, StackPane stackPane,
        ObservableStringValue reasonWhyControlDisabled) {
    ImageView information = Images.INFORMATION.createImageView();

    information.visibleProperty().bind(initialControl.disabledProperty());
    Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(reasonWhyControlDisabled);
    Tooltip.install(information, tooltip);
    tooltip.setAutoHide(true);

    information.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            tooltip.show(information, event.getScreenX(), event.getScreenY());

        }

    });

    stackPane.setMaxWidth(Double.MAX_VALUE);
    stackPane.getChildren().add(initialControl);
    StackPane.setAlignment(initialControl, Pos.CENTER_LEFT);
    stackPane.getChildren().add(information);
    if (initialControl instanceof Button) {
        StackPane.setAlignment(information, Pos.CENTER);
    } else if (initialControl instanceof CheckBox) {
        StackPane.setAlignment(information, Pos.CENTER_LEFT);
        StackPane.setMargin(information, new Insets(0, 0, 0, 1));
    } else {
        StackPane.setAlignment(information, Pos.CENTER_RIGHT);
        double insetFromRight = (initialControl instanceof ComboBox ? 30.0 : 5.0);
        StackPane.setMargin(information, new Insets(0.0, insetFromRight, 0.0, 0.0));
    }
    return stackPane;
}

From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java

/**
 * Setup an 'EXCLAMATION' error marker on the component. Automatically displays anytime that the reasonWhyControlInvalid value
 * is false. Hides when the isControlCurrentlyValid is true.
 * @param stackPane - optional - created if necessary
 *//* www .  j a  v a  2 s  . c  om*/
public static StackPane setupErrorMarker(Node initialNode, StackPane stackPane,
        ValidBooleanBinding isNodeCurrentlyValid) {
    ImageView exclamation = Images.EXCLAMATION.createImageView();

    if (stackPane == null) {
        stackPane = new StackPane();
    }

    exclamation.visibleProperty().bind(isNodeCurrentlyValid.not());
    Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(isNodeCurrentlyValid.getReasonWhyInvalid());
    Tooltip.install(exclamation, tooltip);
    tooltip.setAutoHide(true);

    exclamation.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            tooltip.show(exclamation, event.getScreenX(), event.getScreenY());

        }

    });

    stackPane.setMaxWidth(Double.MAX_VALUE);
    stackPane.getChildren().add(initialNode);
    StackPane.setAlignment(initialNode, Pos.CENTER_LEFT);
    stackPane.getChildren().add(exclamation);
    StackPane.setAlignment(exclamation, Pos.CENTER_RIGHT);
    double insetFromRight;
    if (initialNode instanceof ComboBox) {
        insetFromRight = 30.0;
    } else if (initialNode instanceof ChoiceBox) {
        insetFromRight = 25.0;
    } else {
        insetFromRight = 5.0;
    }
    StackPane.setMargin(exclamation, new Insets(0.0, insetFromRight, 0.0, 0.0));
    return stackPane;
}

From source file:com.wineshop.client.Home.java

@Override
public void initialize(URL url, ResourceBundle bundle) {
    // Setup of the table view
    vineyards.setSortAdapter(new TableViewSortAdapter<Vineyard>(tableVineyards, Vineyard.class));
    vineyards.getFilter().nameProperty().bindBidirectional(fieldSearch.textProperty());

    // Setup of the creation/edit form
    labelFormVineyard.textProperty()/*from w w w .  j  a va2 s.c o m*/
            .bind(Bindings.when(vineyard.savedProperty()).then("Edit vineyard").otherwise("Create vineyard"));

    vineyard.instanceProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> observable, Vineyard oldValue,
                Vineyard newValue) {
            if (oldValue != null) {
                fieldName.textProperty().unbindBidirectional(oldValue.nameProperty());
                fieldAddress.textProperty().unbindBidirectional(oldValue.getAddress().addressProperty());
                listWines.setItems(null);
            }
            if (newValue != null) {
                fieldName.textProperty().bindBidirectional(newValue.nameProperty());
                fieldAddress.textProperty().bindBidirectional(newValue.getAddress().addressProperty());
                listWines.setItems(newValue.getWines());
            }
        }
    });

    // Define the cell factory for the list of wines 
    listWines.setCellFactory(new Callback<ListView<Wine>, ListCell<Wine>>() {
        public ListCell<Wine> call(ListView<Wine> listView) {
            return new WineListCell();
        }
    });

    buttonDelete.visibleProperty().bind(vineyard.savedProperty());
    buttonDelete.disableProperty().bind(Bindings.not(identity.ifAllGranted("ROLE_ADMIN")));
    buttonSave.disableProperty().bind(Bindings.not(vineyard.dirtyProperty()));
    buttonCancel.disableProperty()
            .bind(Bindings.not(Bindings.or(vineyard.savedProperty(), vineyard.dirtyProperty())));

    // Link the table selection and the entity instance in the form 
    select(null);
    tableVineyards.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> property, Vineyard oldSelection,
                Vineyard newSelection) {
            select(newSelection);
        }
    });

    formVineyard.addEventHandler(ValidationResultEvent.INVALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: red");
            if (event.getTarget() instanceof TextInputControl && event.getErrorResults() != null
                    && event.getErrorResults().size() > 0) {
                Tooltip tooltip = new Tooltip(event.getErrorResults().get(0).getMessage());
                tooltip.setAutoHide(true);
                ((TextInputControl) event.getTarget()).setTooltip(tooltip);
            }
        }
    });
    formVineyard.addEventHandler(ValidationResultEvent.VALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: null");
            if (event.getTarget() instanceof TextInputControl) {
                Tooltip tooltip = ((TextInputControl) event.getTarget()).getTooltip();
                if (tooltip != null && tooltip.isActivated())
                    tooltip.hide();
                ((TextInputControl) event.getTarget()).setTooltip(null);
            }
        }
    });
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java

private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) {
    if (assemblageValid) {
        for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
            allValid_.removeBinding(ssp);
        }//from   ww w .  j  av a  2s  .  c  o m
        currentDataFieldWarnings_.clear();
        for (SememeGUIDataTypeNodeDetails nd : currentDataFields_) {
            nd.cleanupListener();
        }
        currentDataFields_.clear();

        GridPane gp = new GridPane();
        gp.setHgap(10.0);
        gp.setVgap(10.0);
        gp.setStyle("-fx-padding: 5;");
        int row = 0;
        boolean extraInfoColumnIsRequired = false;
        for (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) {
            SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("")
                    : null);
            SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null
                    && ci.getValidator() == null) ? null : new SimpleStringProperty());
            ComboBox<DynamicSememeDataType> polymorphicType = null;

            Label l = new Label(ci.getColumnName());
            l.getStyleClass().add("boldLabel");
            l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l));
            Tooltip.install(l, new Tooltip(ci.getColumnDescription()));
            int col = 0;
            gp.add(l, col++, row);

            if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) {
                polymorphicType = new ComboBox<>();
                polymorphicType.setEditable(false);
                polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() {

                    @Override
                    public String toString(DynamicSememeDataType object) {
                        return object.getDisplayName();
                    }

                    @Override
                    public DynamicSememeDataType fromString(String string) {
                        throw new RuntimeException("unecessary");
                    }
                });
                for (DynamicSememeDataType type : DynamicSememeDataType.values()) {
                    if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) {
                        continue;
                    } else {
                        polymorphicType.getItems().add(type);
                    }
                }
                polymorphicType.getSelectionModel()
                        .select((currentValues == null ? DynamicSememeDataType.STRING
                                : (currentValues[row] == null ? DynamicSememeDataType.STRING
                                        : currentValues[row].getDynamicSememeDataType())));
            }

            SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType(
                    ci.getColumnDataType(), ci.getDefaultColumnValue(),
                    (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip,
                    (polymorphicType == null ? null
                            : polymorphicType.getSelectionModel().selectedItemProperty()),
                    allValid_, ci.getValidator(), ci.getValidatorData());

            currentDataFieldWarnings_.addAll(nd.getBoundToAllValid());
            if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) {
                nd.addUpdateParentListListener(currentDataFieldWarnings_);
            }

            currentDataFields_.add(nd);

            gp.add(nd.getNodeForDisplay(), col++, row);

            Label colType = new Label(ci.getColumnDataType().getDisplayName());
            colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType));
            gp.add((polymorphicType == null ? colType : polymorphicType), col++, row);

            if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                extraInfoColumnIsRequired = true;

                StackPane stackPane = new StackPane();
                stackPane.setMaxWidth(Double.MAX_VALUE);

                if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                    ImageView information = Images.INFORMATION.createImageView();
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(defaultValueTooltip);
                    Tooltip.install(information, tooltip);
                    tooltip.setAutoHide(true);
                    information.setOnMouseClicked(
                            event -> tooltip.show(information, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(information);
                }

                if (ci.isColumnRequired()) {
                    ImageView exclamation = Images.EXCLAMATION.createImageView();

                    final BooleanProperty showExclamation = new SimpleBooleanProperty(
                            StringUtils.isNotBlank(valueIsRequired.get()));
                    valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue,
                            newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue)));

                    exclamation.visibleProperty().bind(showExclamation);
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(valueIsRequired);
                    Tooltip.install(exclamation, tooltip);
                    tooltip.setAutoHide(true);

                    exclamation.setOnMouseClicked(
                            event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(exclamation);
                }

                gp.add(stackPane, col++, row);
            }
            row++;
        }

        ColumnConstraints cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.ALWAYS);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        if (extraInfoColumnIsRequired) {
            cc = new ColumnConstraints();
            cc.setHgrow(Priority.NEVER);
            gp.getColumnConstraints().add(cc);
        }

        if (row == 0) {
            sp_.setContent(new Label("This assemblage does not allow data fields"));
        } else {
            sp_.setContent(gp);
        }
        allValid_.invalidate();
    } else {
        sp_.setContent(null);
    }
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java

private void buildDataFields(boolean assemblageValid, RefexDynamicDataBI[] currentValues) {
    if (assemblageValid) {
        for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
            allValid_.removeBinding(ssp);
        }/* w w  w  . jav a  2s.co  m*/
        currentDataFieldWarnings_.clear();
        for (RefexDataTypeNodeDetails nd : currentDataFields_) {
            nd.cleanupListener();
        }
        currentDataFields_.clear();

        GridPane gp = new GridPane();
        gp.setHgap(10.0);
        gp.setVgap(10.0);
        gp.setStyle("-fx-padding: 5;");
        int row = 0;
        boolean extraInfoColumnIsRequired = false;
        for (RefexDynamicColumnInfo ci : assemblageInfo_.getColumnInfo()) {
            SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("")
                    : null);
            SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null
                    && ci.getValidator() == null) ? null : new SimpleStringProperty());
            ComboBox<RefexDynamicDataType> polymorphicType = null;

            Label l = new Label(ci.getColumnName());
            l.getStyleClass().add("boldLabel");
            l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l));
            Tooltip.install(l, new Tooltip(ci.getColumnDescription()));
            int col = 0;
            gp.add(l, col++, row);

            if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) {
                polymorphicType = new ComboBox<>();
                polymorphicType.setEditable(false);
                polymorphicType.setConverter(new StringConverter<RefexDynamicDataType>() {

                    @Override
                    public String toString(RefexDynamicDataType object) {
                        return object.getDisplayName();
                    }

                    @Override
                    public RefexDynamicDataType fromString(String string) {
                        throw new RuntimeException("unecessary");
                    }
                });
                for (RefexDynamicDataType type : RefexDynamicDataType.values()) {
                    if (type == RefexDynamicDataType.POLYMORPHIC || type == RefexDynamicDataType.UNKNOWN) {
                        continue;
                    } else {
                        polymorphicType.getItems().add(type);
                    }
                }
                polymorphicType.getSelectionModel()
                        .select((currentValues == null ? RefexDynamicDataType.STRING
                                : (currentValues[row] == null ? RefexDynamicDataType.STRING
                                        : currentValues[row].getRefexDataType())));
            }

            RefexDataTypeNodeDetails nd = RefexDataTypeFXNodeBuilder.buildNodeForType(ci.getColumnDataType(),
                    ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]),
                    valueIsRequired, defaultValueTooltip,
                    (polymorphicType == null ? null
                            : polymorphicType.getSelectionModel().selectedItemProperty()),
                    allValid_, new SimpleObjectProperty<>(ci.getValidator()),
                    new SimpleObjectProperty<>(ci.getValidatorData()));

            currentDataFieldWarnings_.addAll(nd.getBoundToAllValid());
            if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) {
                nd.addUpdateParentListListener(currentDataFieldWarnings_);
            }

            currentDataFields_.add(nd);

            gp.add(nd.getNodeForDisplay(), col++, row);

            Label colType = new Label(ci.getColumnDataType().getDisplayName());
            colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType));
            gp.add((polymorphicType == null ? colType : polymorphicType), col++, row);

            if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                extraInfoColumnIsRequired = true;

                StackPane stackPane = new StackPane();
                stackPane.setMaxWidth(Double.MAX_VALUE);

                if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                    ImageView information = Images.INFORMATION.createImageView();
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(defaultValueTooltip);
                    Tooltip.install(information, tooltip);
                    tooltip.setAutoHide(true);
                    information.setOnMouseClicked(
                            event -> tooltip.show(information, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(information);
                }

                if (ci.isColumnRequired()) {
                    ImageView exclamation = Images.EXCLAMATION.createImageView();

                    final BooleanProperty showExclamation = new SimpleBooleanProperty(
                            StringUtils.isNotBlank(valueIsRequired.get()));
                    valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue,
                            newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue)));

                    exclamation.visibleProperty().bind(showExclamation);
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(valueIsRequired);
                    Tooltip.install(exclamation, tooltip);
                    tooltip.setAutoHide(true);

                    exclamation.setOnMouseClicked(
                            event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(exclamation);
                }

                gp.add(stackPane, col++, row);
            }
            row++;
        }

        ColumnConstraints cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.ALWAYS);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        if (extraInfoColumnIsRequired) {
            cc = new ColumnConstraints();
            cc.setHgrow(Priority.NEVER);
            gp.getColumnConstraints().add(cc);
        }

        if (row == 0) {
            sp_.setContent(new Label("This assemblage does not allow data fields"));
        } else {
            sp_.setContent(gp);
        }
        allValid_.invalidate();
    } else {
        sp_.setContent(null);
    }
}

From source file:nl.rivm.cib.episim.model.disease.infection.MSEIRSPlot.java

@Override
public void start(final Stage stage) {
    final SIRConfig conf = ConfigFactory.create(SIRConfig.class);
    final double[] t = conf.t();
    final long[] pop = conf.population();
    final double n0 = Arrays.stream(pop).sum();
    final String[] colors = conf.colors(), colors2 = conf.colors2();

    final Pane plot = new Pane();
    plot.setPrefSize(400, 300);/*  ww w.  j av  a  2  s.  c om*/
    plot.setMinSize(50, 50);

    final NumberAxis xAxis = new NumberAxis(t[0], t[1], (t[1] - t[0]) / 10);
    final NumberAxis yAxis = new NumberAxis(0, n0, n0 / 10);
    final Pane axes = new Pane();
    axes.prefHeightProperty().bind(plot.heightProperty());
    axes.prefWidthProperty().bind(plot.widthProperty());

    xAxis.setSide(Side.BOTTOM);
    xAxis.setMinorTickVisible(false);
    xAxis.setPrefWidth(axes.getPrefWidth());
    xAxis.prefWidthProperty().bind(axes.widthProperty());
    xAxis.layoutYProperty().bind(axes.heightProperty());

    yAxis.setSide(Side.LEFT);
    yAxis.setMinorTickVisible(false);
    yAxis.setPrefHeight(axes.getPrefHeight());
    yAxis.prefHeightProperty().bind(axes.heightProperty());
    yAxis.layoutXProperty().bind(Bindings.subtract(1, yAxis.widthProperty()));
    axes.getChildren().setAll(xAxis, yAxis);

    final Label lbl = new Label(String.format("R0=%.1f, recovery=%.1ft\nSIR(0)=%s", conf.reproduction(),
            conf.recovery(), Arrays.toString(pop)));
    lbl.setTextAlignment(TextAlignment.CENTER);
    lbl.setTextFill(Color.WHITE);

    final Path[] deterministic = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors[i]);
        final Path path = deterministic[i];
        path.setStroke(color.deriveColor(0, 1, 1, 0.6));
        path.setStrokeWidth(2);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    plot.getChildren().setAll(axes);

    // fill paths with integration estimates
    final double xl = xAxis.getLowerBound(), sx = plot.getPrefWidth() / (xAxis.getUpperBound() - xl),
            yh = plot.getPrefHeight(), sy = yh / (yAxis.getUpperBound() - yAxis.getLowerBound());
    final TreeMap<Double, Integer> iDeterministic = new TreeMap<>();

    MSEIRSTest.deterministic(conf, () -> new DormandPrince853Integrator(1.0E-8, 10, 1.0E-20, 1.0E-20))
            .subscribe(yt -> {
                iDeterministic.put(yt.getKey(), deterministic[0].getElements().size());
                final double[] y = yt.getValue();
                final double x = (yt.getKey() - xl) * sx;
                for (int i = 0; i < y.length; i++) {
                    final double yi = yh - y[i] * sy;
                    final PathElement di = deterministic[i].getElements().isEmpty() ? new MoveTo(x, yi)
                            : new LineTo(x, yi);
                    deterministic[i].getElements().add(di);
                }
            }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(deterministic));

    final Path[] stochasticTau = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors[i]);
        final Path path = stochasticTau[i];
        path.setStroke(color);
        path.setStrokeWidth(1);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    final TreeMap<Double, Integer> iStochasticTau = new TreeMap<>();
    MSEIRSTest.stochasticGillespie(conf).subscribe(yt -> {
        final double x = (yt.getKey() - xl) * sx;
        iStochasticTau.put(yt.getKey(), stochasticTau[0].getElements().size());
        final long[] y = yt.getValue();
        for (int i = 0; i < y.length; i++) {
            final double yi = yh - y[i] * sy;
            final ObservableList<PathElement> path = stochasticTau[i].getElements();
            if (path.isEmpty()) {
                path.add(new MoveTo(x, yi)); // first
            } else {
                final PathElement last = path.get(path.size() - 1);
                final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY();
                path.add(new LineTo(x, y_prev));
                path.add(new LineTo(x, yi));
            }
        }
    }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticTau));

    final Path[] stochasticRes = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors2[i]);
        final Path path = stochasticRes[i];
        path.setStroke(color);
        path.setStrokeWidth(1);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    final TreeMap<Double, Integer> iStochasticRes = new TreeMap<>();
    MSEIRSTest.stochasticSellke(conf).subscribe(yt -> {
        final double x = (yt.getKey() - xl) * sx;
        iStochasticRes.put(yt.getKey(), stochasticRes[0].getElements().size());
        final long[] y = yt.getValue();
        for (int i = 0; i < y.length; i++) {
            final double yi = yh - y[i] * sy;
            final ObservableList<PathElement> path = stochasticRes[i].getElements();
            if (path.isEmpty()) {
                path.add(new MoveTo(x, yi)); // first
            } else {
                final PathElement last = path.get(path.size() - 1);
                final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY();
                path.add(new LineTo(x, y_prev));
                path.add(new LineTo(x, yi));
            }
        }
    }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticRes));

    // auto-scale on stage/plot resize 
    // FIXME scaling around wrong origin, use ScatterChart?
    //         xAxis.widthProperty()
    //               .addListener( (ChangeListener<Number>) ( observable,
    //                  oldValue, newValue ) ->
    //               {
    //                  final double scale = ((Double) newValue)
    //                        / plot.getPrefWidth();
    //                  plot.getChildren().filtered( n -> n instanceof Path )
    //                        .forEach( n ->
    //                        {
    //                           final Path path = (Path) n;
    //                           path.setScaleX( scale );
    //                           path.setTranslateX( (path
    //                                 .getBoundsInParent().getWidth()
    //                                 - path.getLayoutBounds().getWidth())
    //                                 / 2 );
    //                        } );
    //               } );
    //         plot.heightProperty()
    //               .addListener( (ChangeListener<Number>) ( observable,
    //                  oldValue, newValue ) ->
    //               {
    //                  final double scale = ((Double) newValue)
    //                        / plot.getPrefHeight();
    //                  plot.getChildren().filtered( n -> n instanceof Path )
    //                        .forEach( n ->
    //                        {
    //                           final Path path = (Path) n;
    //                           path.setScaleY( scale );
    //                           path.setTranslateY(
    //                                 (path.getBoundsInParent()
    //                                       .getHeight() * (scale - 1))
    //                                       / 2 );
    //                        } );
    //               } );

    final StackPane layout = new StackPane(lbl, plot);
    layout.setAlignment(Pos.TOP_CENTER);
    layout.setPadding(new Insets(50));
    layout.setStyle("-fx-background-color: rgb(35, 39, 50);");

    final Line vertiCross = new Line();
    vertiCross.setStroke(Color.SILVER);
    vertiCross.setStrokeWidth(1);
    vertiCross.setVisible(false);
    axes.getChildren().add(vertiCross);

    final Tooltip tip = new Tooltip("");
    tip.setAutoHide(false);
    tip.hide();
    axes.setOnMouseExited(ev -> tip.hide());
    axes.setOnMouseMoved(ev -> {
        final Double x = (Double) xAxis.getValueForDisplay(ev.getX());
        if (x > xAxis.getUpperBound() || x < xAxis.getLowerBound()) {
            tip.hide();
            vertiCross.setVisible(false);
            return;
        }
        final Double y = (Double) yAxis.getValueForDisplay(ev.getY());
        if (y > yAxis.getUpperBound() || y < yAxis.getLowerBound()) {
            tip.hide();
            vertiCross.setVisible(false);
            return;
        }
        final double xs = xAxis.getDisplayPosition(x);
        vertiCross.setStartX(xs);
        vertiCross.setStartY(yAxis.getDisplayPosition(0));
        vertiCross.setEndX(xs);
        vertiCross.setEndY(yAxis.getDisplayPosition(yAxis.getUpperBound()));
        vertiCross.setVisible(true);
        final int i = (iDeterministic.firstKey() > x ? iDeterministic.firstEntry()
                : iDeterministic.floorEntry(x)).getValue();
        final Object[] yi = Arrays.stream(deterministic).mapToDouble(p -> getY(p, i))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 1)).toArray();
        final int j = (iStochasticTau.firstKey() > x ? iStochasticTau.firstEntry()
                : iStochasticTau.floorEntry(x)).getValue();
        final Object[] yj = Arrays.stream(stochasticTau).mapToDouble(p -> getY(p, j))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray();
        final int k = (iStochasticRes.firstKey() > x ? iStochasticRes.firstEntry()
                : iStochasticRes.floorEntry(x)).getValue();
        final Object[] yk = Arrays.stream(stochasticRes).mapToDouble(p -> getY(p, k))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray();
        final String txt = String.format("SIR(t=%.1f)\n" + "~det%s\n" + "~tau%s\n" + "~res%s", x,
                Arrays.toString(yi), Arrays.toString(yj), Arrays.toString(yk));

        tip.setText(txt);
        tip.show(axes, ev.getScreenX() - ev.getSceneX() + xs, ev.getScreenY() + 15);
    });

    try {
        stage.getIcons().add(new Image(FileUtil.toInputStream("icon.jpg")));
    } catch (final IOException e) {
        LOG.error("Problem", e);
    }
    stage.setTitle("Deterministic vs. Stochastic");
    stage.setScene(new Scene(layout, Color.rgb(35, 39, 50)));
    //         stage.setOnHidden( ev -> tip.hide() );
    stage.show();
}