JavaFX add Arc To Path - Java javafx.scene.shape

Java examples for javafx.scene.shape:Path

Description

JavaFX add Arc To Path

Demo Code


import java.util.ArrayList;
import java.util.List;
import javafx.scene.shape.ArcTo;
import javafx.scene.shape.ClosePath;
import javafx.scene.shape.HLineTo;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.PathElement;
import javafx.scene.shape.QuadCurveTo;
import javafx.scene.shape.Shape;
import javafx.scene.shape.VLineTo;
import javafx.scene.transform.Affine;

public class Main{
    public static void main(String[] argv) throws Exception{
        List pathSegment = java.util.Arrays.asList("asdf","java2s.com");
        double x = 2.45678;
        double y = 2.45678;
        double rX = 2.45678;
        double rY = 2.45678;
        addArcTo(pathSegment,x,y,rX,rY);
    }//  w  w w. j  ava  2s .  co  m
    /**
     * @param pathSegment
     * @param x
     * @param y
     * @param rX
     * @param rY
     */
    public static void addArcTo(List<PathElement> pathSegment, double x,
            double y, double rX, double rY) {
        pathSegment.add(buildArcTo(x, y, rX, rY));
    }
    /**
     * @param pathSegment
     * @param x
     * @param y
     * @param rX
     * @param rY
     * @param sweepFlag
     */
    public static void addArcTo(List<PathElement> pathSegment, double x,
            double y, double rX, double rY, boolean sweepFlag) {
        pathSegment.add(buildArcTo(x, y, rX, rY,
                sweepFlag));
    }
    /**
     *
     * @param x
     * @param y
     * @param rX
     * @param rY
     * @return
     */
    public static ArcTo buildArcTo(double x, double y, double rX, double rY) {
        ArcTo arcTo = new ArcTo();
        arcTo.setX(x);
        arcTo.setY(y);
        arcTo.setRadiusX(rX);
        arcTo.setRadiusY(rY);
        return arcTo;
    }
    /**
     *
     * @param x
     * @param y
     * @param rX
     * @param rY
     * @param sweepFlag
     * @return
     */
    public static ArcTo buildArcTo(double x, double y, double rX,
            double rY, boolean sweepFlag) {
        ArcTo arcTo = buildArcTo(x, y, rX, rY);
        arcTo.setSweepFlag(sweepFlag);
        return arcTo;
    }
}

Related Tutorials