Search in sources :

Example 21 with InnerShadow

use of javafx.scene.effect.InnerShadow in project Board-Instrumentation-Framework by intel.

the class LcdSkin method initGraphics.

private void initGraphics() {
    main = new Region();
    main.getStyleClass().setAll("main");
    main.setOpacity(getSkinnable().isBackgroundVisible() ? 1 : 0);
    mainInnerShadow0 = new InnerShadow();
    mainInnerShadow0.setOffsetX(0.0);
    mainInnerShadow0.setOffsetY(0.0);
    mainInnerShadow0.setRadius(3.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow0.setColor(Color.web("0xffffff80"));
    mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1 = new InnerShadow();
    mainInnerShadow1.setOffsetX(0.0);
    mainInnerShadow1.setOffsetY(1.0);
    mainInnerShadow1.setRadius(2.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow1.setColor(Color.web("0x000000a6"));
    mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1.setInput(mainInnerShadow0);
    main.setEffect(getSkinnable().isMainInnerShadowVisible() ? mainInnerShadow1 : null);
    crystalClip = new Rectangle(0, 0, width, height);
    crystalClip.setArcWidth(5);
    crystalClip.setArcHeight(5);
    crystalImage = createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8);
    crystalOverlay = new ImageView(crystalImage);
    crystalOverlay.setClip(crystalClip);
    crystalOverlay.setOpacity(getSkinnable().isCrystalOverlayVisible() ? 1 : 0);
    threshold = new Region();
    threshold.getStyleClass().setAll("threshold");
    threshold.setOpacity(0);
    trendDown = new Region();
    trendDown.getStyleClass().setAll("trend-down");
    trendDown.setOpacity((getSkinnable().isTrendVisible() && Lcd.Trend.DOWN == getSkinnable().getTrend()) ? 1 : 0);
    trendFalling = new Region();
    trendFalling.getStyleClass().setAll("trend-falling");
    trendFalling.setOpacity((getSkinnable().isTrendVisible() && Lcd.Trend.FALLING == getSkinnable().getTrend()) ? 1 : 0);
    trendSteady = new Region();
    trendSteady.getStyleClass().setAll("trend-steady");
    trendSteady.setOpacity((getSkinnable().isTrendVisible() && Lcd.Trend.STEADY == getSkinnable().getTrend()) ? 1 : 0);
    trendRising = new Region();
    trendRising.getStyleClass().setAll("trend-rising");
    trendRising.setOpacity((getSkinnable().isTrendVisible() && Lcd.Trend.RISING == getSkinnable().getTrend()) ? 1 : 0);
    trendUp = new Region();
    trendUp.getStyleClass().setAll("trend-up");
    trendUp.setOpacity((getSkinnable().isTrendVisible() && Lcd.Trend.UP == getSkinnable().getTrend()) ? 1 : 0);
    battery = new Region();
    battery.getStyleClass().setAll("battery-empty");
    battery.setOpacity(getSkinnable().isBatteryVisible() ? 1 : 0);
    signal = new Region();
    signal.getStyleClass().setAll("signal");
    signal.setOpacity(getSkinnable().isSignalVisible() ? 1 : 0);
    alarm = new Region();
    alarm.getStyleClass().setAll("alarm");
    alarm.setOpacity(getSkinnable().isAlarmVisible() ? 1 : 0);
    if (getSkinnable().isTextMode() && getSkinnable().getValueFont() == LcdFont.LCD) {
        getSkinnable().setValueFont(LcdFont.DIGITAL);
    }
    backgroundText = new Text(getSkinnable().isTextMode() ? getSkinnable().getText() : Double.toString(getSkinnable().getValue()));
    backgroundText.getStyleClass().setAll("fg-trsp");
    backgroundText.setOpacity((Lcd.LcdFont.LCD == getSkinnable().getValueFont() || Lcd.LcdFont.ELEKTRA == getSkinnable().getValueFont()) ? 1 : 0);
    text = new Text(getSkinnable().isTextMode() ? getSkinnable().getText() : Double.toString(getSkinnable().getValue()));
    text.getStyleClass().setAll("fg");
    unitText = new Text(getSkinnable().getUnit());
    unitText.getStyleClass().setAll("fg");
    unitText.setOpacity(getSkinnable().isUnitVisible() ? 1 : 0);
    unitText.visibleProperty().bind(getSkinnable().unitVisibleProperty());
    title = new Text(getSkinnable().getTitle());
    title.getStyleClass().setAll("fg");
    title.setOpacity(getSkinnable().isTitleVisible() ? 1 : 0);
    lowerRightText = getSkinnable().isNumberSystemVisible() ? new Text(getSkinnable().getNumberSystem().toString()) : new Text(getSkinnable().getLowerRightText());
    lowerRightText.getStyleClass().setAll("fg");
    lowerRightText.setOpacity(getSkinnable().isLowerRightTextVisible() ? 1 : 0);
    upperLeftText = getSkinnable().isMinMeasuredValueVisible() ? new Text(Double.toString(getSkinnable().getMaxValue())) : new Text(getSkinnable().getUpperLeftText());
    upperLeftText.getStyleClass().setAll("fg");
    upperLeftText.setOpacity(getSkinnable().isMinMeasuredValueVisible() ? 1 : 0);
    upperRightText = getSkinnable().isMaxMeasuredValueVisible() ? new Text(Double.toString(getSkinnable().getMinValue())) : new Text(getSkinnable().getUpperRightText());
    upperRightText.getStyleClass().setAll("fg");
    upperRightText.setOpacity(getSkinnable().isMaxMeasuredValueVisible() ? 1 : 0);
    lowerCenterText = new Text(getSkinnable().isFormerValueVisible() ? Double.toString(getSkinnable().getFormerValue()) : getSkinnable().getLowerCenterText());
    lowerCenterText.getStyleClass().setAll("fg");
    shadowGroup = new Group();
    shadowGroup.setEffect(getSkinnable().isForegroundShadowVisible() ? FOREGROUND_SHADOW : null);
    shadowGroup.getChildren().setAll(threshold, trendDown, trendFalling, trendSteady, trendRising, trendUp, battery, signal, alarm, text, unitText, title, lowerRightText, upperLeftText, upperRightText, lowerCenterText);
    pane = new Pane();
    pane.getChildren().setAll(main, crystalOverlay, backgroundText, shadowGroup);
    getChildren().setAll(pane);
}
Also used : Group(javafx.scene.Group) InnerShadow(javafx.scene.effect.InnerShadow) Rectangle(javafx.scene.shape.Rectangle) Region(javafx.scene.layout.Region) Text(javafx.scene.text.Text) ImageView(javafx.scene.image.ImageView) Pane(javafx.scene.layout.Pane)

Example 22 with InnerShadow

use of javafx.scene.effect.InnerShadow in project Board-Instrumentation-Framework by intel.

the class PushButtonSkin method initGraphics.

private void initGraphics() {
    frame = new Region();
    frame.getStyleClass().setAll("frame");
    frameInnerShadow0 = new InnerShadow();
    frameInnerShadow0.setOffsetX(0);
    frameInnerShadow0.setOffsetY(1);
    frameInnerShadow0.setRadius(0);
    frameInnerShadow0.setColor(Color.web("0x333333a6"));
    frameInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    frameInnerShadow1 = new InnerShadow();
    frameInnerShadow1.setOffsetX(0);
    frameInnerShadow1.setOffsetY(-1);
    frameInnerShadow1.setRadius(0);
    frameInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    frameInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    frameInnerShadow1.setInput(frameInnerShadow0);
    frame.setEffect(frameInnerShadow1);
    deselected = new Region();
    deselected.getStyleClass().setAll("deselected");
    deselectedInnerShadow0 = new InnerShadow();
    deselectedInnerShadow0.setOffsetX(0);
    deselectedInnerShadow0.setOffsetY(-1);
    deselectedInnerShadow0.setRadius(0);
    deselectedInnerShadow0.setColor(Color.web("0x4b4e52a6"));
    deselectedInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedInnerShadow1 = new InnerShadow();
    deselectedInnerShadow1.setOffsetX(0);
    deselectedInnerShadow1.setOffsetY(1);
    deselectedInnerShadow1.setRadius(0);
    deselectedInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    deselectedInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedInnerShadow1.setInput(deselectedInnerShadow0);
    deselectedDropShadow = new DropShadow();
    deselectedDropShadow.setOffsetX(0);
    deselectedDropShadow.setOffsetY(3);
    deselectedDropShadow.setRadius(3.0 / 128.0 * PREFERRED_WIDTH);
    deselectedDropShadow.setColor(Color.web("0x000000a6"));
    deselectedDropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedDropShadow.setInput(deselectedInnerShadow1);
    deselected.setEffect(deselectedDropShadow);
    selected = new Region();
    selected.getStyleClass().setAll("selected");
    selectedInnerShadow0 = new InnerShadow();
    selectedInnerShadow0.setOffsetX(0);
    selectedInnerShadow0.setOffsetY(-1);
    selectedInnerShadow0.setRadius(0);
    selectedInnerShadow0.setColor(Color.web("0x4b4e52a6"));
    selectedInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    selectedInnerShadow1 = new InnerShadow();
    selectedInnerShadow1.setOffsetX(0);
    selectedInnerShadow1.setOffsetY(1);
    selectedInnerShadow1.setRadius(0);
    selectedInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    selectedInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    selectedInnerShadow1.setInput(selectedInnerShadow0);
    selectedDropShadow = new DropShadow();
    selectedDropShadow.setOffsetX(0);
    selectedDropShadow.setOffsetY(0);
    selectedDropShadow.setRadius(2.0 / 128.0 * PREFERRED_WIDTH);
    selectedDropShadow.setColor(Color.web("0x000000a6"));
    selectedDropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    selectedDropShadow.setInput(selectedInnerShadow1);
    selected.setEffect(selectedDropShadow);
    icon = new Region();
    icon.getStyleClass().setAll("icon");
    pane.getChildren().setAll(frame, deselected, selected, icon);
    // Adjust visibility dependent on settings
    updateStatus();
    getChildren().setAll(pane);
    resize();
}
Also used : InnerShadow(javafx.scene.effect.InnerShadow) Region(javafx.scene.layout.Region) DropShadow(javafx.scene.effect.DropShadow)

Example 23 with InnerShadow

use of javafx.scene.effect.InnerShadow 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)

Aggregations

InnerShadow (javafx.scene.effect.InnerShadow)23 DropShadow (javafx.scene.effect.DropShadow)17 Region (javafx.scene.layout.Region)17 Pane (javafx.scene.layout.Pane)13 Text (javafx.scene.text.Text)13 Canvas (javafx.scene.canvas.Canvas)9 Group (javafx.scene.Group)8 Rotate (javafx.scene.transform.Rotate)7 Stop (javafx.scene.paint.Stop)6 LinearGradient (javafx.scene.paint.LinearGradient)5 Color (javafx.scene.paint.Color)4 RadialGradient (javafx.scene.paint.RadialGradient)4 Label (javafx.scene.control.Label)3 Path (javafx.scene.shape.Path)3 Rectangle (javafx.scene.shape.Rectangle)3 Blend (javafx.scene.effect.Blend)2 ImageView (javafx.scene.image.ImageView)2 Arc (javafx.scene.shape.Arc)2 Circle (javafx.scene.shape.Circle)2 LineTo (javafx.scene.shape.LineTo)2