Search in sources :

Example 21 with BorderWidths

use of javafx.scene.layout.BorderWidths in project tilesfx by HanSolo.

the class TileSkin method redraw.

protected void redraw() {
    boolean hasRoundedCorners = tile.getRoundedCorners();
    pane.setBorder(new Border(new BorderStroke(tile.getBorderColor(), BorderStrokeStyle.SOLID, hasRoundedCorners ? new CornerRadii(clamp(0, Double.MAX_VALUE, size * 0.025)) : CornerRadii.EMPTY, new BorderWidths(clamp(0, Double.MAX_VALUE, tile.getBorderWidth() / PREFERRED_WIDTH * size)))));
    pane.setBackground(new Background(new BackgroundFill(tile.getBackgroundColor(), hasRoundedCorners ? new CornerRadii(clamp(0, Double.MAX_VALUE, size * 0.025)) : CornerRadii.EMPTY, Insets.EMPTY)));
    backgroundImageView.setOpacity(tile.getBackgroundImageOpacity());
    notifyRegion.setRoundedCorner(hasRoundedCorners);
    notifyRegion.setBackgroundColor(tile.getNotifyRegionBackgroundColor());
    notifyRegion.setForegroundColor(tile.getNotifyRegionForegroundColor());
    notifyRegion.setTooltipText(tile.getNotifyRegionTooltipText());
    infoRegion.setRoundedCorner(hasRoundedCorners);
    infoRegion.setBackgroundColor(tile.getInfoRegionBackgroundColor());
    infoRegion.setForegroundColor(tile.getInfoRegionForegroundColor());
    infoRegion.setTooltipText(tile.getInfoRegionTooltipText());
    lowerRightRegion.setRoundedCorner(hasRoundedCorners);
    lowerRightRegion.setBackgroundColor(tile.getLowerRightRegionBackgroundColor());
    lowerRightRegion.setForegroundColor(tile.getLowerRightRegionForegroundColor());
    lowerRightRegion.setTooltipText(tile.getLowerRightRegionTooltipText());
    locale = tile.getLocale();
    if (tile.getCustomDecimalFormatEnabled()) {
        decimalFormat = tile.getCustomDecimalFormat();
    } else {
        formatString = new StringBuilder("%.").append(tile.getDecimals()).append("f").toString();
    }
    tickLabelFormatString = new StringBuilder("%.").append(tile.getTickLabelDecimals()).append("f").toString();
    sectionsVisible = tile.getSectionsVisible();
    textSize = tile.getTextSize();
}
Also used : Background(javafx.scene.layout.Background) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 22 with BorderWidths

use of javafx.scene.layout.BorderWidths in project tilesfx by HanSolo.

the class PlusMinusTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    mouseEventHandler = e -> {
        final EventType TYPE = e.getEventType();
        final Label SRC = (Label) e.getSource();
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            if (SRC.equals(minusLabel)) {
                decrement();
            } else if (SRC.equals(plusLabel)) {
                increment();
            }
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            if (SRC.equals(minusLabel)) {
                minusLabel.setTextFill(tile.getForegroundColor());
                minusLabel.setBorder(new Border(new BorderStroke(tile.getForegroundColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
            } else if (SRC.equals(plusLabel)) {
                plusLabel.setTextFill(tile.getForegroundColor());
                plusLabel.setBorder(new Border(new BorderStroke(tile.getForegroundColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
            }
        }
    };
    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());
    valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());
    upperUnitText = new Text("");
    upperUnitText.setFill(tile.getUnitColor());
    Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty());
    fractionLine = new Line();
    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());
    unitFlow = new VBox(upperUnitText, unitText);
    unitFlow.setAlignment(Pos.CENTER_RIGHT);
    valueUnitFlow = new HBox(valueText, unitFlow);
    valueUnitFlow.setAlignment(Pos.BOTTOM_RIGHT);
    valueUnitFlow.setMouseTransparent(true);
    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setWrapText(true);
    description.setTextFill(tile.getTextColor());
    Helper.enableNode(description, !tile.getDescription().isEmpty());
    plusLabel = new Label("+");
    plusLabel.setAlignment(Pos.CENTER);
    plusLabel.setEffect(shadow);
    plusLabel.setPickOnBounds(false);
    minusLabel = new Label("-");
    minusLabel.setAlignment(Pos.CENTER);
    minusLabel.setEffect(shadow);
    minusLabel.setPickOnBounds(false);
    getPane().getChildren().addAll(titleText, text, valueUnitFlow, fractionLine, description, minusLabel, plusLabel);
}
Also used : Line(javafx.scene.shape.Line) HBox(javafx.scene.layout.HBox) EventType(javafx.event.EventType) BorderWidths(javafx.scene.layout.BorderWidths) Label(javafx.scene.control.Label) BorderStroke(javafx.scene.layout.BorderStroke) Text(javafx.scene.text.Text) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border) VBox(javafx.scene.layout.VBox)

Example 23 with BorderWidths

use of javafx.scene.layout.BorderWidths in project tilesfx by HanSolo.

the class PlusMinusTileSkin method increment.

private void increment() {
    plusLabel.setTextFill(tile.getActiveColor());
    plusLabel.setBorder(new Border(new BorderStroke(tile.getActiveColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
    double newValue = clamp(minValue, maxValue, tile.getValue() + tile.getIncrement());
    tile.setValue(newValue);
}
Also used : BorderWidths(javafx.scene.layout.BorderWidths) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 24 with BorderWidths

use of javafx.scene.layout.BorderWidths in project XR3Player by goxr3plus.

the class FunIndicator method redraw.

/**
 * Redraw.
 */
private void redraw() {
    pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth / PREFERRED_WIDTH * size))));
}
Also used : Background(javafx.scene.layout.Background) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) BorderStroke(javafx.scene.layout.BorderStroke) Border(javafx.scene.layout.Border)

Example 25 with BorderWidths

use of javafx.scene.layout.BorderWidths in project JFoenix by sshahine.

the class JFXDecorator method initializeContainers.

private void initializeContainers(Node node, boolean fullScreen, boolean max, boolean min) {
    buttonsContainer = new HBox();
    buttonsContainer.getStyleClass().add("jfx-decorator-buttons-container");
    buttonsContainer.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
    // BINDING
    buttonsContainer.setPadding(new Insets(4));
    buttonsContainer.setAlignment(Pos.CENTER_RIGHT);
    // customize decorator buttons
    List<JFXButton> btns = new ArrayList<>();
    if (fullScreen) {
        btns.add(btnFull);
    }
    if (min) {
        btns.add(btnMin);
    }
    if (max) {
        btns.add(btnMax);
        // maximize/restore the window on header double click
        buttonsContainer.addEventHandler(MouseEvent.MOUSE_CLICKED, (mouseEvent) -> {
            if (mouseEvent.getClickCount() == 2) {
                btnMax.fire();
            }
        });
    }
    btns.add(btnClose);
    text = new Text();
    text.getStyleClass().addAll("jfx-decorator-text", "title", "jfx-decorator-title");
    text.setFill(Color.WHITE);
    // binds the Text's text to title
    text.textProperty().bind(title);
    // binds title to the primaryStage's title
    title.bind(primaryStage.titleProperty());
    graphicContainer = new HBox();
    graphicContainer.setPickOnBounds(false);
    graphicContainer.setAlignment(Pos.CENTER_LEFT);
    graphicContainer.getChildren().setAll(text);
    HBox graphicTextContainer = new HBox(graphicContainer, text);
    graphicTextContainer.getStyleClass().add("jfx-decorator-title-container");
    graphicTextContainer.setAlignment(Pos.CENTER_LEFT);
    graphicTextContainer.setPickOnBounds(false);
    HBox.setHgrow(graphicTextContainer, Priority.ALWAYS);
    HBox.setMargin(graphicContainer, new Insets(0, 8, 0, 8));
    buttonsContainer.getChildren().setAll(graphicTextContainer);
    buttonsContainer.getChildren().addAll(btns);
    buttonsContainer.addEventHandler(MouseEvent.MOUSE_ENTERED, (enter) -> allowMove = true);
    buttonsContainer.addEventHandler(MouseEvent.MOUSE_EXITED, (enter) -> {
        if (!isDragging) {
            allowMove = false;
        }
    });
    buttonsContainer.setMinWidth(180);
    contentPlaceHolder.getStyleClass().add("jfx-decorator-content-container");
    contentPlaceHolder.setMinSize(0, 0);
    StackPane clippedContainer = new StackPane(node);
    contentPlaceHolder.getChildren().add(clippedContainer);
    ((Region) node).setMinSize(0, 0);
    VBox.setVgrow(contentPlaceHolder, Priority.ALWAYS);
    contentPlaceHolder.getStyleClass().add("resize-border");
    contentPlaceHolder.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(0, 4, 4, 4))));
    // BINDING
    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(clippedContainer.widthProperty());
    clip.heightProperty().bind(clippedContainer.heightProperty());
    clippedContainer.setClip(clip);
    this.getChildren().addAll(buttonsContainer, contentPlaceHolder);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) ArrayList(java.util.ArrayList) Rectangle(javafx.scene.shape.Rectangle) Text(javafx.scene.text.Text) BorderWidths(javafx.scene.layout.BorderWidths) Region(javafx.scene.layout.Region) BorderStroke(javafx.scene.layout.BorderStroke) Border(javafx.scene.layout.Border) StackPane(javafx.scene.layout.StackPane)

Aggregations

BorderStroke (javafx.scene.layout.BorderStroke)32 BorderWidths (javafx.scene.layout.BorderWidths)32 Border (javafx.scene.layout.Border)31 Background (javafx.scene.layout.Background)20 BackgroundFill (javafx.scene.layout.BackgroundFill)20 CornerRadii (javafx.scene.layout.CornerRadii)16 Insets (javafx.geometry.Insets)11 Text (javafx.scene.text.Text)8 ArrayList (java.util.ArrayList)6 VBox (javafx.scene.layout.VBox)6 HBox (javafx.scene.layout.HBox)5 Pane (javafx.scene.layout.Pane)4 Region (javafx.scene.layout.Region)3 StackPane (javafx.scene.layout.StackPane)3 Rectangle (javafx.scene.shape.Rectangle)3 List (java.util.List)2 ObservableList (javafx.collections.ObservableList)2 Color (javafx.scene.paint.Color)2 Line (javafx.scene.shape.Line)2 CommonWidgetProperties.propBorderColor (org.csstudio.display.builder.model.properties.CommonWidgetProperties.propBorderColor)2