Java Code Examples for javafx.scene.control.Tooltip

The following examples show how to use javafx.scene.control.Tooltip. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: constellation   Source File: AttributeNode.java    License: Apache License 2.0 6 votes vote down vote up
public final void setAttribute(Attribute attribute, boolean isKey) {
    if (attribute != this.attribute || this.isKey != isKey) {
        this.attribute = attribute;
        this.isKey = isKey;
        setText(attribute.getName());
        if (isKey) {
            setGraphic(new ImageView(KEY_IMAGE));
        } else if (attribute instanceof NewAttribute) {
            setGraphic(new ImageView(ADD_IMAGE));
        } else {
            setGraphic(null);
        }

        setTooltip(new Tooltip(String.format("%s: %s", attribute.getAttributeType(), attribute.getDescription())));

        deleteMenu.setDisable(!(attribute instanceof NewAttribute));
    }
}
 
Example 2
Source Project: constellation   Source File: DataSourceTitledPane.java    License: Apache License 2.0 6 votes vote down vote up
public DataSourceTitledPane(final DataAccessPlugin plugin, final ImageView dataSourceIcon, final PluginParametersPaneListener top, final Set<String> globalParamLabels) {
    this.plugin = plugin;
    this.top = top;
    this.globalParamLabels = globalParamLabels;

    isLoaded = false;
    enabled = new CheckBox();
    label = new Label(plugin.getName(), dataSourceIcon);

    setGraphic(createTitleBar());
    enabled.setDisable(true);

    final boolean isExpanded = DataAccessPreferences.isExpanded(plugin.getName(), false);

    createParameters(isExpanded, null);

    setPadding(Insets.EMPTY);
    setTooltip(new Tooltip(plugin.getDescription()));
}
 
Example 3
Source Project: phoebus   Source File: RTTimePlot.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** @param enabled <code>true</code> to enable scrolling */
public void setScrolling(final boolean enabled)
{
    //TODO: Fix graphics size to button size
    final ScheduledFuture<?> was_scrolling;
    if (enabled)
    {   // Show that scrolling is 'on', and tool tip explains that it can be turned off
        scroll_img.imageProperty().set(scroll_on);
        scroll.setTooltip(new Tooltip(Messages.Scroll_Off_TT));
        // Scroll once so that end of axis == 'now',
        // because otherwise one of the listeners might right away
        // disable scrolling
        scroll();
        final long scroll_period = scroll_step.toMillis();
        was_scrolling = scrolling.getAndSet(Activator.thread_pool.scheduleAtFixedRate(RTTimePlot.this::scroll, scroll_period, scroll_period, TimeUnit.MILLISECONDS));
    }
    else
    {   // Other way around
        scroll_img.imageProperty().set(scroll_off);
        scroll.setTooltip(new Tooltip(Messages.Scroll_On_TT));
        was_scrolling = scrolling.getAndSet(null);
    }
    if (was_scrolling != null)
        was_scrolling.cancel(false);
}
 
Example 4
Source Project: charts   Source File: StreamChart.java    License: Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    tooltip = new Tooltip();
    tooltip.setAutoHide(true);

    getChildren().setAll(canvas);
}
 
Example 5
Source Project: dolphin-platform   Source File: Utils.java    License: Apache License 2.0 6 votes vote down vote up
public static void registerTooltip(Control node, WithDescription bean) {
    Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(FXWrapper.wrapStringProperty(bean.descriptionProperty()));

    FXWrapper.wrapStringProperty(bean.descriptionProperty()).addListener(e -> {
        if (bean.getDescription() == null || bean.getDescription().isEmpty()) {
            node.setTooltip(null);
        } else {
            node.setTooltip(tooltip);
        }
    });

    if (bean.getDescription() == null || bean.getDescription().isEmpty()) {
        node.setTooltip(null);
    } else {
        node.setTooltip(tooltip);
    }
}
 
Example 6
Source Project: marathonv5   Source File: FXUIUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static ButtonBase _initButtonBase(String name, String toolTip, boolean enabled, String buttonText, ButtonBase button) {
    button.setId(name + "Button");
    button.setTooltip(new Tooltip(toolTip));
    Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
    if (enabledIcon != null) {
        button.setText(null);
        button.setGraphic(enabledIcon);
    }
    if (buttonText != null) {
        button.setText(buttonText);
    } else if (enabledIcon == null) {
        button.setText(name);
    }
    button.setDisable(!enabled);
    button.setMinWidth(Region.USE_PREF_SIZE);
    return button;
}
 
Example 7
Source Project: phoebus   Source File: UndoButtons.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** @param undo_manager {@link UndoableActionManager}
 *  @return Undo and Redo button
 */
public static Button[] createButtons(final UndoableActionManager undo_manager)
{
    final Button undo_btn = new Button();
    undo_btn.setGraphic(ImageCache.getImageView(UndoButtons.class, "/icons/undo.png"));
    undo_btn.setTooltip(new Tooltip(Messages.Undo_TT));
    undo_btn.setDisable(!undo_manager.canUndo());
    undo_btn.setOnAction(event -> undo_manager.undoLast());

    final Button redo_btn = new Button();
    redo_btn.setGraphic(ImageCache.getImageView(UndoButtons.class, "/icons/redo.png"));
    redo_btn.setTooltip(new Tooltip(Messages.Redo_TT));
    redo_btn.setDisable(!undo_manager.canRedo());
    redo_btn.setOnAction(event -> undo_manager.redoLast());

    // Automatically enable/disable based on what's possible
    undo_manager.addListener((to_undo, to_redo) ->
        Platform.runLater(()->
        {
            undo_btn.setDisable(to_undo == null);
            redo_btn.setDisable(to_redo == null);
        })
    );

    return new Button[] { undo_btn, redo_btn };
}
 
Example 8
Source Project: bisq   Source File: GUIUtil.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static void updateConfidence(TransactionConfidence confidence,
                                    Tooltip tooltip,
                                    TxConfidenceIndicator txConfidenceIndicator) {
    if (confidence != null) {
        switch (confidence.getConfidenceType()) {
            case UNKNOWN:
                tooltip.setText(Res.get("confidence.unknown"));
                txConfidenceIndicator.setProgress(0);
                break;
            case PENDING:
                tooltip.setText(Res.get("confidence.seen", confidence.numBroadcastPeers()));
                txConfidenceIndicator.setProgress(-1.0);
                break;
            case BUILDING:
                tooltip.setText(Res.get("confidence.confirmed", confidence.getDepthInBlocks()));
                txConfidenceIndicator.setProgress(Math.min(1, (double) confidence.getDepthInBlocks() / 6.0));
                break;
            case DEAD:
                tooltip.setText(Res.get("confidence.invalid"));
                txConfidenceIndicator.setProgress(0);
                break;
        }

        txConfidenceIndicator.setPrefSize(24, 24);
    }
}
 
Example 9
Source Project: pmd-designer   Source File: ASTTreeCell.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ContextMenu buildContextMenu(Node item) {
    ContextMenu contextMenu = new ContextMenuWithNoArrows();
    CustomMenuItem menuItem = new CustomMenuItem(new Label("Export subtree...",
                                                           new FontIcon("fas-external-link-alt")));

    Tooltip tooltip = new Tooltip("Export subtree to a text format");
    Tooltip.install(menuItem.getContent(), tooltip);

    menuItem.setOnAction(
        e -> getService(DesignerRoot.TREE_EXPORT_WIZARD).apply(x -> x.showYourself(x.bindToNode(item)))
    );

    contextMenu.getItems().add(menuItem);

    return contextMenu;
}
 
Example 10
Source Project: metastone   Source File: HandCard.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setCard(GameContext context, Card card, Player player) {
	super.setCard(context, card, player);
	if (tooltipContent == null) {
		tooltip = new Tooltip();
		tooltipContent = new CardTooltip();
		tooltipContent.setCard(context, card, player);
		tooltip.setGraphic(tooltipContent);
		Tooltip.install(this, tooltip);
	} else {
		tooltipContent.setCard(context, card, player);
	}

	hideCard(player.hideCards());

	if (player.hideCards()) {
		Tooltip.uninstall(this, tooltip);
		tooltipContent = null;
		tooltip = null;
	}
}
 
Example 11
@Override
protected void beforeParentInit() {
    additionalInfoListView.setPlaceholder(new Label("No additional info"));

    Val<Node> currentSelection = initNodeSelectionHandling(getDesignerRoot(), EventStreams.never(), false);

    // pin to see updates
    currentSelection.pin();

    hideCommonAttributesProperty()
        .values()
        .distinct()
        .subscribe(show -> setFocusNode(currentSelection.getValue(), new DataHolder()));


    attrValueColumn.setCellValueFactory(param -> Val.constant(DesignerUtil.attrToXpathString(param.getValue())));
    attrNameColumn.setCellValueFactory(param -> Val.constant("@" + param.getValue().getName()));
    attrNameColumn.setCellFactory(col -> new AttributeNameTableCell());

    Label valueColGraphic = new Label("Value");
    valueColGraphic.setTooltip(new Tooltip("This is the XPath 2.0 representation"));
    attrValueColumn.setGraphic(valueColGraphic);
}
 
Example 12
Source Project: arma-dialog-creator   Source File: FXUtil.java    License: MIT License 6 votes vote down vote up
/**
 As of Java 8, setting the tooltip show delay isn't possible. Until an official implementation, this is one way to configure the tooltip show delay

 @param tooltip tooltip to change delay of
 @param delayMillis milliseconds before the tooltip can appear
 */
public static void hackTooltipStartTiming(Tooltip tooltip, double delayMillis) {
	try {
		Field fieldBehavior = tooltip.getClass().getDeclaredField("BEHAVIOR");
		fieldBehavior.setAccessible(true);
		Object objBehavior = fieldBehavior.get(tooltip);

		Field fieldTimer = objBehavior.getClass().getDeclaredField("activationTimer");
		fieldTimer.setAccessible(true);
		Timeline objTimer = (Timeline) fieldTimer.get(objBehavior);

		objTimer.getKeyFrames().clear();
		objTimer.getKeyFrames().add(new KeyFrame(new Duration(delayMillis)));
	} catch (Exception e) {
		e.printStackTrace(System.out);
	}
}
 
Example 13
Source Project: ccu-historian   Source File: ChartCanvas.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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.
 * 
 * @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;
    }
}
 
Example 14
Source Project: latexdraw   Source File: UndoRedoManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initialize(final URL location, final ResourceBundle resources) {
	setActivated(true);

	undoB.setDisable(true);
	redoB.setDisable(true);

	addDisposable(UndoCollector.getInstance().redos().subscribe(redoable -> {
		redoB.setDisable(redoable.isEmpty());
		redoB.setTooltip(redoable.map(u -> new Tooltip(u.getUndoName(lang))).orElse(null));
	}));
	addDisposable(UndoCollector.getInstance().undos().subscribe(undoable -> {
		undoB.setDisable(undoable.isEmpty());
		undoB.setTooltip(undoable.map(u -> new Tooltip(u.getUndoName(lang))).orElse(null));
	}));
}
 
Example 15
Source Project: phoebus   Source File: DockItemWithInput.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** Set input
 *
 *  <p>Registers the input to be persisted and restored.
 *  The tab tooltip indicates complete input,
 *  while tab label will be set to basic name (sans path and extension).
 *  For custom name, call <code>setLabel</code> after updating input
 *  in <code>Platform.runLater()</code>
 *
 *  @param input Input
 *  @see DockItemWithInput#setLabel(String)
 */
public void setInput(final URI input)
{
    this.input = input;
    final String name = input == null ? null : extract_name(input.getPath());

    // Tooltip update must be on UI thread
    Platform.runLater(() ->
    {
        if (input == null)
            name_tab.setTooltip(new Tooltip(Messages.DockNotSaved));
        else
        {
            name_tab.setTooltip(new Tooltip(input.toString()));
            setLabel(name);
        }
    });
}
 
Example 16
Source Project: latexdraw   Source File: ViewText.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void updateImageText(final Tuple<Image, String> values) {
	if(currentCompilation != null && currentCompilation.isDone()) {
		currentCompilation = null;
	}

	compiledText.setUserData(values.b);

	// A text will be used to render the text shape.
	if(values.a == null) {
		compileTooltip.setText(SystemUtils.getInstance().getLatexErrorMessageFromLog(values.b));
		Tooltip.install(text, compileTooltip);
		setImageTextEnable(false);
		compiledText.setImage(null);
	}else {
		// An image will be used to render the text shape.
		compileTooltip.setText(null);
		Tooltip.uninstall(text, compileTooltip);
		compiledText.setImage(values.a);
		setImageTextEnable(true);
		updateTranslationCompiledText();

		getCanvasParent().ifPresent(canvas -> canvas.update());
	}
}
 
Example 17
Source Project: MyBox   Source File: ImageManufactureBatchController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initTargetSection() {
    super.initTargetSection();

    fileTypeGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override
        public void changed(ObservableValue<? extends Toggle> ov,
                Toggle old_toggle, Toggle new_toggle) {
            checkFileType();
        }
    });
    checkFileType();
    if (pcxRadio != null) {
        FxmlControl.setTooltip(pcxRadio, new Tooltip(message("PcxComments")));
    }

    browseButton.setDisable(true);
}
 
Example 18
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 19
Source Project: jmonkeybuilder   Source File: ResourceTreeCell.java    License: Apache License 2.0 5 votes vote down vote up
protected ResourceTreeCell() {
    setOnMouseClicked(this::handleMouseClickedEvent);
    setOnDragDetected(this::handleStartDragEvent);
    setOnDragDone(this::handleStopDragEvent);
    this.icon = new ImageView();
    this.tooltip = new Tooltip();
}
 
Example 20
Source Project: HubTurbo   Source File: PanelMenuBar.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private HBox createCloseButton() {
    HBox closeArea = new HBox();
    closeButton = new Label(OCTICON_CLOSE_PANEL);
    closeButton.setId(IdGenerator.getPanelCloseButtonId(panel.panelIndex));
    closeButton.getStyleClass().addAll("octicon", "label-button");
    closeButton.setOnMouseClicked((e) -> {
        e.consume();
        panel.parentPanelControl.closePanel(panel.panelIndex);
    });
    Tooltip.install(closeArea, new Tooltip("Close this panel"));

    closeArea.getChildren().add(closeButton);

    return closeArea;
}
 
Example 21
Source Project: bisq   Source File: ClosedTradesView.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void setTradeIdColumnCellFactory() {
    tradeIdColumn.getStyleClass().add("first-column");
    tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    tradeIdColumn.setCellFactory(
            new Callback<>() {

                @Override
                public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(TableColumn<ClosedTradableListItem,
                        ClosedTradableListItem> column) {
                    return new TableCell<>() {
                        private HyperlinkWithIcon field;

                        @Override
                        public void updateItem(final ClosedTradableListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty) {
                                field = new HyperlinkWithIcon(model.getTradeId(item));
                                field.setOnAction(event -> {
                                    Tradable tradable = item.getTradable();
                                    if (tradable instanceof Trade)
                                        tradeDetailsWindow.show((Trade) tradable);
                                    else if (tradable instanceof OpenOffer)
                                        offerDetailsWindow.show(tradable.getOffer());
                                });
                                field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
                                setGraphic(field);
                            } else {
                                setGraphic(null);
                                if (field != null)
                                    field.setOnAction(null);
                            }
                        }
                    };
                }
            });
}
 
Example 22
Source Project: Quelea   Source File: BasicSongPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a title button
 *
 * @param fileName  Image file name
 * @param label     Tooltip label
 * @param titleName Title name to be inserted
 * @return the title button
 */
private Button getTitleButton(String fileName, String label, String titleName) {
    if (darkTheme)
        fileName = fileName.replace(".png", "-light.png");
    Button ret = new Button("", new ImageView(new Image("file:icons/" + fileName, 24, 24, false, true)));
    Utils.setToolbarButtonStyle(ret);
    ret.setTooltip(new Tooltip(LabelGrabber.INSTANCE.getLabel(label)));
    ret.setOnAction((event) -> {
        insertTitle(titleName, "");
    });
    getLyricsField().requestFocus();
    return ret;
}
 
Example 23
Source Project: ShootOFF   Source File: ExerciseSlide.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void registerExercise(TrainingExercise exercise) {
	final Tooltip t = new Tooltip(exercise.getInfo().getDescription());
	t.setPrefWidth(500);
	t.setWrapText(true);
	exerciseItemPane.addButton(exercise, exercise.getInfo().getName(), Optional.empty(), Optional.of(t));
}
 
Example 24
/**
 * Refreshes the shown scripts.
 * When this method is called it begins by clearing the <code>scriptGrid</code>.
 * Afterwards this method refills it.
 */
private void updateScripts(final GridPane scriptGrid) {
    scriptGrid.getChildren().clear();

    for (int i = 0; i < filteredScripts.size(); i++) {
        ScriptDTO script = filteredScripts.get(i);

        final Label scriptName = new Label(script.getScriptName());
        GridPane.setHgrow(scriptName, Priority.ALWAYS);

        if (getControl().isShowScriptSource()) {
            final Tooltip tooltip = new Tooltip(tr("Source: {0}", script.getScriptSource()));
            Tooltip.install(scriptName, tooltip);
        }

        final Button installButton = new Button(tr("Install"));
        installButton.setOnMouseClicked(evt -> {
            try {
                installScript(script);
            } catch (IllegalArgumentException e) {
                final ErrorDialog errorDialog = ErrorDialog.builder()
                        .withMessage(tr("Error while trying to download the installer"))
                        .withException(e)
                        .build();

                errorDialog.showAndWait();
            }
        });

        scriptGrid.addRow(i, scriptName, installButton);
    }
}
 
Example 25
Source Project: mars-sim   Source File: ChatBoxTimed.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    final Clock clock = new Clock(Duration.seconds(1), true);
    
    final BorderPane root = new BorderPane();
    final HBox controls = new HBox(5);
    controls.setAlignment(Pos.CENTER);
    controls.setPadding(new Insets(10));
    
    final TextField itemField = new TextField();
    itemField.setTooltip(new Tooltip("Type an item and press Enter"));
    controls.getChildren().add(itemField);
    
    final VBox items = new VBox(5);
    
    itemField.setOnAction(event -> {
        String text = itemField.getText();
        Label label = new Label();
        label.textProperty().bind(Bindings.format("%s (%s)", text, clock.getElapsedStringBinding()));
        items.getChildren().add(label);
        itemField.setText("");
    });
    
    final ScrollPane scroller = new ScrollPane();
    scroller.setContent(items);
    
    final Label currentTimeLabel = new Label();
    currentTimeLabel.textProperty().bind(Bindings.format("Current time: %s", clock.getTimeStringBinding()));
    
    root.setTop(controls);
    root.setCenter(scroller);
    root.setBottom(currentTimeLabel);
    
    Scene scene = new Scene(root, 600, 400);
    
    primaryStage.setTitle("Timed item display");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 26
public BrowseFileButton() {
	setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.FILE_ALT, "1.2em"));
	setTooltip(new Tooltip(Messages.get("BrowseFileButton.tooltip")));
	setOnAction(this::browse);

	disableProperty().bind(basePath.isNull());

	// workaround for a JavaFX bug:
	//   avoid closing the dialog that contains this control when the user
	//   closes the FileChooser or DirectoryChooser using the ESC key
	addEventHandler(KeyEvent.KEY_RELEASED, e-> {
		if (e.getCode() == KeyCode.ESCAPE)
			e.consume();
	});
}
 
Example 27
Source Project: bisq   Source File: LockedView.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void setAddressColumnCellFactory() {
    addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));

    addressColumn.setCellFactory(
            new Callback<>() {

                @Override
                public TableCell<LockedListItem, LockedListItem> call(TableColumn<LockedListItem,
                        LockedListItem> column) {
                    return new TableCell<>() {
                        private HyperlinkWithIcon hyperlinkWithIcon;

                        @Override
                        public void updateItem(final LockedListItem item, boolean empty) {
                            super.updateItem(item, empty);

                            if (item != null && !empty) {
                                String address = item.getAddressString();
                                hyperlinkWithIcon = new ExternalHyperlink(address);
                                hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
                                hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
                                setGraphic(hyperlinkWithIcon);
                            } else {
                                setGraphic(null);
                                if (hyperlinkWithIcon != null)
                                    hyperlinkWithIcon.setOnAction(null);
                            }
                        }
                    };
                }
            });
}
 
Example 28
Source Project: Medusa   Source File: LevelSkin.java    License: Apache License 2.0 5 votes vote down vote up
public LevelSkin(Gauge gauge) {
    super(gauge);
    locale               = gauge.getLocale();
    sections             = gauge.getSections();
    barTooltip           = new Tooltip();
    formatString         = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f%%").toString();
    currentValueListener = o -> setBar(gauge.getCurrentValue());
    barTooltip.setTextAlignment(TextAlignment.CENTER);

    initGraphics();
    registerListeners();
}
 
Example 29
Source Project: worldfx   Source File: World.java    License: Apache License 2.0 5 votes vote down vote up
public void addLocation(final Location LOCATION) {
    double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X;
    double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y;

    FontIcon locationIcon = new FontIcon(null == LOCATION.getIconCode() ? locationIconCode : LOCATION.getIconCode());
    locationIcon.setIconSize(LOCATION.getIconSize());
    locationIcon.setTextOrigin(VPos.CENTER);
    locationIcon.setIconColor(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor());
    locationIcon.setX(x - LOCATION.getIconSize() * 0.5);
    locationIcon.setY(y);

    StringBuilder tooltipBuilder = new StringBuilder();
    if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName());
    if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo());
    String tooltipText = tooltipBuilder.toString();
    if (!tooltipText.isEmpty()) {
        Tooltip tooltip = new Tooltip(tooltipText);
        tooltip.setFont(Font.font(10));
        Tooltip.install(locationIcon, tooltip);
    }

    if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler()));
    if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler()));
    if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler()));
    if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler()));

    locations.put(LOCATION, locationIcon);
}
 
Example 30
Source Project: latexdraw   Source File: ViewText.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the view.
 * @param sh The model.
 */
ViewText(final Text sh, final LaTeXDataService data) {
	super(sh);
	text = new javafx.scene.text.Text();
	compiledText = new ImageView();
	compileTooltip = new Tooltip(null);
	this.latexData = data;

	// Scaling at 0.5 as the png produced by latex is zoomed x 2 (for a better rendering)
	compiledText.setScaleX(0.5);
	compiledText.setScaleY(0.5);
	compiledText.setVisible(false);
	compiledText.setSmooth(true);
	compiledText.setCache(true);
	compiledText.imageProperty().addListener((observable, oldValue, theImg) -> {
		if(theImg != null) {
			// Have to move the picture as it is zoomed
			compiledText.setX(-theImg.getWidth() / 4d);
			compiledText.setY(-(3d * theImg.getHeight()) / 4d);
		}
	});

	textUpdate = (observable, oldValue, newValue) -> update();
	model.textProperty().addListener(textUpdate);

	getChildren().add(text);
	getChildren().add(compiledText);
	setImageTextEnable(false);
	update();
	bindTextPosition();
}