Search in sources :

Example 11 with CornerRadii

use of javafx.scene.layout.CornerRadii in project Retrospector by NonlinearFruit.

the class Retrospector method init.

@Override
public void init() {
    ImageView splash = new ImageView(new Image(SPLASH_IMAGE, SPLASH_WIDTH, SPLASH_HEIGHT, true, true));
    loadProgress = new ProgressBar(0);
    loadProgress.setPrefWidth(SPLASH_WIDTH);
    progressText = new Label("Initializing . . .");
    progressText.setBackground(new Background(new BackgroundFill(Color.GHOSTWHITE, new CornerRadii(5), new Insets(0))));
    splashLayout = new VBox();
    splashLayout.getChildren().addAll(splash, loadProgress, progressText);
    progressText.setAlignment(Pos.CENTER);
    //        splashLayout.setEffect(new DropShadow());
    splashLayout.setBackground(Background.EMPTY);
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Label(javafx.scene.control.Label) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) CornerRadii(javafx.scene.layout.CornerRadii) ProgressBar(javafx.scene.control.ProgressBar) VBox(javafx.scene.layout.VBox)

Example 12 with CornerRadii

use of javafx.scene.layout.CornerRadii in project KNOBS by ESSICS.

the class Knob method initComponents.

protected void initComponents() {
    angleStepProperty().bind(Bindings.divide(ANGLE_RANGE, Bindings.subtract(maxValueProperty(), minValueProperty())));
    backgroundProperty().bind(Bindings.createObjectBinding(() -> Color.TRANSPARENT.equals(getBackgroundColor()) ? Background.EMPTY : new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)), backgroundColorProperty()));
    dropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.20), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.20), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);
    barGradient = new ConicalGradient(reorderStops(getGradientStops()));
    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT)));
    currentValueBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    currentValueBarArc.setType(ArcType.OPEN);
    currentValueBarArc.setStrokeLineCap(StrokeLineCap.ROUND);
    currentValueBarArc.setFill(null);
    currentValueBarArc.strokeProperty().bind(currentValueColorProperty());
    currentValueBarArc.lengthProperty().bind(Bindings.createDoubleBinding(() -> {
        double localMin = (isZeroDetentEnabled() && getMinValue() < 0) ? Math.min(0, getMaxValue()) : getMinValue();
        double length = getAngleStep() * (localMin - getCurrentValue());
        if (length == 0) {
            length = getAngleStep() * (getMinValue() - getMaxValue()) / 10000;
        }
        return length;
    }, angleStepProperty(), currentValueProperty(), maxValueProperty(), minValueProperty(), zeroDetentEnabledProperty()));
    currentValueBarArc.opacityProperty().bind(Bindings.createDoubleBinding(() -> {
        double localMin = (isZeroDetentEnabled() && getMinValue() < 0) ? Math.min(0, getMaxValue()) : getMinValue();
        double length = getAngleStep() * (localMin - getCurrentValue());
        if (length == 0) {
            return 0.6666;
        } else {
            return 1.0;
        }
    }, angleStepProperty(), currentValueProperty(), maxValueProperty(), minValueProperty(), zeroDetentEnabledProperty()));
    currentValueBarArc.startAngleProperty().bind(Bindings.createDoubleBinding(() -> {
        double angle = BAR_START_ANGLE;
        if (isZeroDetentEnabled() && getMinValue() < 0) {
            angle += Math.max(getAngleStep() * getMinValue(), -ANGLE_RANGE);
        }
        return angle;
    }, angleStepProperty(), minValueProperty(), zeroDetentEnabledProperty()));
    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42), new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.fillProperty().bind(colorProperty());
    ring.setEffect(dropShadow);
    ring.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
        if (!isDisabled() && !isDragDisabled()) {
            touchRotate(e.getSceneX(), e.getSceneY());
        }
    });
    ring.addEventHandler(MouseEvent.MOUSE_DRAGGED, e -> {
        if (!isDisabled() && !isDragDisabled()) {
            touchRotate(e.getSceneX(), e.getSceneY());
        }
    });
    ring.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
        if (!isDisabled() && !isDragDisabled()) {
            fireTargeValueSet();
        }
    });
    mainCircle = new Circle();
    mainCircle.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
    mainCircle.setOnMouseClicked(doubleClickHandler);
    text = new Text(String.format(format, getCurrentValue()));
    text.fillProperty().bind(textColorProperty());
    text.setOnMouseClicked(doubleClickHandler);
    text.setTextOrigin(VPos.CENTER);
    targetText = new Text(String.format(format, getTargetValue()));
    targetText.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
    targetText.setOnMouseClicked(doubleClickHandler);
    targetText.setTextOrigin(VPos.CENTER);
    targetText.visibleProperty().bind(Bindings.createBooleanBinding(() -> isTargetValueAlwaysVisible() || !close(getCurrentValue(), getTargetValue(), (getMaxValue() - getMinValue()) * PROXIMITY_ERROR), targetValueAlwaysVisibleProperty(), currentValueProperty(), targetValueProperty(), maxValueProperty(), minValueProperty()));
    unitText = new Text(getUnit());
    unitText.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
    unitText.setOnMouseClicked(doubleClickHandler);
    unitText.setTextOrigin(VPos.CENTER);
    textMinTag = new Polygon(0.0, 0.7, 0.6, 0.7, 0.6, 0.9, 0.0, 0.9);
    textMinTag.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
    textMinTag.visibleProperty().bind(extremaVisibleProperty());
    textMin = new Text(String.format(format, getMinValue()));
    textMin.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
    textMin.setTextOrigin(VPos.CENTER);
    textMin.visibleProperty().bind(extremaVisibleProperty());
    textMaxTag = new Polygon(0.0, 0.7, 0.6, 0.7, 0.6, 0.9, 0.0, 0.9);
    textMaxTag.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
    textMaxTag.visibleProperty().bind(extremaVisibleProperty());
    textMax = new Text(String.format(format, getMaxValue()));
    textMax.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
    textMax.setTextOrigin(VPos.CENTER);
    textMax.visibleProperty().bind(extremaVisibleProperty());
    tagBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE + 15, 50);
    tagBarArc.setType(ArcType.OPEN);
    tagBarArc.setStrokeLineCap(StrokeLineCap.ROUND);
    tagBarArc.setFill(null);
    tagBarArc.strokeProperty().bind(tagColorProperty());
    tagBarArc.visibleProperty().bind(tagVisibleProperty());
    indicatorRotate = new Rotate(-ANGLE_RANGE * 0.5, center, center);
    indicatorGlow = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.020, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.50), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorRotate.angleProperty().bind(Bindings.subtract(Bindings.multiply(Bindings.subtract(targetValueProperty(), minValueProperty()), angleStepProperty()), ANGLE_RANGE * 0.5));
    indicatorGlow.colorProperty().bind(selectionColorProperty());
    indicatorHighlight.setInput(indicatorInnerShadow);
    indicator = new Circle();
    indicator.effectProperty().bind(Bindings.createObjectBinding(() -> isSelected() ? indicatorGlow : null, selectionColorProperty(), selectedProperty()));
    indicator.disableProperty().bind(dragDisabledProperty());
    indicator.fillProperty().bind(Bindings.createObjectBinding(() -> {
        Color c = isSelected() ? getSelectionColor() : getIndicatorColor();
        return isDragDisabled() ? c.deriveColor(0, 1, 0.92, 0.6) : c;
    }, colorProperty(), dragDisabledProperty(), indicatorColorProperty(), selectionColorProperty(), selectedProperty()));
    indicator.strokeProperty().bind(Bindings.createObjectBinding(() -> {
        Color c = isSelected() ? getSelectionColor().darker().darker() : getIndicatorColor().darker().darker();
        return isDragDisabled() ? c.deriveColor(0, 1, 0.92, 0.6) : c;
    }, colorProperty(), dragDisabledProperty(), indicatorColorProperty(), selectionColorProperty(), selectedProperty()));
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);
    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);
    pane = new Pane(barArc, currentValueBarArc, ring, mainCircle, text, targetText, unitText, textMinTag, textMin, textMaxTag, textMax, tagBarArc, indicatorGroup);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.backgroundProperty().bind(Bindings.createObjectBinding(() -> new Background(new BackgroundFill(getColor().darker(), new CornerRadii(1024), Insets.EMPTY)), colorProperty()));
    pane.setEffect(highlight);
    Platform.runLater(() -> getChildren().setAll(pane));
}
Also used : ConicalGradient(eu.hansolo.medusa.tools.ConicalGradient) Circle(javafx.scene.shape.Circle) Group(javafx.scene.Group) Background(javafx.scene.layout.Background) Rotate(javafx.scene.transform.Rotate) InnerShadow(javafx.scene.effect.InnerShadow) BackgroundFill(javafx.scene.layout.BackgroundFill) Color(javafx.scene.paint.Color) Rectangle(javafx.scene.shape.Rectangle) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) DropShadow(javafx.scene.effect.DropShadow) Arc(javafx.scene.shape.Arc) Polygon(javafx.scene.shape.Polygon) CornerRadii(javafx.scene.layout.CornerRadii)

Example 13 with CornerRadii

use of javafx.scene.layout.CornerRadii 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 14 with CornerRadii

use of javafx.scene.layout.CornerRadii 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 15 with CornerRadii

use of javafx.scene.layout.CornerRadii 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)

Aggregations

CornerRadii (javafx.scene.layout.CornerRadii)20 Background (javafx.scene.layout.Background)15 BackgroundFill (javafx.scene.layout.BackgroundFill)15 Border (javafx.scene.layout.Border)8 BorderStroke (javafx.scene.layout.BorderStroke)8 BorderWidths (javafx.scene.layout.BorderWidths)8 Text (javafx.scene.text.Text)5 Insets (javafx.geometry.Insets)4 Label (javafx.scene.control.Label)4 DropShadow (javafx.scene.effect.DropShadow)3 Pane (javafx.scene.layout.Pane)3 Color (javafx.scene.paint.Color)2 Rectangle (javafx.scene.shape.Rectangle)2 TextFlow (javafx.scene.text.TextFlow)2 BlackCard (com.gianlu.pyxreborn.Models.BlackCard)1 ConicalGradient (eu.hansolo.medusa.tools.ConicalGradient)1 Tile (eu.hansolo.tilesfx.Tile)1 ChartData (eu.hansolo.tilesfx.chart.ChartData)1 TileEvent (eu.hansolo.tilesfx.events.TileEvent)1 EventType (eu.hansolo.tilesfx.events.TileEvent.EventType)1