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

项目:marathonv5    文件:PathSample.java   
public static Node createIconContent() {
    Path path = new Path();
           path.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(45),
            new ArcTo(20, 20, 0, 80, 25, true, true)
            );
    path.setStroke(Color.web("#b9c0c5"));
    path.setStrokeWidth(5);
    path.getStrokeDashArray().addAll(15d,15d);
    path.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    path.setEffect(effect);
    return path;
}
项目:marathonv5    文件:PathSample.java   
public static Node createIconContent() {
    Path path = new Path();
           path.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(45),
            new ArcTo(20, 20, 0, 80, 25, true, true)
            );
    path.setStroke(Color.web("#b9c0c5"));
    path.setStrokeWidth(5);
    path.getStrokeDashArray().addAll(15d,15d);
    path.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    path.setEffect(effect);
    return path;
}
项目: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);
   }
}
项目:H-Uppaal    文件:ChannelSenderArrowHead.java   
private Path initializeTriangle() {
    final Path triangle = new Path();

    MoveTo start = new MoveTo();
    LineTo l1 = new LineTo();
    LineTo l2 = new LineTo();
    LineTo l3 = new LineTo();

    start.xProperty().bind(ax);
    start.yProperty().bind(ay);

    l1.xProperty().bind(bx);
    l1.yProperty().bind(by);

    l2.xProperty().bind(cx);
    l2.yProperty().bind(cy);

    l3.xProperty().bind(ax);
    l3.yProperty().bind(ay);

    triangle.setFill(Color.BLACK);
    triangle.getElements().addAll(start, l1, l2, l3);

    return triangle;
}
项目:H-Uppaal    文件:HandshakeChannelSenderArrowHead.java   
private Path initializeHalfCircle() {
    final Path halfCircle = new Path();

    halfCircle.setStroke(Color.BLACK);
    MoveTo p1 = new MoveTo();
    ArcTo p2 = new ArcTo();

    p1.xProperty().bind(xProperty().add(CIRCLE_RADIUS));
    p1.yProperty().bind(yProperty());

    p2.xProperty().bind(xProperty().subtract(CIRCLE_RADIUS));
    p2.yProperty().bind(yProperty());
    p2.setRadiusX(CIRCLE_RADIUS);
    p2.setRadiusY(CIRCLE_RADIUS);

    halfCircle.getElements().add(p1);
    halfCircle.getElements().add(p2);

    return halfCircle;
}
项目:H-Uppaal    文件:BroadcastChannelSenderArrowHead.java   
private Path initializeLargeCircle() {
    final Path largeCircle = new Path();

    largeCircle.setStroke(Color.BLACK);
    MoveTo p1 = new MoveTo();
    ArcTo p2 = new ArcTo();

    p1.xProperty().bind(xProperty().add(LARGE_CIRCLE_RADIUS));
    p1.yProperty().bind(yProperty());

    p2.xProperty().bind(xProperty().subtract(LARGE_CIRCLE_RADIUS));
    p2.yProperty().bind(yProperty());
    p2.setRadiusX(LARGE_CIRCLE_RADIUS);
    p2.setRadiusY(LARGE_CIRCLE_RADIUS);

    largeCircle.getElements().add(p1);
    largeCircle.getElements().add(p2);

    return largeCircle;
}
项目:H-Uppaal    文件:BroadcastChannelSenderArrowHead.java   
private Path initializeMediumCircle() {
    final Path mediumCircle = new Path();

    mediumCircle.setStroke(Color.BLACK);
    MoveTo p1 = new MoveTo();
    ArcTo p2 = new ArcTo();

    p1.xProperty().bind(xProperty().add(MEDIUM_CIRCLE_RADIUS));
    p1.yProperty().bind(yProperty());

    p2.xProperty().bind(xProperty().subtract(MEDIUM_CIRCLE_RADIUS));
    p2.yProperty().bind(yProperty());
    p2.setRadiusX(MEDIUM_CIRCLE_RADIUS);
    p2.setRadiusY(MEDIUM_CIRCLE_RADIUS);

    mediumCircle.getElements().add(p1);
    mediumCircle.getElements().add(p2);

    return mediumCircle;
}
项目:H-Uppaal    文件:BroadcastChannelSenderArrowHead.java   
private Path initializeSmallCircle() {
    final Path smallCircle = new Path();

    smallCircle.setStroke(Color.BLACK);
    MoveTo p1 = new MoveTo();
    ArcTo p2 = new ArcTo();

    p1.xProperty().bind(xProperty().add(SMALL_CIRCLE_RADIUS));
    p1.yProperty().bind(yProperty());

    p2.xProperty().bind(xProperty().subtract(SMALL_CIRCLE_RADIUS));
    p2.yProperty().bind(yProperty());
    p2.setRadiusX(SMALL_CIRCLE_RADIUS);
    p2.setRadiusY(SMALL_CIRCLE_RADIUS);

    smallCircle.getElements().add(p1);
    smallCircle.getElements().add(p2);

    return smallCircle;
}
项目: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()); }
}
项目:tilesfx    文件:StockTileSkin.java   
@Override protected void handleEvents(final String EVENT_TYPE) {
    super.handleEvents(EVENT_TYPE);

    if ("VISIBILITY".equals(EVENT_TYPE)) {
        Helper.enableNode(titleText, !tile.getTitle().isEmpty());
        Helper.enableNode(valueText, tile.isValueVisible());
        Helper.enableNode(timeSpanText, !tile.isTextVisible());
        redraw();
    } else if ("VALUE".equals(EVENT_TYPE)) {
        if(tile.isAnimated()) { tile.setAnimated(false); }
        if (!tile.isAveragingEnabled()) { tile.setAveragingEnabled(true); }
        double value = clamp(minValue, maxValue, tile.getValue());
        addData(value);
        handleCurrentValue(value);
    } else if ("AVERAGING".equals(EVENT_TYPE)) {
        noOfDatapoints = tile.getAveragingPeriod();
        // 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.");
        for (int i = 0; i < noOfDatapoints; i++) { dataList.add(minValue); }
        pathElements.clear();
        pathElements.add(0, new MoveTo());
        for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }
        sparkLine.getElements().setAll(pathElements);
        redraw();
    }
}
项目:FxEditor    文件:LineBox.java   
/** returns selection shape for a given range */
public PathElement[] getRange(int start, int end)
{
    if(center instanceof CTextFlow)
    {
        CTextFlow t = (CTextFlow)center;
        return t.getRange(start, end);
    }
    else
    {
        double w = center.getWidth();
        double h = center.getHeight();

        return new PathElement[]
        {
            new MoveTo(0, 0),
            new LineTo(w, 0),
            new LineTo(w, h),
            new LineTo(0, h),
            new LineTo(0, 0)
        };
    }
}
项目:FxEditor    文件:LineBox.java   
/** returns selection shape for a given range */
public PathElement[] getCaretShape(int index, boolean leading)
{
    if(center instanceof CTextFlow)
    {
        CTextFlow t = (CTextFlow)center;
        return t.getCaretShape(index, leading);
    }
    else
    {
        double x = leading ? 0 : center.getWidth();
        double h = center.getHeight();

        return new PathElement[]
        {
            new MoveTo(x, 0),
            new LineTo(x, h)
        };
    }
}
项目: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;
}
项目:dnainator    文件:Edge.java   
/**
 * Constructs a new {@link Edge}, ending at the provided {@link AbstractNode}.
 * @param dst This edge's destination node.
 */
public Edge(AbstractNode dst) {
    // Set start point of the Path.
    MoveTo m = new MoveTo();
    m.xProperty().bindBidirectional(dst.translateXProperty());
    m.yProperty().bindBidirectional(dst.translateYProperty());
    getElements().add(m);

    // Add the horizontal line, starting at the path's start point.
    HLineTo hline = new HLineTo();
    getElements().add(hline);

    // Add the vertical line, starting at the horizontal line's end point.
    VLineTo vline = new VLineTo();
    getElements().add(vline);
}
项目:markdown-writer-fx    文件:ParagraphOverlayGraphicFactory.java   
protected Rectangle2D getBounds(int start, int end) {
    PathElement[] shape = getShape(start, end);
    double minX = 0, minY = 0, maxX = 0, maxY = 0;
    for (PathElement pathElement : shape) {
        if (pathElement instanceof MoveTo) {
            MoveTo moveTo = (MoveTo) pathElement;
            minX = maxX = moveTo.getX();
            minY = maxY = moveTo.getY();
        } else if (pathElement instanceof LineTo) {
            LineTo lineTo = (LineTo) pathElement;
            double x = lineTo.getX();
            double y = lineTo.getY();
            minX = Math.min(minX, x);
            minY = Math.min(minY, y);
            maxX = Math.max(maxX, x);
            maxY = Math.max(maxY, y);
        }
    }
    return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
项目:FlagMaker-2    文件:OverlayDiamond.java   
@Override
public void Draw(Pane canvas)
{
    double width = canvas.getWidth() * (GetDoubleAttribute("Width") / (double) MaximumX);
    double height = GetDoubleAttribute("Height") == 0
            ? width
            : canvas.getHeight() * (GetDoubleAttribute("Height") / MaximumY);
    double left = canvas.getWidth() * (GetDoubleAttribute("X") / MaximumX) - width / 2;
    double top = canvas.getHeight() * (GetDoubleAttribute("Y") / MaximumY) - height / 2;
    Path path = new Path(new PathElement[]
    {
        new MoveTo(0, height / 2),
        new LineTo(width / 2, 0),
        new LineTo(width, height / 2),
        new LineTo(width / 2, height),
        new LineTo(0, height / 2)
    });
    path.setFill(GetColorAttribute("Color"));
    path.setStrokeWidth(0);
    path.setLayoutX(left);
    path.setLayoutY(top);
    canvas.getChildren().add(path);
}
项目:FlagMaker-2    文件:OverlayFimbriationBackward.java   
@Override
public void Draw(Pane canvas)
{
    double widthX = canvas.getWidth() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
    double widthY = canvas.getHeight() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;

    Path path = new Path(new PathElement[]
    {
        new MoveTo(widthX, 0),
        new LineTo(0, 0),
        new LineTo(0, widthY),
        new LineTo(canvas.getWidth() - widthX, canvas.getHeight()),
        new LineTo(canvas.getWidth(), canvas.getHeight()),
        new LineTo(canvas.getWidth(), canvas.getHeight() - widthY),
        new LineTo(widthX, 0)
    });
    path.setFill(GetColorAttribute("Color"));
    path.setStrokeWidth(0);
    canvas.getChildren().add(path);
}
项目:FlagMaker-2    文件:OverlayBorder.java   
@Override
protected Shape[] Thumbnail()
{
    return new Shape[]
    {
        new Path(new PathElement[]
        {
            new MoveTo(0, 5),
            new LineTo(30, 5),
            new LineTo(30, 25),
            new LineTo(0, 25),
            new LineTo(0, 5),
            new MoveTo(5, 10),
            new LineTo(5, 20),
            new LineTo(25, 20),
            new LineTo(25, 10),
            new LineTo(5, 10)
        })
    };
}
项目:FlagMaker-2    文件:OverlayFimbriationForward.java   
@Override
public void Draw(Pane canvas)
{
    double widthX = canvas.getWidth() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
    double widthY = canvas.getHeight() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;

    Path path = new Path(new PathElement[]
    {
        new MoveTo(canvas.getWidth() - widthX, 0),
        new LineTo(canvas.getWidth(), 0),
        new LineTo(canvas.getWidth(), widthY),
        new LineTo(widthX, canvas.getHeight()),
        new LineTo(0, canvas.getHeight()),
        new LineTo(0, canvas.getHeight() - widthY),
        new LineTo(canvas.getWidth() - widthX, 0)
    });
    path.setFill(GetColorAttribute("Color"));
    path.setStrokeWidth(0);
    canvas.getChildren().add(path);
}
项目:FlagMaker-2    文件:DivisionBendsForward.java   
@Override
public void Draw(Pane canvas)
{
    double height = canvas.getHeight();
    double width = canvas.getWidth();

    canvas.getChildren().add(new Rectangle(width, height, Colors[0]));

    Path p = new Path(new PathElement[]
    {
        new MoveTo(width, 0),
        new LineTo(width, height),
        new LineTo(0, height),
        new LineTo(width, 0)
    });
    p.fillProperty().set(Colors[1]);
    p.strokeWidthProperty().set(0);
    canvas.getChildren().add(p);
}
项目:FlagMaker-2    文件:DivisionX.java   
@Override
public void Draw(Pane canvas)
{
    double height = canvas.getHeight();
    double width = canvas.getWidth();

    canvas.getChildren().add(new Rectangle(width, height, Colors[0]));

    Path p = new Path(new PathElement[]
    {
        new MoveTo(0, height),
        new LineTo(width, 0),
        new LineTo(width, height),
        new LineTo(0, 0)
    });
    p.fillProperty().set(Colors[1]);
    p.strokeWidthProperty().set(0);
    canvas.getChildren().add(p);
}
项目:FlagMaker-2    文件:DivisionBendsBackward.java   
@Override
public void Draw(Pane canvas)
{
    double height = canvas.getHeight();
    double width = canvas.getWidth();

    canvas.getChildren().add(new Rectangle(width, height, Colors[0]));

    Path p = new Path(new PathElement[]
    {
        new MoveTo(width, height),
        new LineTo(0, height),
        new LineTo(0, 0),
        new LineTo(width, height)
    });
    p.fillProperty().set(Colors[1]);
    p.strokeWidthProperty().set(0);
    canvas.getChildren().add(p);
}
项目:Elegit    文件:DirectedPath.java   
/**
 * Constructs and binds the appropriate properties for the line and
 * the arrow
 */
public DirectedPath(DoubleBinding startX, DoubleBinding startY,
                    DoubleBinding endX,DoubleBinding endY){

    this.path = new Path();

    MoveTo start = new MoveTo();
    start.xProperty().bind(startX);
    start.yProperty().bind(startY);

    LineTo end = new LineTo();
    end.xProperty().bind(endX);
    end.yProperty().bind(endY);

    path.getElements().add(start);
    path.getElements().add(end);

    this.arrow = getArrow();

    this.getChildren().add(path);
    this.getChildren().add(arrow);

    this.path.getStyleClass().setAll("edge");
}
项目: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());
}
项目:javafx-demos    文件:ShapesDemo.java   
private void createMinus() {
    Path minus = PathBuilder.create()
            .elements(new MoveTo(0, 0),
                    new LineTo(0, 5),
                    new LineTo(15, 5),
                    new LineTo(15, 0),
                    new LineTo(0, 0))
            .stroke(Color.web("#000000"))
            .fill(Color.web("#FFFFFF"))
            .strokeWidth(1)
            .cursor(Cursor.HAND)
            .build();
    Circle c = CircleBuilder.create().radius(13).style("-fx-fill:-fx-base;").build() ;
    StackPane sp = StackPaneBuilder.create().styleClass("close-btn")
                                   .maxHeight(26).maxWidth(26)
                                   .prefHeight(26).prefWidth(26)
                                   .children(c,minus).build();

    root.getChildren().add(sp);
}
项目:kotlinfx-ensemble    文件:PathSample.java   
public static Node createIconContent() {
    Path path = new Path();
           path.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(45),
            new ArcTo(20, 20, 0, 80, 25, true, true)
            );
    path.setStroke(Color.web("#b9c0c5"));
    path.setStrokeWidth(5);
    path.getStrokeDashArray().addAll(15d,15d);
    path.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    path.setEffect(effect);
    return path;
}
项目: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;
}
项目:RichTextFX    文件:TextFlowExt.java   
/**
 * @param from The index of the first character.
 * @param to The index of the last character.
 * @return An array with the PathElement objects which define an
 *         underline from the first to the last character.
 */
PathElement[] getUnderlineShape(int from, int to) {
    // get a Path for the text underline
    PathElement[] shape = textLayout().getRange(from, to, TextLayout.TYPE_UNDERLINE, 0, 0);

    // The shape is returned as a closed Path (a thin rectangle).
    // If we use the Path as it is, this causes rendering issues.
    // Hence we only use the MoveTo and the succeeding LineTo elements for the result
    // so that simple line segments instead of rectangles are returned.
    List<PathElement> result = new ArrayList<>();

    boolean collect = false;
    for (PathElement elem : shape) {
        if (elem instanceof MoveTo) {   // There seems to be no API to get the type of the PathElement
            result.add(elem);
            collect = true;
        } else if (elem instanceof LineTo) {
            if (collect) {
                result.add(elem);
                collect = false;
            }
        }
    }

   return result.toArray(new PathElement[0]);
}
项目:Moxy-Parser    文件:SequenceNode.java   
protected void unbindChildren(RuleNode<?> first, RuleNode<?> second) {

        if (second != null) {
            second.layoutXProperty().unbind();
        }
        if (first != null) {
            Path path = getPath(first, 0);

            if (path == null) {
                return;
            }

            MoveTo move = (MoveTo) path.getElements().get(0);
            move.xProperty().unbind();
            move.yProperty().unbind();

            HLineTo line = (HLineTo) path.getElements().get(1);
            line.xProperty().unbind();

            removePath(path, first);
        }

    }
项目:incubator-netbeans    文件:PuzzlePieces.java   
Desk(int numOfColumns, int numOfRows) {
    setStyle("-fx-background-color: #cccccc; " +
            "-fx-border-color: #464646; " +
            "-fx-effect: innershadow( two-pass-box , rgba(0,0,0,0.8) , 15, 0.0 , 0 , 4 );");
    double DESK_WIDTH = Piece.SIZE * numOfColumns;
    double DESK_HEIGHT = Piece.SIZE * numOfRows;
    setPrefSize(DESK_WIDTH,DESK_HEIGHT);
    setMaxSize(DESK_WIDTH, DESK_HEIGHT);
    autosize();
    // create path for lines
    Path grid = new Path();
    grid.setStroke(Color.rgb(70, 70, 70));
    getChildren().add(grid);
    // create vertical lines
     for (int col = 0; col < numOfColumns - 1; col++) {
         grid.getElements().addAll(
             new MoveTo(Piece.SIZE + Piece.SIZE * col, 5),
             new LineTo(Piece.SIZE + Piece.SIZE * col, Piece.SIZE * numOfRows - 5)
         );
    }
    // create horizontal lines
    for (int row = 0; row < numOfRows - 1; row++) {
         grid.getElements().addAll(
             new MoveTo(5, Piece.SIZE + Piece.SIZE * row),
             new LineTo(Piece.SIZE * numOfColumns - 5, Piece.SIZE + Piece.SIZE * row)
         );
    }
}
项目:incubator-netbeans    文件:TransitionPath.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 400,260));
    Rectangle rect = new Rectangle (0, 0, 40, 40);
    rect.setArcHeight(10);
    rect.setArcWidth(10);
    rect.setFill(Color.ORANGE);
    root.getChildren().add(rect);
    Path path = PathBuilder.create()
            .elements(
                new MoveTo(20,20),
                new CubicCurveTo(380, 0, 380, 120, 200, 120),
                new CubicCurveTo(0, 120, 0, 240, 380, 240)
            )
            .build();
    path.setStroke(Color.DODGERBLUE);
    path.getStrokeDashArray().setAll(5d,5d);
    root.getChildren().add(path);

    pathTransition = PathTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .path(path)
            .node(rect)
            .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
项目:SunburstChart    文件:SunburstChart.java   
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    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
}