JavaFX add Quad Curve To Path - Java javafx.scene.shape

Java examples for javafx.scene.shape:Path

Description

JavaFX add Quad Curve 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{

    /**/*from ww  w .j  ava  2 s .c  o  m*/
     * @param pathSegment
     * @param x
     * @param y
     * @param ctrlX
     * @param ctrlY
     */
    public static void addQuadCurveTo(List<PathElement> pathSegment,
            double x, double y, double ctrlX, double ctrlY) {
        pathSegment.add(buildQuadCurveTo(x, y, ctrlX,
                ctrlY));
    }
    /**
     *
     * @param x
     * @param y
     * @param ctrlX
     * @param ctrlY
     * @return
     */
    public static QuadCurveTo buildQuadCurveTo(double x, double y,
            double ctrlX, double ctrlY) {
        QuadCurveTo quadCurveTo = new QuadCurveTo();
        quadCurveTo.setX(x);
        quadCurveTo.setY(y);
        quadCurveTo.setControlX(ctrlX);
        quadCurveTo.setControlY(ctrlY);
        return quadCurveTo;
    }
}

Related Tutorials