Search in sources :

Example 1 with ClosePath

use of javafx.scene.shape.ClosePath in project Board-Instrumentation-Framework by intel.

the class OneEightyGaugeSkin method initGraphics.

private void initGraphics() {
    unitText = new Text(getSkinnable().getUnit());
    unitText.setTextOrigin(VPos.CENTER);
    unitText.getStyleClass().setAll("unit");
    unitText.setFill(getSkinnable().getUnitColor());
    titleText = new Text(getSkinnable().getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.getStyleClass().setAll("title");
    titleText.setFill(getSkinnable().getTitleColor());
    valueText = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getValue()));
    valueText.setTextOrigin(VPos.CENTER);
    valueText.getStyleClass().setAll("value");
    valueText.setFill(getSkinnable().getValueColor());
    minText = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinValue()));
    minText.setTextOrigin(VPos.CENTER);
    minText.getStyleClass().setAll("min-text");
    minText.setFill(getSkinnable().getMinTextColor());
    maxText = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxValue()));
    maxText.setTextOrigin(VPos.CENTER);
    maxText.getStyleClass().setAll("max-text");
    maxText.setFill(getSkinnable().getMaxTextColor());
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.3), 30d, 0d, 0d, 10d);
    barBackgroundStart = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    barBackgroundOuterArc = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, true, true);
    barBackgroundLineToInnerArc = new LineTo(0.72222 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    barBackgroundInnerArc = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, false, false);
    barBackground = new Path();
    barBackground.setFillRule(FillRule.EVEN_ODD);
    barBackground.getElements().add(barBackgroundStart);
    barBackground.getElements().add(barBackgroundOuterArc);
    barBackground.getElements().add(barBackgroundLineToInnerArc);
    barBackground.getElements().add(barBackgroundInnerArc);
    barBackground.getElements().add(new ClosePath());
    barBackground.getStyleClass().setAll("bar-background");
    barBackground.setFill(getSkinnable().getBarBackgroundColor());
    barBackground.setEffect(getSkinnable().isShadowsEnabled() ? innerShadow : null);
    dataBarStart = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    dataBarOuterArc = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, 0, 0, false, true);
    dataBarLineToInnerArc = new LineTo(0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    dataBarInnerArc = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0, 0, false, false);
    dataBar = new Path();
    dataBar.setFillRule(FillRule.EVEN_ODD);
    dataBar.getElements().add(dataBarStart);
    dataBar.getElements().add(dataBarOuterArc);
    dataBar.getElements().add(dataBarLineToInnerArc);
    dataBar.getElements().add(dataBarInnerArc);
    dataBar.getElements().add(new ClosePath());
    dataBar.getStyleClass().setAll("data-bar");
    dataBar.setFill(getSkinnable().getBarColor());
    dataBar.setEffect(getSkinnable().isShadowsEnabled() ? innerShadow : null);
    pane = new Pane();
    pane.getChildren().setAll(unitText, titleText, valueText, minText, maxText, barBackground, dataBar);
    getChildren().setAll(pane);
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) ArcTo(javafx.scene.shape.ArcTo) LineTo(javafx.scene.shape.LineTo) InnerShadow(javafx.scene.effect.InnerShadow) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane)

Example 2 with ClosePath

use of javafx.scene.shape.ClosePath in project Board-Instrumentation-Framework by intel.

the class ShapeConverter method processPath.

private static Path processPath(final List<String> PATH_LIST, final PathReader READER) {
    final Path PATH = new Path();
    PATH.setFillRule(FillRule.EVEN_ODD);
    while (!PATH_LIST.isEmpty()) {
        if ("M".equals(READER.read())) {
            PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY()));
        } else if ("C".equals(READER.read())) {
            PATH.getElements().add(new CubicCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("Q".equals(READER.read())) {
            PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("H".equals(READER.read())) {
            PATH.getElements().add(new HLineTo(READER.nextX()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new VLineTo(READER.nextY()));
        } else if ("A".equals(READER.read())) {
            PATH.getElements().add(new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false));
        } else if ("Z".equals(READER.read())) {
            PATH.getElements().add(new ClosePath());
        }
    }
    return PATH;
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) SVGPath(javafx.scene.shape.SVGPath) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) VLineTo(javafx.scene.shape.VLineTo) HLineTo(javafx.scene.shape.HLineTo) ArcTo(javafx.scene.shape.ArcTo) QuadCurveTo(javafx.scene.shape.QuadCurveTo) VLineTo(javafx.scene.shape.VLineTo) HLineTo(javafx.scene.shape.HLineTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 3 with ClosePath

use of javafx.scene.shape.ClosePath in project Board-Instrumentation-Framework by intel.

the class SplitFlapSkin method resize.

// ******************** Resizing ******************************************
private void resize() {
    width = getSkinnable().getWidth();
    height = getSkinnable().getHeight();
    if (getSkinnable().isKeepAspect()) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }
    }
    if (width > 0 && height > 0) {
        pane.setMaxSize(width, height);
        flapHeight = 0.49206349206349204 * height;
        fixtureRight.setPrefSize(0.0476190476 * height, 0.164021164021164 * height);
        fixtureRight.setTranslateX(width - 0.0476190476 * height);
        fixtureRight.setTranslateY(0.41798941798941797 * height);
        fixtureRight.setCacheShape(true);
        fixtureLeft.setPrefSize(0.0476190476 * height, 0.164021164021164 * height);
        fixtureLeft.setTranslateY(0.41798941798941797 * height);
        fixtureLeft.setCacheShape(true);
        if (width > height && width > 0 && height > 0) {
            final Path UPPER = new Path();
            UPPER.setFillRule(FillRule.EVEN_ODD);
            UPPER.getElements().add(new MoveTo(width, 0.0));
            UPPER.getElements().add(new LineTo(width, 0.4074074074074074 * height));
            UPPER.getElements().add(new LineTo(width - 0.0582010582 * height, 0.4074074074074074 * height));
            UPPER.getElements().add(new LineTo(width - 0.0582010582 * height, 0.49206349206349204 * height));
            UPPER.getElements().add(new LineTo(0.0582010582 * height, 0.49206349206349204 * height));
            UPPER.getElements().add(new LineTo(0.0582010582 * height, 0.4074074074074074 * height));
            UPPER.getElements().add(new LineTo(0.0, 0.4074074074074074 * height));
            UPPER.getElements().add(new LineTo(0.0, 0.0));
            UPPER.getElements().add(new LineTo(width, 0.0));
            UPPER.getElements().add(new ClosePath());
            final String UPPER_SVG = ShapeConverter.shapeToSvgString(UPPER);
            final Path LOWER = new Path();
            LOWER.setFillRule(FillRule.EVEN_ODD);
            LOWER.getElements().add(new MoveTo(width, height));
            LOWER.getElements().add(new LineTo(width, 0.5925925925925926 * height));
            LOWER.getElements().add(new LineTo(width - 0.0582010582 * height, 0.5925925925925926 * height));
            LOWER.getElements().add(new LineTo(width - 0.0582010582 * height, 0.5079365079365079 * height));
            LOWER.getElements().add(new LineTo(0.0582010582 * height, 0.5079365079365079 * height));
            LOWER.getElements().add(new LineTo(0.0582010582 * height, 0.5925925925925926 * height));
            LOWER.getElements().add(new LineTo(0.0, 0.5925925925925926 * height));
            LOWER.getElements().add(new LineTo(0.0, height));
            LOWER.getElements().add(new LineTo(width, height));
            LOWER.getElements().add(new ClosePath());
            final String LOWER_SVG = ShapeConverter.shapeToSvgString(LOWER);
            upperBackground.setStyle(new StringBuilder("-fx-shape:").append("\"").append(UPPER_SVG).append("\";").toString());
            lowerBackground.setStyle(new StringBuilder("-fx-shape:").append("\"").append(LOWER_SVG).append("\";").toString());
            flap.setStyle(new StringBuilder("-fx-shape:").append("\"").append(UPPER_SVG).append("\";").toString());
        }
        upperBackground.setPrefSize(width, flapHeight);
        upperBackground.setCacheShape(true);
        lowerBackground.setPrefSize(width, flapHeight);
        lowerBackground.setTranslateY(0.5079365079365079 * height);
        lowerBackground.setCacheShape(true);
        font = Fonts.bebasNeue(height * 0.9);
        upperBackgroundText.setWidth(width);
        upperBackgroundText.setHeight(flapHeight);
        lowerBackgroundText.setWidth(width);
        lowerBackgroundText.setHeight(flapHeight);
        lowerBackgroundText.setTranslateY(0.5079365079365079 * height);
        flap.setPrefSize(width, flapHeight);
        flap.setCacheShape(true);
        rotateFlap.setPivotY(height * 0.5);
        flapTextFront.setWidth(width);
        flapTextFront.setHeight(flapHeight);
        flapTextBack.setWidth(width);
        flapTextBack.setHeight(flapHeight);
        ctxUpperBackgroundText.setFont(font);
        ctxLowerBackgroundText.setFont(font);
        ctxTextFront.setFont(font);
        ctxTextBack.setFont(font);
        refreshTextCtx();
        innerShadow.setOffsetY(-0.01 * flapHeight);
        innerShadow.setRadius(0.01 * flapHeight);
        innerHighlight.setOffsetY(0.01 * flapHeight);
        innerHighlight.setRadius(0.01 * flapHeight);
        reversedInnerShadow.setOffsetY(-0.01 * 0.4920634921 * height);
        reversedInnerShadow.setRadius(0.01 * 0.4920634921 * height);
        reversedInnerHighlight.setOffsetY(0.01 * 0.4920634921 * height);
        reversedInnerHighlight.setRadius(0.01 * 0.4920634921 * height);
    }
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo)

Example 4 with ClosePath

use of javafx.scene.shape.ClosePath in project tilesfx by HanSolo.

the class HighLowTileSkin method drawTriangle.

private void drawTriangle() {
    MoveTo moveTo = new MoveTo(0.056 * size, 0.032 * size);
    CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size, 0.028 * size, 0.064 * size, 0.028 * size, 0.068 * size, 0.032 * size);
    CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size, 0.032 * size, 0.120 * size, 0.080 * size, 0.12 * size, 0.080 * size);
    CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size, 0.088 * size, 0.124 * size, 0.096 * size, 0.112 * size, 0.096 * size);
    CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size, 0.096 * size, 0.012 * size, 0.096 * size, 0.012 * size, 0.096 * size);
    CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size, -0.004 * size, 0.088 * size, 0.004 * size, 0.080 * size);
    CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size, 0.080 * size, 0.056 * size, 0.032 * size, 0.056 * size, 0.032 * size);
    ClosePath closePath = new ClosePath();
    triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 5 with ClosePath

use of javafx.scene.shape.ClosePath in project tilesfx by HanSolo.

the class LeaderBoardItem method drawTriangle.

private void drawTriangle() {
    MoveTo moveTo = new MoveTo(0, 0.028 * size);
    LineTo lineTo1 = new LineTo(0.022 * size, 0);
    LineTo lineTo2 = new LineTo(0.044 * size, 0.028 * size);
    LineTo lineTo3 = new LineTo(0, 0.028 * size);
    ClosePath closePath = new ClosePath();
    triangle.getElements().setAll(moveTo, lineTo1, lineTo2, lineTo3, closePath);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo)

Aggregations

ClosePath (javafx.scene.shape.ClosePath)15 MoveTo (javafx.scene.shape.MoveTo)15 LineTo (javafx.scene.shape.LineTo)11 CubicCurveTo (javafx.scene.shape.CubicCurveTo)9 Path (javafx.scene.shape.Path)6 PathElement (javafx.scene.shape.PathElement)4 Point (eu.hansolo.tilesfx.tools.Point)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ArcTo (javafx.scene.shape.ArcTo)2 QuadCurveTo (javafx.scene.shape.QuadCurveTo)2 Text (javafx.scene.text.Text)2 IntStream (java.util.stream.IntStream)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 Point2D (javafx.geometry.Point2D)1 InnerShadow (javafx.scene.effect.InnerShadow)1 Pane (javafx.scene.layout.Pane)1 Color (javafx.scene.paint.Color)1