Search in sources :

Example 1 with Arc

use of javafx.scene.shape.Arc in project JFoenix by jfoenixadmin.

the class JFXSpinner method initialize.

private void initialize() {
    blueColor = Color.valueOf("#4285f4");
    redColor = Color.valueOf("#db4437");
    yellowColor = Color.valueOf("#f4b400");
    greenColor = Color.valueOf("#0F9D58");
    arc = new Arc(0, 0, 12, 12, 0, 360);
    arc.setFill(Color.TRANSPARENT);
    arc.setStrokeWidth(3);
    arc.getStyleClass().addAll("arc");
    arc.radiusXProperty().bindBidirectional(radius);
    arc.radiusYProperty().bindBidirectional(radius);
    getChildren().add(arc);
    this.minWidthProperty().bind(Bindings.createDoubleBinding(() -> {
        return getRadius() * 2 + arc.getStrokeWidth() + 5;
    }, radius, arc.strokeWidthProperty()));
    this.maxWidthProperty().bind(Bindings.createDoubleBinding(() -> {
        return getRadius() * 2 + arc.getStrokeWidth() + 5;
    }, radius, arc.strokeWidthProperty()));
    this.minHeightProperty().bind(Bindings.createDoubleBinding(() -> {
        return getRadius() * 2 + arc.getStrokeWidth() + 5;
    }, radius, arc.strokeWidthProperty()));
    this.maxHeightProperty().bind(Bindings.createDoubleBinding(() -> {
        return getRadius() * 2 + arc.getStrokeWidth() + 5;
    }, radius, arc.strokeWidthProperty()));
}
Also used : Arc(javafx.scene.shape.Arc)

Example 2 with Arc

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

the class AvGauge method initGraphics.

private void initGraphics() {
    border = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.5);
    border.setFill(Color.TRANSPARENT);
    border.setStroke(borderColor.get());
    outerBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 90, 0);
    outerBar.setType(ArcType.ROUND);
    outerBar.setFill(outerBarColor.get());
    innerBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.83333 * 0.5, PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.83333 * 0.5, 90, 0);
    innerBar.setType(ArcType.ROUND);
    innerBar.setFill(innerBarColor.get());
    separator = new Line(PREFERRED_WIDTH * 0.5, 1, PREFERRED_WIDTH * 0.5, 0.16667 * PREFERRED_HEIGHT);
    separator.setStroke(separatorColor.get());
    separator.setFill(Color.TRANSPARENT);
    background = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.66667 * 0.5);
    background.setFill(backgroundColor.get());
    outerValueText = new Text(String.format(Locale.US, "%." + decimals + "f", getOuterValue()));
    outerValueText.setFont(Fonts.latoLight(PREFERRED_WIDTH * 0.27333));
    outerValueText.setFill(outerValueTextColor.get());
    innerValueText = new Text(String.format(Locale.US, "%." + decimals + "f", getInnerValue()));
    innerValueText.setFont(Fonts.latoLight(PREFERRED_WIDTH * 0.08));
    innerValueText.setFill(innerValueTextColor.get());
    titleText = new Text("");
    titleText.setFont(Fonts.latoLight(PREFERRED_WIDTH * 0.08));
    titleText.setFill(titleTextColor.get());
    pane = new Pane();
    pane.getChildren().setAll(border, outerBar, innerBar, separator, background, outerValueText, innerValueText, titleText);
    getChildren().setAll(pane);
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Arc(javafx.scene.shape.Arc) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane)

Example 3 with Arc

use of javafx.scene.shape.Arc in project org.csstudio.display.builder by kasemir.

the class ArcRepresentation method createJFXNode.

@Override
public Arc createJFXNode() throws Exception {
    final Arc arc = new Arc();
    updateColors();
    updateAngles();
    return arc;
}
Also used : Arc(javafx.scene.shape.Arc)

Example 4 with Arc

use of javafx.scene.shape.Arc in project latexdraw by arnobl.

the class ViewArrowableTraitArc method clipPath.

@Override
protected void clipPath(final Arc arc) {
    if (!model.getArcStyle().supportArrow()) {
        arc.setClip(null);
        return;
    }
    final double width = Math.max(arc.getRadiusX() * 2d, 1d);
    double sAngle = model.getAngleStart();
    double eAngle = model.getAngleEnd();
    IArrow arr = model.getArrowAt(1);
    final double gap = Math.atan(arr.getArrowShapeLength() / width);
    if (arr.getArrowStyle().isReducingShape()) {
        if (eAngle > sAngle) {
            eAngle -= gap;
        } else {
            eAngle += gap;
        }
    }
    arr = model.getArrowAt(0);
    if (arr.getArrowStyle().isReducingShape()) {
        if (eAngle > sAngle) {
            sAngle += gap;
        } else {
            sAngle -= gap;
        }
    }
    sAngle = Math.toDegrees(sAngle % (2d * Math.PI));
    eAngle = Math.toDegrees(eAngle % (2d * Math.PI));
    if (MathUtils.INST.equalsDouble(sAngle, eAngle)) {
        eAngle += 0.1;
    }
    final Arc clip = new Arc(arc.getCenterX(), arc.getCenterY(), arc.getRadiusX(), arc.getRadiusY(), sAngle, eAngle - sAngle);
    clip.setType(arc.getType());
    clip.setStrokeWidth(arc.getStrokeWidth());
    arc.setClip(clip);
}
Also used : ICircleArc(net.sf.latexdraw.models.interfaces.shape.ICircleArc) Arc(javafx.scene.shape.Arc) IArrow(net.sf.latexdraw.models.interfaces.shape.IArrow)

Example 5 with Arc

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

the class GaugeSparkLineTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    averagingListener = o -> handleEvents("AVERAGING_PERIOD");
    highlightSectionListener = o -> handleEvents("HIGHLIGHT_SECTIONS");
    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());
    if (tile.isAutoScale())
        tile.calcAutoScale();
    niceScaleY = new NiceScale(tile.getMinValue(), tile.getMaxValue());
    niceScaleY.setMaxTicks(5);
    tickLineColor = Color.color(Tile.FOREGROUND.getRed(), Tile.FOREGROUND.getGreen(), Tile.FOREGROUND.getBlue(), 0.50);
    horizontalTickLines = new ArrayList<>(5);
    tickLabelsY = new ArrayList<>(5);
    for (int i = 0; i < 5; i++) {
        Line hLine = new Line(0, 0, 0, 0);
        hLine.getStrokeDashArray().addAll(1.0, 2.0);
        hLine.setStroke(Color.TRANSPARENT);
        horizontalTickLines.add(hLine);
        Text tickLabelY = new Text("");
        tickLabelY.setFill(Color.TRANSPARENT);
        tickLabelsY.add(tickLabelY);
    }
    gradientLookup = new GradientLookup(tile.getGradientStops());
    low = tile.getMaxValue();
    high = tile.getMinValue();
    stdDeviation = 0;
    movingAverage = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList = new LinkedList<>();
    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4)
        throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");
    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);
    titleText = new Text(tile.getTitle());
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    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.CENTER);
    averageText = new Text(String.format(locale, formatString, tile.getAverage()));
    averageText.setFill(Tile.FOREGROUND);
    Helper.enableNode(averageText, tile.isAverageVisible());
    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());
    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());
    stdDeviationArea = new Rectangle();
    Helper.enableNode(stdDeviationArea, tile.isAverageVisible());
    averageLine = new Line();
    averageLine.setStroke(Tile.FOREGROUND);
    averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005);
    Helper.enableNode(averageLine, tile.isAverageVisible());
    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1; i < noOfDatapoints; i++) {
        pathElements.add(i, new LineTo());
    }
    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);
    dot = new Circle();
    dot.setFill(tile.getBarColor());
    sectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionCtx = sectionCanvas.getGraphicsContext2D();
    highlightSectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    highlightSectionCtx = sectionCanvas.getGraphicsContext2D();
    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, tile.getStartAngle() - 45, tile.getAngleRange());
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(tile.getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.125);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);
    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, tile.getStartAngle() - 135, 0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(tile.getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.125);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);
    minValueText = new Text();
    maxValueText = new Text();
    getPane().getChildren().addAll(sectionCanvas, highlightSectionCanvas, barBackground, bar, minValueText, maxValueText, titleText, valueUnitFlow, stdDeviationArea, averageLine, sparkLine, dot, averageText, timeSpanText, text);
    getPane().getChildren().addAll(horizontalTickLines);
    getPane().getChildren().addAll(tickLabelsY);
}
Also used : Path(javafx.scene.shape.Path) Circle(javafx.scene.shape.Circle) LineTo(javafx.scene.shape.LineTo) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) Text(javafx.scene.text.Text) CacheHint(javafx.scene.CacheHint) Point(eu.hansolo.tilesfx.tools.Point) Line(javafx.scene.shape.Line) Arc(javafx.scene.shape.Arc) MoveTo(javafx.scene.shape.MoveTo) NiceScale(eu.hansolo.tilesfx.tools.NiceScale) TextFlow(javafx.scene.text.TextFlow) GradientLookup(eu.hansolo.tilesfx.tools.GradientLookup)

Aggregations

Arc (javafx.scene.shape.Arc)24 ICircleArc (net.sf.latexdraw.models.interfaces.shape.ICircleArc)10 Text (javafx.scene.text.Text)8 Pane (javafx.scene.layout.Pane)5 Line (javafx.scene.shape.Line)5 Rectangle (javafx.scene.shape.Rectangle)5 Theory (org.junit.experimental.theories.Theory)5 Circle (javafx.scene.shape.Circle)4 TextFlow (javafx.scene.text.TextFlow)4 Rotate (javafx.scene.transform.Rotate)4 Canvas (javafx.scene.canvas.Canvas)3 DropShadow (javafx.scene.effect.DropShadow)3 Path (javafx.scene.shape.Path)3 Test (org.junit.Test)3 Section (eu.hansolo.tilesfx.Section)2 TimeSection (eu.hansolo.tilesfx.TimeSection)2 CacheHint (javafx.scene.CacheHint)2 Group (javafx.scene.Group)2 Tooltip (javafx.scene.control.Tooltip)2 InnerShadow (javafx.scene.effect.InnerShadow)2