Example usage for javafx.scene.control Tooltip install

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

Introduction

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

Prototype

public static void install(Node node, Tooltip t) 

Source Link

Document

Associates the given Tooltip with the given Node .

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Tooltip Sample");
    stage.setWidth(300);//ww  w  .  java 2 s  .  c  o  m
    stage.setHeight(150);

    Rectangle rect = new Rectangle(0, 0, 100, 100);
    Tooltip t = new Tooltip("A Square");
    Tooltip.install(rect, t);

    ((Group) scene.getRoot()).getChildren().add(rect);

    stage.setScene(scene);
    stage.show();
}

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
 *//*from w  ww. j  a va  2 s  . c  o  m*/
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: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 a2  s  . c o m
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.ConceptNode.java

/**
 * descriptionReader is optional/* w w  w  .j  a  v  a  2 s .  co m*/
 */
public ConceptNode(ConceptVersionBI initialConcept, boolean flagAsInvalidWhenBlank,
        ObservableList<SimpleDisplayConcept> dropDownOptions,
        Function<ConceptVersionBI, String> descriptionReader) {
    c_ = initialConcept;
    //We can't simply use the ObservableList from the CommonlyUsedConcepts, because it infinite loops - there doesn't seem to be a way 
    //to change the items in the drop down without changing the selection.  So, we have this hack instead.
    listChangeListener_ = new ListChangeListener<SimpleDisplayConcept>() {
        @Override
        public void onChanged(Change<? extends SimpleDisplayConcept> c) {
            //TODO I still have an infinite loop here.  Find and fix.
            logger.debug("updating concept dropdown");
            disableChangeListener_ = true;
            SimpleDisplayConcept temp = cb_.getValue();
            cb_.setItems(FXCollections.observableArrayList(dropDownOptions_));
            cb_.setValue(temp);
            cb_.getSelectionModel().select(temp);
            disableChangeListener_ = false;
        }
    };
    descriptionReader_ = (descriptionReader == null ? (conceptVersion) -> {
        return conceptVersion == null ? "" : OTFUtility.getDescription(conceptVersion);
    } : descriptionReader);
    dropDownOptions_ = dropDownOptions == null
            ? AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts()
            : dropDownOptions;
    dropDownOptions_.addListener(new WeakListChangeListener<SimpleDisplayConcept>(listChangeListener_));
    conceptBinding_ = new ObjectBinding<ConceptVersionBI>() {
        @Override
        protected ConceptVersionBI computeValue() {
            return c_;
        }
    };

    flagAsInvalidWhenBlank_ = flagAsInvalidWhenBlank;
    cb_ = new ComboBox<>();
    cb_.setConverter(new StringConverter<SimpleDisplayConcept>() {
        @Override
        public String toString(SimpleDisplayConcept object) {
            return object == null ? "" : object.getDescription();
        }

        @Override
        public SimpleDisplayConcept fromString(String string) {
            return new SimpleDisplayConcept(string, 0);
        }
    });
    cb_.setValue(new SimpleDisplayConcept("", 0));
    cb_.setEditable(true);
    cb_.setMaxWidth(Double.MAX_VALUE);
    cb_.setPrefWidth(ComboBox.USE_COMPUTED_SIZE);
    cb_.setMinWidth(200.0);
    cb_.setPromptText("Type, drop or select a concept");

    cb_.setItems(FXCollections.observableArrayList(dropDownOptions_));
    cb_.setVisibleRowCount(11);

    cm_ = new ContextMenu();

    MenuItem copyText = new MenuItem("Copy Description");
    copyText.setGraphic(Images.COPY.createImageView());
    copyText.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            CustomClipboard.set(cb_.getEditor().getText());
        }
    });
    cm_.getItems().add(copyText);

    CommonMenusNIdProvider nidProvider = new CommonMenusNIdProvider() {
        @Override
        public Set<Integer> getNIds() {
            Set<Integer> nids = new HashSet<>();
            if (c_ != null) {
                nids.add(c_.getNid());
            }
            return nids;
        }
    };
    CommonMenuBuilderI menuBuilder = CommonMenus.CommonMenuBuilder.newInstance();
    menuBuilder.setInvisibleWhenFalse(isValid);
    CommonMenus.addCommonMenus(cm_, menuBuilder, nidProvider);

    cb_.getEditor().setContextMenu(cm_);

    updateGUI();

    new LookAheadConceptPopup(cb_);

    if (cb_.getValue().getNid() == 0) {
        if (flagAsInvalidWhenBlank_) {
            isValid.setInvalid("Concept Required");
        }
    } else {
        isValid.setValid();
    }

    cb_.valueProperty().addListener(new ChangeListener<SimpleDisplayConcept>() {
        @Override
        public void changed(ObservableValue<? extends SimpleDisplayConcept> observable,
                SimpleDisplayConcept oldValue, SimpleDisplayConcept newValue) {
            if (newValue == null) {
                logger.debug("Combo Value Changed - null entry");
            } else {
                logger.debug("Combo Value Changed: {} {}", newValue.getDescription(), newValue.getNid());
            }

            if (disableChangeListener_) {
                logger.debug("change listener disabled");
                return;
            }

            if (newValue == null) {
                //This can happen if someone calls clearSelection() - it passes in a null.
                cb_.setValue(new SimpleDisplayConcept("", 0));
                return;
            } else {
                if (newValue.shouldIgnoreChange()) {
                    logger.debug("One time change ignore");
                    return;
                }
                //Whenever the focus leaves the combo box editor, a new combo box is generated.  But, the new box will have 0 for an id.  detect and ignore
                if (oldValue != null && oldValue.getDescription().equals(newValue.getDescription())
                        && newValue.getNid() == 0) {
                    logger.debug("Not a real change, ignore");
                    newValue.setNid(oldValue.getNid());
                    return;
                }
                lookup();
            }
        }
    });

    AppContext.getService(DragRegistry.class).setupDragAndDrop(cb_, new SingleConceptIdProvider() {
        @Override
        public String getConceptId() {
            return cb_.getValue().getNid() + "";
        }
    }, true);

    pi_ = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS);
    pi_.visibleProperty().bind(isLookupInProgress_);
    pi_.setPrefHeight(16.0);
    pi_.setPrefWidth(16.0);
    pi_.setMaxWidth(16.0);
    pi_.setMaxHeight(16.0);

    lookupFailImage_ = Images.EXCLAMATION.createImageView();
    lookupFailImage_.visibleProperty().bind(isValid.not().and(isLookupInProgress_.not()));
    Tooltip t = new Tooltip();
    t.textProperty().bind(isValid.getReasonWhyInvalid());
    Tooltip.install(lookupFailImage_, t);

    StackPane sp = new StackPane();
    sp.setMaxWidth(Double.MAX_VALUE);
    sp.getChildren().add(cb_);
    sp.getChildren().add(lookupFailImage_);
    sp.getChildren().add(pi_);
    StackPane.setAlignment(cb_, Pos.CENTER_LEFT);
    StackPane.setAlignment(lookupFailImage_, Pos.CENTER_RIGHT);
    StackPane.setMargin(lookupFailImage_, new Insets(0.0, 30.0, 0.0, 0.0));
    StackPane.setAlignment(pi_, Pos.CENTER_RIGHT);
    StackPane.setMargin(pi_, new Insets(0.0, 30.0, 0.0, 0.0));

    hbox_ = new HBox();
    hbox_.setSpacing(5.0);
    hbox_.setAlignment(Pos.CENTER_LEFT);

    hbox_.getChildren().add(sp);
    HBox.setHgrow(sp, Priority.SOMETIMES);
}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartCanvas.java

/**
 * Sets the tooltip text, with the (x, y) location being used for the
 * anchor.  If the text is {@code null}, no tooltip will be displayed.
 * This method is intended for calling by the {@link TooltipHandlerFX}
 * class, you won't normally call it directly.
 * //w w  w  . j a v a 2s .c  om
 * @param text  the text ({@code null} permitted).
 * @param x  the x-coordinate of the mouse pointer.
 * @param y  the y-coordinate of the mouse pointer.
 */
public void setTooltip(String text, double x, double y) {
    if (text != null) {
        if (this.tooltip == null) {
            this.tooltip = new Tooltip(text);
            Tooltip.install(this, this.tooltip);
        } else {
            this.tooltip.setText(text);
            this.tooltip.setAnchorX(x);
            this.tooltip.setAnchorY(y);
        }
    } else {
        Tooltip.uninstall(this, this.tooltip);
        this.tooltip = null;
    }
}

From source file:ambroafb.general.AnnotiationUtils.java

private static void changeNodeTitleLabelVisual(Node node, String explain) {
    Parent parent = node.getParent();//from   w w  w  .j  ava2s .c  o m
    Label nodeTitleLabel = (Label) parent.lookup(".validationMessage");

    if (explain.isEmpty()) {
        if (default_colors_map.containsKey(nodeTitleLabel)) {// This order of 'if' statements is correct!
            nodeTitleLabel.setTextFill(default_colors_map.get(nodeTitleLabel));
            default_colors_map.remove(nodeTitleLabel);
            Tooltip.uninstall(nodeTitleLabel, toolTip);
        }
    } else {
        node.requestFocus();
        toolTip.setText(GeneralConfig.getInstance().getTitleFor(explain));
        toolTip.setStyle("-fx-background-color: gray; -fx-font-size: 8pt;");
        Tooltip.install(nodeTitleLabel, toolTip);
        default_colors_map.putIfAbsent(nodeTitleLabel, nodeTitleLabel.getTextFill());
        nodeTitleLabel.setTextFill(Color.RED);
    }
}

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 www.  j a  v  a2  s. c om*/
        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);
        }/*from  w ww.j  av  a2s.c  om*/
        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:editeurpanovisu.EditeurPanovisu.java

private AnchorPane afficherListePanosVignettes(int numHS) {

    AnchorPane aplistePano = new AnchorPane();
    aplistePano.setOpacity(1);/*w w  w .j  a va 2  s  . c  o  m*/
    Pane fond = new Pane();
    fond.setStyle("-fx-background-color : #bbb;");
    fond.setPrefWidth(540);
    fond.setPrefHeight(((nombrePanoramiques - 2) / 4 + 1) * 65 + 10);
    fond.setMinWidth(540);
    fond.setMinHeight(70);
    aplistePano.getChildren().add(fond);
    aplistePano.setStyle("-fx-backgroung-color : #bbb;");
    int j = 0;
    ImageView[] IVPano;
    IVPano = new ImageView[nombrePanoramiques];
    double xPos;
    double yPos;
    int row = 0;
    for (int i = 0; i < nombrePanoramiques; i++) {
        int numeroPano = i;
        IVPano[j] = new ImageView(panoramiquesProjet[i].getVignettePanoramique());
        IVPano[j].setFitWidth(120);
        IVPano[j].setFitHeight(60);
        IVPano[j].setSmooth(true);
        String nomPano = panoramiquesProjet[i].getNomFichier();
        int col = j % 4;
        row = j / 4;
        xPos = col * 130 + 25;
        yPos = row * 65 + 5;
        IVPano[j].setLayoutX(xPos);
        IVPano[j].setLayoutY(yPos);
        IVPano[j].setCursor(Cursor.HAND);
        IVPano[j].setStyle("-fx-background-color : #ccc;");
        Tooltip t = new Tooltip(
                nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")));
        t.setStyle(tooltipStyle);
        Tooltip.install(IVPano[j], t);
        IVPano[j].setOnMouseClicked((MouseEvent me) -> {
            pano.setCursor(Cursor.CROSSHAIR);
            pano.setOnMouseClicked((MouseEvent me1) -> {
                gereSourisPanoramique(me1);
            });
            panoListeVignette = nomPano;
            if (panoramiquesProjet[numeroPano].getTitrePanoramique() != null) {
                String texteHS = panoramiquesProjet[numeroPano].getTitrePanoramique();
                TextArea txtHS = (TextArea) outils.lookup("#txtHS" + numHS);
                txtHS.setText(texteHS);
            }
            panoramiquesProjet[panoActuel].getHotspot(numHS).setNumeroPano(numeroPano);
            ComboBox cbx = (ComboBox) outils.lookup("#cbpano" + numHS);
            cbx.setValue(nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")));
            aplistePano.setVisible(false);
            me.consume();
        });
        aplistePano.getChildren().add(IVPano[j]);
        j++;

    }
    int taille = (row + 1) * 65 + 5;
    aplistePano.setPrefWidth(540);
    aplistePano.setPrefHeight(taille);
    aplistePano.setMinWidth(540);
    aplistePano.setMinHeight(taille);
    ImageView IVClose = new ImageView(
            new Image("file:" + repertAppli + File.separator + "images/ferme.png", 20, 20, true, true));
    IVClose.setLayoutX(2);
    IVClose.setLayoutY(5);
    IVClose.setCursor(Cursor.HAND);
    aplistePano.getChildren().add(IVClose);
    IVClose.setOnMouseClicked((MouseEvent me) -> {
        pano.setCursor(Cursor.CROSSHAIR);
        pano.setOnMouseClicked((MouseEvent me1) -> {
            gereSourisPanoramique(me1);
        });

        panoListeVignette = "";
        aplistePano.setVisible(false);
        me.consume();
    });
    aplistePano.setTranslateZ(2);
    return aplistePano;
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param i/*from   w  ww.  j a va2s  .  c o  m*/
 * @param longitude
 * @param latitude
 */
private void afficheHS(int i, double longitude, double latitude) {
    double largeur = imagePanoramique.getFitWidth();
    double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX();
    double Y = (90.0d - latitude) * largeur / 360.0d;
    Circle point = new Circle(X, Y, 5);
    point.setFill(Color.YELLOW);
    point.setStroke(Color.RED);
    point.setId("point" + i);
    point.setCursor(Cursor.DEFAULT);
    pano.getChildren().add(point);

    Tooltip t = new Tooltip("point n " + (i + 1));
    t.setStyle(tooltipStyle);
    Tooltip.install(point, t);
    point.setOnDragDetected((MouseEvent me1) -> {
        point.setFill(Color.RED);
        point.setStroke(Color.YELLOW);
        dragDrop = true;
        me1.consume();

    });
    point.setOnMouseDragged((MouseEvent me1) -> {
        double XX = me1.getX() - imagePanoramique.getLayoutX();
        if (XX < 0) {
            XX = 0;
        }
        if (XX > imagePanoramique.getFitWidth()) {
            XX = imagePanoramique.getFitWidth();
        }
        point.setCenterX(XX + imagePanoramique.getLayoutX());
        double YY = me1.getY();
        if (YY < 0) {
            YY = 0;
        }
        if (YY > imagePanoramique.getFitHeight()) {
            YY = imagePanoramique.getFitHeight();
        }
        point.setCenterY(YY);
        me1.consume();

    });
    point.setOnMouseReleased((MouseEvent me1) -> {
        String chPoint = point.getId();
        chPoint = chPoint.substring(5, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        double X1 = me1.getSceneX();
        double Y1 = me1.getSceneY();
        double mouseX = X1 - imagePanoramique.getLayoutX();
        if (mouseX < 0) {
            mouseX = 0;
        }
        if (mouseX > imagePanoramique.getFitWidth()) {
            mouseX = imagePanoramique.getFitWidth();
        }

        double mouseY = Y1 - pano.getLayoutY() - 109;
        if (mouseY < 0) {
            mouseY = 0;
        }
        if (mouseY > imagePanoramique.getFitHeight()) {
            mouseY = imagePanoramique.getFitHeight();
        }

        double longit, lat;
        double larg = imagePanoramique.getFitWidth();
        String chLong, chLat;
        longit = 360.0f * mouseX / larg - 180;
        lat = 90.0d - 2.0f * mouseY / larg * 180.0f;
        panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLatitude(lat);
        panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLongitude(longit);
        point.setFill(Color.YELLOW);
        point.setStroke(Color.RED);
        me1.consume();

    });

    point.setOnMouseClicked((MouseEvent me1) -> {
        double mouseX = me1.getSceneX() - imagePanoramique.getLayoutX();
        if (mouseX < 0) {
            mouseX = 0;
        }
        if (mouseX > imagePanoramique.getFitWidth()) {
            mouseX = imagePanoramique.getFitWidth();
        }

        double mouseY = me1.getSceneY() - pano.getLayoutY() - 115;
        if (mouseY < 0) {
            mouseY = 0;
        }
        if (mouseY > imagePanoramique.getFitHeight()) {
            mouseY = imagePanoramique.getFitHeight();
        }

        String chPoint = point.getId();
        chPoint = chPoint.substring(5, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        Node pt;
        pt = (Node) pano.lookup("#point" + chPoint);

        if (me1.isControlDown()) {
            dejaSauve = false;
            stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
            pano.getChildren().remove(pt);

            for (int o = numeroPoint + 1; o < numPoints; o++) {
                pt = (Node) pano.lookup("#point" + Integer.toString(o));
                pt.setId("point" + Integer.toString(o - 1));
            }
            /**
             * on retire les anciennes indication de HS
             */
            retireAffichageHotSpots();
            numPoints--;
            panoramiquesProjet[panoActuel].removeHotspot(numeroPoint);
            /**
             * On les cre les nouvelles
             */
            ajouteAffichageHotspots();
            me1.consume();
            valideHS();
        } else {
            if (!dragDrop) {
                if (nombrePanoramiques > 1) {
                    AnchorPane listePanoVig = afficherListePanosVignettes(numeroPoint);
                    int largeurVignettes = 4;
                    if (nombrePanoramiques < 4) {
                        largeurVignettes = nombrePanoramiques;
                    }
                    if (mouseX + largeurVignettes * 130 > pano.getWidth()) {
                        listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130);
                    } else {
                        listePanoVig.setLayoutX(mouseX);
                    }
                    listePanoVig.setLayoutY(mouseY);
                    pano.getChildren().add(listePanoVig);
                }
            } else {
                dragDrop = false;
            }
            valideHS();
            me1.consume();

        }

    });
}