Java 类javafx.scene.shape.ClosePath 实例源码

项目:LivroJavaComoProgramar10Edicao    文件:PolyShapesController.java   
@FXML
private void drawingAreaMouseClicked(MouseEvent e)
{
   polyline.getPoints().addAll(e.getX(), e.getY());
   polygon.getPoints().addAll(e.getX(), e.getY());

   // if path is empty, move to first click position and close path
   if (path.getElements().isEmpty())
   {
      path.getElements().add(new MoveTo(e.getX(), e.getY()));
      path.getElements().add(new ClosePath());      
   }
   else // insert a new path segment before the ClosePath element
   {
      // create an arc segment and insert it in the path
      ArcTo arcTo = new ArcTo();
      arcTo.setX(e.getX());
      arcTo.setY(e.getY());
      arcTo.setRadiusX(100.0);
      arcTo.setRadiusY(100.0);
      arcTo.setSweepFlag(sweepFlag);
      sweepFlag = !sweepFlag;
      path.getElements().add(path.getElements().size() - 1, arcTo);
   }
}
项目:tilesfx    文件:SmoothAreaChartTileSkin.java   
private void drawChart(final List<Point> POINTS) {
    if (POINTS.isEmpty()) return;
    Point[] points = smoothing ? Helper.subdividePoints(POINTS.toArray(new Point[0]), 8) : POINTS.toArray(new Point[0]);

    fillPath.getElements().clear();
    fillPath.getElements().add(new MoveTo(0, height));

    strokePath.getElements().clear();
    strokePath.getElements().add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point p : points) {
        fillPath.getElements().add(new LineTo(p.getX(), p.getY()));
        strokePath.getElements().add(new LineTo(p.getX(), p.getY()));
    }

    fillPath.getElements().add(new LineTo(width, height));
    fillPath.getElements().add(new LineTo(0, height));
    fillPath.getElements().add(new ClosePath());

    if (dataPointsVisible) { drawDataPoints(POINTS, tile.isFillWithGradient() ? tile.getGradientStops().get(0).getColor() : tile.getBarColor()); }
}
项目:javaone2016    文件:BadgeOutline.java   
private void clearSmallPolygons(Path... paths){
    validPaths = new ArrayList<>();
    Point2D p0 = Point2D.ZERO;
    for (Path path : paths) {
        for (PathElement elem : path.getElements()) {
            if (elem instanceof MoveTo) {
                elements = new ArrayList<>();
                elements.add(elem);
                listPoints = new ArrayList<>();
                p0 = new Point2D(((MoveTo)elem).getX(), ((MoveTo)elem).getY());
                listPoints.add(p0);
            } else if (elem instanceof CubicCurveTo) {
                elements.add(elem);
                Point2D ini = listPoints.size() > 0 ? listPoints.get(listPoints.size() - 1) : p0;
                listPoints.addAll(evalCubicCurve((CubicCurveTo) elem, ini, POINTS_CURVE));
            } else if (elem instanceof ClosePath) {
                elements.add(elem);
                listPoints.add(p0);
                if (Math.abs(calculateArea()) > MINIMUM_AREA) {
                    validPaths.add(new Path(elements));
                }
            } 
        }
    }
}
项目:javaone2016    文件:BadgeOutline.java   
private String pathsToSVGPath() {
    final StringBuilder sb = new StringBuilder();
    for (Path path : validPaths) {
        for (PathElement element : path.getElements()) {
            if (element instanceof MoveTo) {
                sb.append("M ").append(((MoveTo) element).getX()).append(" ")
                               .append(((MoveTo) element).getY());
            } else if (element instanceof CubicCurveTo) {
                CubicCurveTo curve = (CubicCurveTo) element;
                sb.append(" C ")
                        .append(curve.getControlX1()).append(" ").append(curve.getControlY1()).append(" ")
                        .append(curve.getControlX2()).append(" ").append(curve.getControlY2()).append(" ")
                        .append(curve.getX()).append(" ").append(curve.getY());
            } else if (element instanceof ClosePath) {
                sb.append(" Z ");
            }
        }
    }
    return sb.toString();
}
项目:Medusa    文件:SectionSkin.java   
private void createNeedle() {
    double needleWidth  = size * 0.04;
    double needleHeight = size * 0.4675;
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.4375 * needleWidth, 0.0,
                                              0.5 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0,
                                              0.6875 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.6875 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0,
                                      needle.getLayoutBounds().getMaxX(), 0,
                                      false, CycleMethod.NO_CYCLE,
                                      new Stop(0.0, gauge.getNeedleColor().darker()),
                                      new Stop(0.5, gauge.getNeedleColor()),
                                      new Stop(1.0, gauge.getNeedleColor().darker())));
}
项目:Medusa    文件:AmpSkin.java   
private void drawAverage() {
    double scaledWidth = width * 1.106;
    double centerX     = width * 0.5;
    double centerY     = height * 0.77;
    double minValue    = gauge.getMinValue();
    // Draw average
    average.getElements().clear();
    double averageAngle = START_ANGLE - (gauge.getAverage() - minValue) * angleStep;
    double averageSize  = Helper.clamp(2.0, 2.5, 0.01 * scaledWidth);
    double sinValue     = Math.sin(Math.toRadians(averageAngle));
    double cosValue     = Math.cos(Math.toRadians(averageAngle));
    average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
    cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
    average.getElements().add(new LineTo(centerX + scaledWidth * 0.35 * sinValue, centerY + scaledWidth * 0.35 * cosValue));
    average.getElements().add(new ClosePath());
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
项目:bpmgauge    文件:Segment.java   
private void initGraphics() {
    moveTo     = new MoveTo();
    upperLeft  = new LineTo();
    upperRight = new LineTo();
    lowerRight = new LineTo();
    lowerLeft  = new LineTo();

    path = new Path();
    path.getElements().add(moveTo);
    path.getElements().add(upperLeft);
    path.getElements().add(upperRight);
    path.getElements().add(lowerRight);
    path.getElements().add(lowerLeft);
    path.getElements().add(new ClosePath());

    path.getStyleClass().add("segment");

    pane = new Pane(path);
    pane.getStyleClass().add("segment");

    getChildren().setAll(pane);
}
项目:grapheditor    文件:ArrowHead.java   
/**
 * Draws the arrow-head for its current size and position values.
 */
public void draw() {

    getElements().clear();

    getElements().add(new MoveTo(x, y + length / 2));
    getElements().add(new LineTo(x + width / 2, y - length / 2));

    if (radius > 0) {
        final ArcTo arcTo = new ArcTo();
        arcTo.setX(x - width / 2);
        arcTo.setY(y - length / 2);
        arcTo.setRadiusX(radius);
        arcTo.setRadiusY(radius);
        arcTo.setSweepFlag(true);
        getElements().add(arcTo);
    } else {
        getElements().add(new LineTo(x - width / 2, y - length / 2));
    }

    getElements().add(new ClosePath());
}
项目:marlin-fx    文件:ShapeOutlineBugRectangle.java   
@Override
public void start(Stage stage) throws Exception {
    Path shape = new Path(new MoveTo(450, 450),
               new LineTo(-SIZE, -SIZE),
               new LineTo(0, -2 * SIZE),
               new LineTo(SIZE, -SIZE),
               new LineTo(450, 450),
               new ClosePath());

    shape.setFill(Color.BLUE);
    shape.setStroke(Color.RED);
    shape.setStrokeWidth(2.0);
    shape.getStrokeDashArray().addAll(10.0, 5.0);

    Pane root = new Pane();
    root.getChildren().add(shape);

    stage.setScene(new Scene(root, 900, 900));
    stage.show();
}
项目:FXImgurUploader    文件:ShapeConverter.java   
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;
}
项目:graph-editor    文件:ArrowHead.java   
/**
 * Draws the arrow-head for its current size and position values.
 */
public void draw() {

    getElements().clear();

    getElements().add(new MoveTo(x, y + length / 2));
    getElements().add(new LineTo(x + width / 2, y - length / 2));

    if (radius > 0) {
        final ArcTo arcTo = new ArcTo();
        arcTo.setX(x - width / 2);
        arcTo.setY(y - length / 2);
        arcTo.setRadiusX(radius);
        arcTo.setRadiusY(radius);
        arcTo.setSweepFlag(true);
        getElements().add(arcTo);
    } else {
        getElements().add(new LineTo(x - width / 2, y - length / 2));
    }

    getElements().add(new ClosePath());
}
项目:Enzo    文件:ShapeConverter.java   
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;
}
项目:marathonv5    文件:PathSample.java   
public PathSample() {
    super(180,90);
    // Create path shape - square
    Path path1 = new Path();
    path1.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(65),
            new VLineTo(65),
            new LineTo(25, 65),
            new ClosePath()         
            );
    path1.setFill(null);
    path1.setStroke(Color.RED);
    path1.setStrokeWidth(2);

    // Create path shape - curves
    Path path2 = new Path();
    path2.getElements().addAll(
            new MoveTo(100, 45),
            new CubicCurveTo(120, 20, 130, 80, 140, 45),
            new QuadCurveTo(150, 0, 160, 45),
            new ArcTo(20, 40, 0, 180, 45, true, true)
            );
    path2.setFill(null);
    path2.setStroke(Color.DODGERBLUE);
    path2.setStrokeWidth(2);

    // show the path shapes;
    getChildren().add(new Group(path1, path2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty())
    );
    // END REMOVE ME
}
项目:marathonv5    文件:PathSample.java   
public PathSample() {
    super(180,90);
    // Create path shape - square
    Path path1 = new Path();
    path1.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(65),
            new VLineTo(65),
            new LineTo(25, 65),
            new ClosePath()         
            );
    path1.setFill(null);
    path1.setStroke(Color.RED);
    path1.setStrokeWidth(2);

    // Create path shape - curves
    Path path2 = new Path();
    path2.getElements().addAll(
            new MoveTo(100, 45),
            new CubicCurveTo(120, 20, 130, 80, 140, 45),
            new QuadCurveTo(150, 0, 160, 45),
            new ArcTo(20, 40, 0, 180, 45, true, true)
            );
    path2.setFill(null);
    path2.setStroke(Color.DODGERBLUE);
    path2.setStrokeWidth(2);

    // show the path shapes;
    getChildren().add(new Group(path1, path2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty())
    );
    // END REMOVE ME
}
项目:smoothcharts    文件:SmoothedChart.java   
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
    if (fillElements.isEmpty()) return;
    // as we do not have direct access to the data, first recreate the list of all the data points we have
    final Point2D[] dataPoints = new Point2D[strokeElements.size()];
    for (int i = 0; i < strokeElements.size(); i++) {
        final PathElement element = strokeElements.get(i);
        if (element instanceof MoveTo) {
            final MoveTo move = (MoveTo) element;
            dataPoints[i] = new Point2D(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            final LineTo line = (LineTo) element;
            final double x = line.getX(), y = line.getY();
            dataPoints[i] = new Point2D(x, y);
        }
    }
    double firstX = dataPoints[0].getX();
    double lastX  = dataPoints[dataPoints.length - 1].getX();

    Point2D[] points = Helper.subdividePoints(dataPoints, getSubDivisions());

    fillElements.clear();
    fillElements.add(new MoveTo(firstX, HEIGHT));

    strokeElements.clear();
    strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point2D p : points) {
        if (Double.compare(p.getX(), firstX) >= 0) {
            fillElements.add(new LineTo(p.getX(), p.getY()));
            strokeElements.add(new LineTo(p.getX(), p.getY()));
        }
    }

    fillElements.add(new LineTo(lastX, HEIGHT));
    fillElements.add(new LineTo(0, HEIGHT));
    fillElements.add(new ClosePath());
}
项目:tilesfx    文件:LeaderBoardItem.java   
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);
}
项目:tilesfx    文件:HighLowTileSkin.java   
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);
}
项目:tilesfx    文件:StockTileSkin.java   
private void drawTriangle() {
    MoveTo       moveTo        = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5);
    CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5);
    CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5,  0.080 * size * 0.5);
    CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5);
    CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5);
    CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5);
    CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5);
    ClosePath    closePath     = new ClosePath();
    triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath);
}
项目:tilesfx    文件:SmoothedChart.java   
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
    if (fillElements.isEmpty()) return;
    // as we do not have direct access to the data, first recreate the list of all the data points we have
    final Point[] dataPoints = new Point[strokeElements.size()];
    for (int i = 0; i < strokeElements.size(); i++) {
        final PathElement element = strokeElements.get(i);
        if (element instanceof MoveTo) {
            final MoveTo move = (MoveTo) element;
            dataPoints[i] = new Point(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            final LineTo line = (LineTo) element;
            final double x = line.getX(), y = line.getY();
            dataPoints[i] = new Point(x, y);
        }
    }
    double firstX = dataPoints[0].getX();
    double lastX  = dataPoints[dataPoints.length - 1].getX();

    Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions());

    fillElements.clear();
    fillElements.add(new MoveTo(firstX, HEIGHT));

    strokeElements.clear();
    strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));

    for (Point p : points) {
        if (Double.compare(p.getX(), firstX) >= 0) {
            fillElements.add(new LineTo(p.getX(), p.getY()));
            strokeElements.add(new LineTo(p.getX(), p.getY()));
        }
    }

    fillElements.add(new LineTo(lastX, HEIGHT));
    fillElements.add(new LineTo(0, HEIGHT));
    fillElements.add(new ClosePath());
}
项目:tilesfx    文件:Helper.java   
public static final Path smoothPath(final ObservableList<PathElement> ELEMENTS, final boolean FILLED) {
    if (ELEMENTS.isEmpty()) { return new Path(); }
    final Point[] dataPoints = new Point[ELEMENTS.size()];
    for (int i = 0; i < ELEMENTS.size(); i++) {
        final PathElement element = ELEMENTS.get(i);
        if (element instanceof MoveTo) {
            MoveTo move   = (MoveTo) element;
            dataPoints[i] = new Point(move.getX(), move.getY());
        } else if (element instanceof LineTo) {
            LineTo line   = (LineTo) element;
            dataPoints[i] = new Point(line.getX(), line.getY());
        }
    }
    double                 zeroY               = ((MoveTo) ELEMENTS.get(0)).getY();
    List<PathElement>      smoothedElements    = new ArrayList<>();
    Pair<Point[], Point[]> result              = calcCurveControlPoints(dataPoints);
    Point[]                firstControlPoints  = result.getKey();
    Point[]                secondControlPoints = result.getValue();
    // Start path dependent on filled or not
    if (FILLED) {
        smoothedElements.add(new MoveTo(dataPoints[0].getX(), zeroY));
        smoothedElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY()));
    } else {
        smoothedElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY()));
    }
    // Add curves
    for (int i = 2; i < dataPoints.length; i++) {
        final int ci = i - 1;
        smoothedElements.add(new CubicCurveTo(
            firstControlPoints[ci].getX(), firstControlPoints[ci].getY(),
            secondControlPoints[ci].getX(), secondControlPoints[ci].getY(),
            dataPoints[i].getX(), dataPoints[i].getY()));
    }
    // Close the path if filled
    if (FILLED) {
        smoothedElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY));
        smoothedElements.add(new ClosePath());
    }
    return new Path(smoothedElements);
}
项目:medusademo    文件:InteractiveGaugeSkin.java   
private void drawAverage() {
    double centerX = size * 0.5;
    double centerY = size * 0.5;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (getSkinnable().getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (getSkinnable().getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + size * 0.38 * sinValue, centerY + size * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + size * 0.465 * sinValue, centerY + size * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(getSkinnable().getAverageColor());
    average.setStroke(getSkinnable().getTickMarkColor());
}
项目:Medusa    文件:QuarterSkin.java   
private void drawAverage() {
    double scaledSize = size * 1.95;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.38 * sinValue, centerY + scaledSize * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.465 * sinValue, centerY + scaledSize * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
项目:Medusa    文件:FatClockSkin.java   
private void createHourPointer() {
    double width  = size * 0.09733333;
    double height = size * 0.42066667;
    hour.setCache(false);
    hour.getElements().clear();
    hour.getElements().add(new MoveTo(0.0, 0.0));
    hour.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.884310618066561 * height, 0.0, 0.884310618066561 * height));
    hour.getElements().add(new CubicCurveTo(0.0, 0.9477020602218701 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
    hour.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9477020602218701 * height, width, 0.884310618066561 * height));
    hour.getElements().add(new CubicCurveTo(width, 0.884310618066561 * height, width, 0.0, width, 0.0));
    hour.getElements().add(new LineTo(0.0, 0.0));
    hour.getElements().add(new ClosePath());
    hour.setCache(true);
    hour.setCacheHint(CacheHint.ROTATE);
}
项目:Medusa    文件:FatClockSkin.java   
private void createMinutePointer() {
    double width  = size * 0.09733333;
    double height = size * 0.548;
    minute.setCache(false);
    minute.getElements().clear();
    minute.getElements().add(new MoveTo(0.0, 0.0));
    minute.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.9111922141119222 * height, 0.0, 0.9111922141119222 * height));
    minute.getElements().add(new CubicCurveTo(0.0, 0.9598540145985401 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
    minute.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9598540145985401 * height, width, 0.9111922141119222 * height));
    minute.getElements().add(new CubicCurveTo(width, 0.9111922141119222 * height, width, 0.0, width, 0.0));
    minute.getElements().add(new LineTo(0.0, 0.0));
    minute.getElements().add(new ClosePath());
    minute.setCache(true);
    minute.setCacheHint(CacheHint.ROTATE);
}
项目:Medusa    文件:GaugeSkin.java   
private void drawAverage() {
    double centerX = size * 0.5;
    double centerY = size * 0.5;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + size * 0.38 * sinValue, centerY + size * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + size * 0.465 * sinValue, centerY + size * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
项目:Medusa    文件:BatterySkin.java   
private Path createVerticalBattery(final Path PATH) {
    PATH.getElements().clear();
    PATH.getElements().add(new MoveTo(0.25 * size, 0.175 * size));
    PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.175 * size,
                                                0.25 * size, 0.925 * size,
                                                0.25 * size, 0.925 * size));
    PATH.getElements().add(new CubicCurveTo(0.25 * size, 0.96875 * size,
                                                0.28125 * size, size,
                                                0.325 * size, size));
    PATH.getElements().add(new CubicCurveTo(0.325 * size, size,
                                                0.675 * size, size,
                                                0.675 * size, size));
    PATH.getElements().add(new CubicCurveTo(0.71875 * size, size,
                                                0.75 * size, 0.96875 * size,
                                                0.75 * size, 0.925 * size));
    PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.925 * size,
                                                0.75 * size, 0.175 * size,
                                                0.75 * size, 0.175 * size));
    PATH.getElements().add(new CubicCurveTo(0.75 * size, 0.13125 * size,
                                                0.71875 * size, 0.1 * size,
                                                0.675 * size, 0.1 * size));
    PATH.getElements().add(new CubicCurveTo(0.675 * size, 0.1 * size,
                                                0.6 * size, 0.1 * size,
                                                0.6 * size, 0.1 * size));
    PATH.getElements().add(new LineTo(0.6 * size, 0.0));
    PATH.getElements().add(new LineTo(0.4 * size, 0.0));
    PATH.getElements().add(new LineTo(0.4 * size, 0.1 * size));
    PATH.getElements().add(new CubicCurveTo(0.4 * size, 0.1 * size,
                                                0.325 * size, 0.1 * size,
                                                0.325 * size, 0.1 * size));
    PATH.getElements().add(new CubicCurveTo(0.28125 * size, 0.1 * size,
                                                0.25 * size, 0.13125 * size,
                                                0.25 * size, 0.175 * size));
    PATH.getElements().add(new ClosePath());
    return PATH;
}
项目:Medusa    文件:BatterySkin.java   
private Path createHorizontalBattery(final Path PATH) {
    PATH.getElements().clear();
    PATH.getElements().add(new MoveTo(0.825 * size, 0.25 * size));
    PATH.getElements().add(new CubicCurveTo(0.825 * size, 0.25 * size,
                                                  0.075 * size, 0.25 * size,
                                                  0.075 * size, 0.25 * size));
    PATH.getElements().add(new CubicCurveTo(0.03125 * size, 0.25 * size,
                                                  0.0, 0.28125 * size,
                                                  0.0, 0.325 * size));
    PATH.getElements().add(new CubicCurveTo(0.0, 0.325 * size,
                                                  0.0, 0.675 * size,
                                                  0.0, 0.675 * size));
    PATH.getElements().add(new CubicCurveTo(0.0, 0.71875 * size,
                                                  0.03125 * size, 0.75 * size,
                                                  0.075 * size, 0.75 * size));
    PATH.getElements().add(new CubicCurveTo(0.075 * size, 0.75 * size,
                                                  0.825 * size, 0.75 * size,
                                                  0.825 * size, 0.75 * size));
    PATH.getElements().add(new CubicCurveTo(0.86875 * size, 0.75 * size,
                                                  0.9 * size, 0.71875 * size,
                                                  0.9 * size, 0.675 * size));
    PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.675 * size,
                                                  0.9 * size, 0.6 * size,
                                                  0.9 * size, 0.6 * size));
    PATH.getElements().add(new LineTo(size, 0.6 * size));
    PATH.getElements().add(new LineTo(size, 0.4 * size));
    PATH.getElements().add(new LineTo(0.9 * size, 0.4 * size));
    PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.4 * size,
                                                  0.9 * size, 0.325 * size,
                                                  0.9 * size, 0.325 * size));
    PATH.getElements().add(new CubicCurveTo(0.9 * size, 0.28125 * size,
                                                  0.86875 * size, 0.25 * size,
                                                  0.825 * size, 0.25 * size));
    PATH.getElements().add(new ClosePath());
    return PATH;
}
项目:Medusa    文件:KpiSkin.java   
private void drawNeedle() {
    double needleWidth  = size * 0.064;
    double needleHeight = size * 0.44;
    needle.setCache(false);
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.1875 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.1875 * needleWidth, 0.0,
                                            0.1875 * needleWidth, 0.8727272727272727 * needleHeight,
                                            0.1875 * needleWidth, 0.8727272727272727 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0625 * needleWidth, 0.8818181818181818 * needleHeight,
                                            0.0, 0.9 * needleHeight,
                                            0.0, 0.9272727272727272 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9636363636363636 * needleHeight,
                                            0.25 * needleWidth, needleHeight,
                                            0.5 * needleWidth, needleHeight));
    needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, needleHeight,
                                            needleWidth, 0.9636363636363636 * needleHeight,
                                            needleWidth, 0.9272727272727272 * needleHeight));
    needle.getElements().add(new CubicCurveTo(needleWidth, 0.9 * needleHeight,
                                            0.9375 * needleWidth, 0.8818181818181818 * needleHeight,
                                            0.8125 * needleWidth, 0.8727272727272727 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.8125 * needleWidth, 0.8727272727272727 * needleHeight,
                                            0.8125 * needleWidth, 0.0,
                                            0.8125 * needleWidth, 0.0));
    needle.getElements().add(new LineTo(0.1875 * needleWidth, 0.0));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
项目:marlin-fx    文件:TestNonAARasterization.java   
public static void setPath(Path p, Path2D p2d) {
    p.getElements().clear();
    PathIterator pi = p2d.getPathIterator(null);
    double[] coords = new double[6];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
            case PathIterator.SEG_MOVETO:
                p.getElements().add(new MoveTo(coords[0], coords[1]));
                break;
            case PathIterator.SEG_LINETO:
                p.getElements().add(new LineTo(coords[0], coords[1]));
                break;
            case PathIterator.SEG_QUADTO:
                p.getElements().add(new QuadCurveTo(coords[0], coords[1],
                                                    coords[2], coords[3]));
                break;
            case PathIterator.SEG_CUBICTO:
                p.getElements().add(new CubicCurveTo(coords[0], coords[1],
                                                     coords[2], coords[3],
                                                     coords[4], coords[5]));
                break;
            case PathIterator.SEG_CLOSE:
                p.getElements().add(new ClosePath());
                break;
            default:
                throw new InternalError("unexpected segment type");
        }
        pi.next();
    }
    p.getElements().add(new ClosePath());
}
项目:viskell    文件:DrawWire.java   
/**
 * @param touchPoint that is the center of new active touch area, or null if the mouse
 */
private TouchArea(TouchPoint touchPoint) {
    super();
    this.setLayoutX(DrawWire.this.getEndX());
    this.setLayoutY(DrawWire.this.getEndY());

    this.touchID = touchPoint == null ? -1 : touchPoint.getId();
    this.dragStarted = true;
    this.nearbyAnchors = new ArrayList<>();
    this.lastNearbyUpdate = Point2D.ZERO;

    this.disapperance = new Timeline(new KeyFrame(Duration.millis(2000),
            e -> DrawWire.this.remove(),
            new KeyValue(this.opacityProperty(), 0.3),
            new KeyValue(DrawWire.this.opacityProperty(), 0.2)));

    // a circle with hole is built from a path of round arcs with a very thick stroke
    ArcTo arc1 = new ArcTo(100, 100, 0, 100, 0, true, true);
    ArcTo arc2 = new ArcTo(100, 100, 0, -100, 0, true, true);
    this.getElements().addAll(new MoveTo(-100, 0), arc1, arc2, new ClosePath());
    this.setStroke(Color.web("#0066FF"));
    this.setStrokeType(StrokeType.INSIDE);
    this.setStrokeWidth(90);
    this.setStroke(Color.web("#0066FF"));
    this.setStrokeType(StrokeType.INSIDE);
    this.setOpacity(0);

    if (touchPoint != null) { 
        touchPoint.grab(this);
    }

    this.addEventHandler(TouchEvent.TOUCH_PRESSED, this::handleTouchPress);
    this.addEventHandler(TouchEvent.TOUCH_MOVED, this::handleTouchDrag);
    this.addEventHandler(TouchEvent.TOUCH_RELEASED, this::handleTouchRelease);
    this.addEventHandler(MouseEvent.MOUSE_PRESSED, this::handleMousePress);
    this.addEventHandler(MouseEvent.MOUSE_DRAGGED, this::handleMouseDrag);
    this.addEventHandler(MouseEvent.MOUSE_RELEASED, this::handleMouseRelease);
}
项目:fr.xs.jtk    文件:Text3DHelper.java   
private Path generatePath(){
    Path path = new Path(new MoveTo(list.get(0).x,list.get(0).y));
    list.stream().skip(1).forEach(p->path.getElements().add(new LineTo(p.x,p.y)));
    path.getElements().add(new ClosePath());
    path.setStroke(Color.GREEN);
    // Path must be filled to allow Shape.intersect
    path.setFill(Color.RED);
    return path;
}
项目:JavaFxNodeToSvg    文件:ShapeConverter.java   
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;
}
项目:FX3DAndroid    文件:Text3DHelper.java   
private Path generatePath(){
    Path path = new Path(new MoveTo(list.get(0).x,list.get(0).y));
    stream(list).skip(1).forEach(p->path.getElements().add(new LineTo(p.x,p.y)));
    path.getElements().add(new ClosePath());
    path.setStroke(Color.GREEN);
    // Path must be filled to allow Shape.intersect
    path.setFill(Color.RED);
    return path;
}
项目:agile    文件:Space.java   
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
    bg.getElements().clear();
    buildHpath();
    buildVpath();
    bg.getElements().addAll(hpth);
    bg.getElements().addAll(vpth);
    bg.getElements().add(new ClosePath());
}
项目:kotlinfx-ensemble    文件:PathSample.java   
public PathSample() {
    super(180,90);
    // Create path shape - square
    Path path1 = new Path();
    path1.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(65),
            new VLineTo(65),
            new LineTo(25, 65),
            new ClosePath()         
            );
    path1.setFill(null);
    path1.setStroke(Color.RED);
    path1.setStrokeWidth(2);

    // Create path shape - curves
    Path path2 = new Path();
    path2.getElements().addAll(
            new MoveTo(100, 45),
            new CubicCurveTo(120, 20, 130, 80, 140, 45),
            new QuadCurveTo(150, 0, 160, 45),
            new ArcTo(20, 40, 0, 180, 45, true, true)
            );
    path2.setFill(null);
    path2.setStroke(Color.DODGERBLUE);
    path2.setStrokeWidth(2);

    // show the path shapes;
    getChildren().add(new Group(path1, path2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Path 1 Stroke", path1.strokeProperty()),
            new SimplePropertySheet.PropDesc("Path 2 Stroke", path2.strokeProperty())
    );
    // END REMOVE ME
}
项目:MultiAxisCharts    文件:MultiAxisAreaChart.java   
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
    List<LineTo> constructedPath = new ArrayList<>(getDataSize());
    for (int seriesIndex = 0; seriesIndex < getDataSize(); seriesIndex++) {
        MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
        DoubleProperty seriesYAnimMultiplier = seriesYMultiplierMap.get(series);
        double lastX = 0;
        final ObservableList<Node> children = ((Group) series.getNode()).getChildren();
        ObservableList<PathElement> seriesLine = ((Path) children.get(1)).getElements();
        ObservableList<PathElement> fillPath = ((Path) children.get(0)).getElements();
        seriesLine.clear();
        fillPath.clear();
        constructedPath.clear();
        for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(series); it.hasNext();) {
            Data<X, Y> item = it.next();
            double x = getXAxis().getDisplayPosition(item.getCurrentX());

            double y = -1;
            if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
                y = getY1Axis().getDisplayPosition(getY1Axis().toRealValue(
                        getY1Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
            } else {
                if (getY2Axis() != null) {
                    if (getY2Axis().isVisible()) {
                        y = getY2Axis().getDisplayPosition(getY2Axis().toRealValue(
                                getY2Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
                    } else {
                        continue;
                    }
                } else {
                    throw new NullPointerException("Y2 axis is not defined.");
                }
            }

            constructedPath.add(new LineTo(x, y));
            if (Double.isNaN(x) || Double.isNaN(y)) {
                continue;
            }
            lastX = x;
            Node symbol = item.getNode();
            if (symbol != null) {
                final double w = symbol.prefWidth(-1);
                final double h = symbol.prefHeight(-1);
                symbol.resizeRelocate(x - (w / 2), y - (h / 2), w, h);
            }
        }

        if (!constructedPath.isEmpty()) {
            Collections.sort(constructedPath, (e1, e2) -> Double.compare(e1.getX(), e2.getX()));
            LineTo first = constructedPath.get(0);

            final double displayYPos = first.getY();
            final double numericYPos = getY1Axis().toNumericValue(getY1Axis().getValueForDisplay(displayYPos));

            // RT-34626: We can't always use getZeroPosition(), as it may be the case
            // that the zero position of the y-axis is not visible on the chart. In these
            // cases, we need to use the height between the point and the y-axis line.
            final double yAxisZeroPos = getY1Axis().getZeroPosition();
            final boolean isYAxisZeroPosVisible = !Double.isNaN(yAxisZeroPos);
            final double yAxisHeight = getY1Axis().getHeight();
            final double yFillPos = isYAxisZeroPosVisible ? yAxisZeroPos
                    : numericYPos < 0 ? numericYPos - yAxisHeight : yAxisHeight;

            seriesLine.add(new MoveTo(first.getX(), displayYPos));
            fillPath.add(new MoveTo(first.getX(), yFillPos));

            seriesLine.addAll(constructedPath);
            fillPath.addAll(constructedPath);
            fillPath.add(new LineTo(lastX, yFillPos));
            fillPath.add(new ClosePath());
        }
    }
}
项目:tilesfx    文件:GaugeTileSkin.java   
private void drawNeedle() {
    double needleWidth  = size * 0.05;
    double needleHeight = size * 0.3325;
    needle.setCache(false);

    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.25 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.25 * needleWidth, 0.9022556390977443 * needleHeight,
                                              0.35 * needleWidth, 0.8872180451127819 * needleHeight,
                                              0.5 * needleWidth, 0.8872180451127819 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.8872180451127819 * needleHeight,
                                              0.75 * needleWidth, 0.9022556390977443 * needleHeight,
                                              0.75 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, 0.9473684210526315 * needleHeight,
                                              0.65 * needleWidth, 0.9624060150375939 * needleHeight,
                                              0.5 * needleWidth, 0.9624060150375939 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.9624060150375939 * needleHeight,
                                              0.25 * needleWidth, 0.9473684210526315 * needleHeight,
                                              0.25 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.getElements().add(new MoveTo(0.0, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9699248120300752 * needleHeight,
                                              0.2 * needleWidth, needleHeight,
                                              0.5 * needleWidth, needleHeight));
    needle.getElements().add(new CubicCurveTo(0.8 * needleWidth, needleHeight,
                                              needleWidth, 0.9699248120300752 * needleHeight,
                                              needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(needleWidth, 0.8947368421052632 * needleHeight,
                                              0.85 * needleWidth, 0.8646616541353384 * needleHeight,
                                              0.65 * needleWidth, 0.849624060150376 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.849624060150376 * needleHeight,
                                              0.65 * needleWidth, 0.022556390977443608 * needleHeight,
                                              0.65 * needleWidth, 0.022556390977443608 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.007518796992481203 * needleHeight,
                                              0.6 * needleWidth, 0.0,
                                              0.5 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.4 * needleWidth, 0.0,
                                              0.35 * needleWidth, 0.007518796992481203 * needleHeight,
                                              0.35 * needleWidth, 0.022556390977443608 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.022556390977443608 * needleHeight,
                                              0.35 * needleWidth, 0.849624060150376 * needleHeight,
                                              0.35 * needleWidth, 0.849624060150376 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.15 * needleWidth, 0.8646616541353384 * needleHeight,
                                              0.0, 0.8947368421052632 * needleHeight,
                                              0.0, 0.924812030075188 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
项目:tilesfx    文件:GaugeTileSkin.java   
private void drawAlertIcon() {
    alertIcon.setCache(false);
    double iconWidth  = size * 0.155;
    double iconHeight = size * 0.135;
    alertIcon.getElements().clear();
    alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.3 * iconHeight,
                                                 0.4684873949579832 * iconWidth, 0.2714285714285714 * iconHeight,
                                                 0.5 * iconWidth, 0.2714285714285714 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.2714285714285714 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.3 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.6 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.6 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.6357142857142857 * iconHeight,
                                                 0.5315126050420168 * iconWidth, 0.6666666666666666 * iconHeight,
                                                 0.5 * iconWidth, 0.6666666666666666 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.6666666666666666 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.6357142857142857 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.6 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.6 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.7642857142857142 * iconHeight,
                                                 0.4684873949579832 * iconWidth, 0.7333333333333333 * iconHeight,
                                                 0.5 * iconWidth, 0.7333333333333333 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.7333333333333333 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.7642857142857142 * iconHeight,
                                                 0.5588235294117647 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.8380952380952381 * iconHeight,
                                                 0.5315126050420168 * iconWidth, 0.8666666666666667 * iconHeight,
                                                 0.5 * iconWidth, 0.8666666666666667 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.8666666666666667 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.8380952380952381 * iconHeight,
                                                 0.4411764705882353 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.getElements().add(new MoveTo(0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.523109243697479 * iconWidth, -0.011904761904761904 * iconHeight,
                                                 0.47689075630252103 * iconWidth, -0.011904761904761904 * iconHeight,
                                                 0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight,
                                                 0.012605042016806723 * iconWidth, 0.9 * iconHeight,
                                                 0.012605042016806723 * iconWidth, 0.9 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(-0.014705882352941176 * iconWidth, 0.9547619047619048 * iconHeight,
                                                 0.0063025210084033615 * iconWidth, iconHeight,
                                                 0.06302521008403361 * iconWidth, iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.06302521008403361 * iconWidth, iconHeight,
                                                 0.9369747899159664 * iconWidth, iconHeight,
                                                 0.9369747899159664 * iconWidth, iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.9936974789915967 * iconWidth, iconHeight,
                                                 1.0147058823529411 * iconWidth, 0.9547619047619048 * iconHeight,
                                                 0.9873949579831933 * iconWidth, 0.9 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.9873949579831933 * iconWidth, 0.9 * iconHeight,
                                                 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight,
                                                 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.setCache(true);
    alertIcon.setCacheHint(CacheHint.SPEED);
}
项目:Medusa    文件:DBClockSkin.java   
private void createSecondPointer() {
    double width  = size * 0.11866667;
    double height = size * 0.46266667;
    second.setCache(false);
    second.getElements().clear();
    second.getElements().add(new MoveTo(0.1348314606741573 * width, 0.4365994236311239 * height));
    second.getElements().add(new CubicCurveTo(0.1348314606741573 * width, 0.38328530259365995 * height,
                                              0.29775280898876405 * width, 0.3414985590778098 * height,
                                              0.5 * width, 0.3414985590778098 * height));
    second.getElements().add(new CubicCurveTo(0.702247191011236 * width, 0.3414985590778098 * height,
                                              0.8651685393258427 * width, 0.38328530259365995 * height,
                                              0.8651685393258427 * width, 0.4365994236311239 * height));
    second.getElements().add(new CubicCurveTo(0.8651685393258427 * width, 0.4884726224783862 * height,
                                              0.702247191011236 * width, 0.5302593659942363 * height,
                                              0.5 * width, 0.5302593659942363 * height));
    second.getElements().add(new CubicCurveTo(0.29775280898876405 * width, 0.5302593659942363 * height,
                                              0.1348314606741573 * width, 0.4884726224783862 * height,
                                              0.1348314606741573 * width, 0.4365994236311239 * height));
    second.getElements().add(new ClosePath());
    second.getElements().add(new MoveTo(0.0, 0.4365994236311239 * height));
    second.getElements().add(new CubicCurveTo(0.0, 0.5 * height,
                                              0.1853932584269663 * width, 0.553314121037464 * height,
                                              0.42134831460674155 * width, 0.5634005763688761 * height));
    second.getElements().add(new CubicCurveTo(0.42134831460674155 * width, 0.5634005763688761 * height,
                                              0.398876404494382 * width, height,
                                              0.398876404494382 * width, height));
    second.getElements().add(new LineTo(0.601123595505618 * width, height));
    second.getElements().add(new CubicCurveTo(0.601123595505618 * width, height,
                                              0.5786516853932584 * width, 0.5634005763688761 * height,
                                              0.5786516853932584 * width, 0.5634005763688761 * height));
    second.getElements().add(new CubicCurveTo(0.8146067415730337 * width, 0.553314121037464 * height,
                                              width, 0.5 * height,
                                              width, 0.4365994236311239 * height));
    second.getElements().add(new CubicCurveTo(width, 0.3703170028818444 * height,
                                              0.8089887640449438 * width, 0.3170028818443804 * height,
                                              0.5617977528089888 * width, 0.30835734870317005 * height));
    second.getElements().add(new CubicCurveTo(0.5617977528089888 * width, 0.30835734870317005 * height,
                                              0.5449438202247191 * width, 0.0,
                                              0.5449438202247191 * width, 0.0));
    second.getElements().add(new LineTo(0.4550561797752809 * width, 0.0));
    second.getElements().add(new CubicCurveTo(0.4550561797752809 * width, 0.0,
                                              0.43820224719101125 * width, 0.30835734870317005 * height,
                                              0.43820224719101125 * width, 0.30835734870317005 * height));
    second.getElements().add(new CubicCurveTo(0.19101123595505617 * width, 0.3170028818443804 * height,
                                              0.0, 0.3703170028818444 * height,
                                              0.0, 0.4365994236311239 * height));
    second.getElements().add(new ClosePath());
    second.setCache(true);
    second.setCacheHint(CacheHint.ROTATE);
}
项目:Medusa    文件:HSkin.java   
private void drawAverage() {
    double scaledWidth = width * 0.9;
    double centerX     = width * 0.5;
    double centerY     = Pos.TOP_CENTER == gauge.getKnobPosition() ? height * 0.1 : height * 0.9;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * scaledWidth);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledWidth * 0.38 * sinValue, centerY + scaledWidth * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.34 * sinValue, centerY + scaledWidth * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.34 * sinValue, centerY + scaledWidth * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledWidth * 0.465 * sinValue, centerY + scaledWidth * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.425 * sinValue, centerY + scaledWidth * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledWidth * 0.425 * sinValue, centerY + scaledWidth * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}