Search in sources :

Example 16 with BorderStroke

use of javafx.scene.layout.BorderStroke 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());
    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());
    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);
    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, description, minusLabel, plusLabel);
}
Also used : EventType(javafx.event.EventType) BorderWidths(javafx.scene.layout.BorderWidths) Label(javafx.scene.control.Label) BorderStroke(javafx.scene.layout.BorderStroke) Text(javafx.scene.text.Text) TextFlow(javafx.scene.text.TextFlow) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 17 with BorderStroke

use of javafx.scene.layout.BorderStroke 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 18 with BorderStroke

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

the class TileSkin method redraw.

protected void redraw() {
    pane.setBorder(new Border(new BorderStroke(tile.getBorderColor(), BorderStrokeStyle.SOLID, tile.getRoundedCorners() ? 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(), tile.getRoundedCorners() ? new CornerRadii(clamp(0, Double.MAX_VALUE, size * 0.025)) : CornerRadii.EMPTY, Insets.EMPTY)));
    notifyRegion.setRoundedCorner(tile.getRoundedCorners());
    notifyRegion.setBackgroundColor(tile.getNotificationBackgroundColor());
    notifyRegion.setForegroundColor(tile.getNotificationForegroundColor());
    locale = tile.getLocale();
    formatString = new StringBuilder("%.").append(Integer.toString(tile.getDecimals())).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 19 with BorderStroke

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

the class TileSkin method initGraphics.

// ******************** Initialization ************************************
protected void initGraphics() {
    // Set initial size
    if (Double.compare(tile.getPrefWidth(), 0.0) <= 0 || Double.compare(tile.getPrefHeight(), 0.0) <= 0 || Double.compare(tile.getWidth(), 0.0) <= 0 || Double.compare(tile.getHeight(), 0.0) <= 0) {
        if (tile.getPrefWidth() > 0 && tile.getPrefHeight() > 0) {
            tile.setPrefSize(tile.getPrefWidth(), tile.getPrefHeight());
        } else {
            tile.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }
    shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 3, 0, 0, 0);
    notifyRegion = new NotifyRegion();
    enableNode(notifyRegion, false);
    pane = new Pane(notifyRegion);
    pane.setBorder(new Border(new BorderStroke(tile.getBorderColor(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(tile.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(tile.getBackgroundColor(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));
    getChildren().setAll(pane);
}
Also used : NotifyRegion(eu.hansolo.tilesfx.tools.NotifyRegion) 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) Pane(javafx.scene.layout.Pane) Border(javafx.scene.layout.Border) DropShadow(javafx.scene.effect.DropShadow)

Example 20 with BorderStroke

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

the class SunburstChart method redraw.

public 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))));
    segmentPane.setBackground(new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)));
    segmentPane.setManaged(isInteractive());
    segmentPane.setVisible(isInteractive());
    drawChart();
}
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)

Aggregations

Border (javafx.scene.layout.Border)23 BorderStroke (javafx.scene.layout.BorderStroke)23 BorderWidths (javafx.scene.layout.BorderWidths)18 Background (javafx.scene.layout.Background)13 BackgroundFill (javafx.scene.layout.BackgroundFill)13 CornerRadii (javafx.scene.layout.CornerRadii)10 Insets (javafx.geometry.Insets)9 Text (javafx.scene.text.Text)5 ArrayList (java.util.ArrayList)4 Label (javafx.scene.control.Label)4 List (java.util.List)3 BorderStrokeStyle (javafx.scene.layout.BorderStrokeStyle)3 Color (javafx.scene.paint.Color)3 ZonedDateTime (java.time.ZonedDateTime)2 Optional (java.util.Optional)2 ObservableList (javafx.collections.ObservableList)2 MouseEvent (javafx.scene.input.MouseEvent)2 StackPane (javafx.scene.layout.StackPane)2 VBox (javafx.scene.layout.VBox)2 Rectangle (javafx.scene.shape.Rectangle)2