Java Code Examples for javafx.geometry.HPos#RIGHT
The following examples show how to use
javafx.geometry.HPos#RIGHT .
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 File: AbstractValueIndicator.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Layouts the label within specified bounds and given horizontal and vertical position, taking into account * {@link #labelHorizontalAnchorProperty() horizontal} and {@link #labelVerticalAnchorProperty() vertical} anchor. * * @param bounds the bounding rectangle with respect to which the label should be positioned * @param hPos relative [0, 1] horizontal position of the label within the bounds * @param vPos relative [0, 1] vertical position of the label within the bounds */ protected final void layoutLabel(final Bounds bounds, final double hPos, final double vPos) { if (label.getText() == null || label.getText().isEmpty()) { getChartChildren().remove(label); return; } double xPos = bounds.getMinX(); double yPos = bounds.getMinY(); xOffset = bounds.getWidth() * hPos; yOffset = bounds.getHeight() * (1 - vPos); final double width = label.prefWidth(-1); final double height = label.prefHeight(width); if (getLabelHorizontalAnchor() == HPos.CENTER) { xOffset -= width / 2; } else if (getLabelHorizontalAnchor() == HPos.RIGHT) { xOffset -= width; } if (getLabelVerticalAnchor() == VPos.CENTER) { yOffset -= height / 2; } else if (getLabelVerticalAnchor() == VPos.BASELINE) { yOffset -= label.getBaselineOffset(); } else if (getLabelVerticalAnchor() == VPos.BOTTOM) { yOffset -= height; } label.resizeRelocate(xPos + xOffset, yPos + yOffset, width, height); addChildNodeIfNotPresent(label); }
Example 2
Source File: Toast.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
public void show(Node anchor, Side side, double offsetX, double offsetY) { if (anchor == null) { return; } autoCenter = false; HPos hpos = side == Side.LEFT ? HPos.LEFT : side == Side.RIGHT ? HPos.RIGHT : HPos.CENTER; VPos vpos = side == Side.TOP ? VPos.TOP : side == Side.BOTTOM ? VPos.BOTTOM : VPos.CENTER; // translate from anchor/hpos/vpos/offsetX/offsetY into screenX/screenY Point2D point = Utils.pointRelativeTo(anchor, content.prefWidth(-1), content.prefHeight(-1), hpos, vpos, offsetX, offsetY, true); this.show(anchor, point.getX(), point.getY()); }
Example 3
Source File: EditView.java From helloiot with GNU General Public License v3.0 | 5 votes |
public void setDevice(DeviceSubscribe device) { this.device = device; if (Strings.isNullOrEmpty(getLabel())) { setLabel(device.getProperties().getProperty("label")); } if (device.getFormat().alignment().getHpos() == HPos.RIGHT) { statusview.getStyleClass().add("textinput-right"); } else { statusview.getStyleClass().remove("textinput-right"); } }
Example 4
Source File: EditEvent.java From helloiot with GNU General Public License v3.0 | 5 votes |
public void setDevice(TransmitterSimple device) { this.device = device; if (Strings.isNullOrEmpty(getLabel())) { setLabel(device.getProperties().getProperty("label")); } if (device.getFormat().alignment().getHpos() == HPos.RIGHT) { payload.getStyleClass().add("textinput-right"); } else { payload.getStyleClass().remove("textinput-right"); } }
Example 5
Source File: EditStatus.java From helloiot with GNU General Public License v3.0 | 5 votes |
public void setDevice(DeviceSimple device) { this.device = device; if (Strings.isNullOrEmpty(getLabel())) { setLabel(device.getProperties().getProperty("label")); } if (device.getFormat().alignment().getHpos() == HPos.RIGHT) { statusview.getStyleClass().add("textinput-right"); statusedit.getStyleClass().add("textinput-right"); } else { statusview.getStyleClass().remove("textinput-right"); statusedit.getStyleClass().remove("textinput-right"); } }
Example 6
Source File: LogView.java From helloiot with GNU General Public License v3.0 | 5 votes |
public void setDevice(DeviceSubscribe device) { this.device = device; if (Strings.isNullOrEmpty(getLabel())) { setLabel(device.getProperties().getProperty("label")); } if (device.getFormat().alignment().getHpos() == HPos.RIGHT) { statusview.getStyleClass().add("textinput-right"); } else { statusview.getStyleClass().remove("textinput-right"); } }
Example 7
Source File: Overlay.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
protected void addButtons() { if (!hideCloseButton) { closeButton = new AutoTooltipButton(closeButtonText == null ? Res.get("shared.close") : closeButtonText); closeButton.getStyleClass().add("compact-button"); closeButton.setOnAction(event -> doClose()); closeButton.setMinWidth(70); HBox.setHgrow(closeButton, Priority.SOMETIMES); } Pane spacer = new Pane(); if (buttonAlignment == HPos.RIGHT) { HBox.setHgrow(spacer, Priority.ALWAYS); spacer.setMaxWidth(Double.MAX_VALUE); } buttonBox = new HBox(); GridPane.setHalignment(buttonBox, buttonAlignment); GridPane.setRowIndex(buttonBox, ++rowIndex); GridPane.setColumnSpan(buttonBox, 2); GridPane.setMargin(buttonBox, new Insets(buttonDistance, 0, 0, 0)); gridPane.getChildren().add(buttonBox); if (actionHandlerOptional.isPresent() || actionButtonText != null) { actionButton = new AutoTooltipButton(actionButtonText == null ? Res.get("shared.ok") : actionButtonText); if (!disableActionButton) actionButton.setDefaultButton(true); else actionButton.setDisable(true); HBox.setHgrow(actionButton, Priority.SOMETIMES); actionButton.getStyleClass().add("action-button"); //TODO app wide focus //actionButton.requestFocus(); if (!disableActionButton) { actionButton.setOnAction(event -> { hide(); actionHandlerOptional.ifPresent(Runnable::run); }); } buttonBox.setSpacing(10); buttonBox.setAlignment(Pos.CENTER); if (buttonAlignment == HPos.RIGHT) buttonBox.getChildren().add(spacer); buttonBox.getChildren().addAll(actionButton); if (secondaryActionButtonText != null && secondaryActionHandlerOptional.isPresent()) { secondaryActionButton = new AutoTooltipButton(secondaryActionButtonText); secondaryActionButton.setOnAction(event -> { hide(); secondaryActionHandlerOptional.ifPresent(Runnable::run); }); buttonBox.getChildren().add(secondaryActionButton); } if (!hideCloseButton) buttonBox.getChildren().add(closeButton); } else if (!hideCloseButton) { closeButton.setDefaultButton(true); buttonBox.getChildren().addAll(spacer, closeButton); } }