/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pathbuilderexperiment; import java.util.ArrayList; import java.util.Collection; import javafx.scene.shape.*; import javafx.util.Builder; /** * * @author jp202575 */ public class PathBuilderExtended> extends ShapeBuilder implements Builder { private int __set; private Collection elements; private Collection elementsInline = new ArrayList(); private FillRule fillRule; protected PathBuilderExtended() {} @SuppressWarnings({"deprecation", "rawtypes", "unchecked"}) public static PathBuilderExtended create() { return new PathBuilderExtended(); } public void applyTo(Path x) { super.applyTo(x); int set = __set; if ((set & (1 << 0)) != 0) x.getElements().setAll(this.elements); if ((set & (1 << 1)) != 0) x.setFillRule(this.fillRule); if ((set & (1 << 2)) != 0) x.getElements().addAll(this.elementsInline); } /** Set the value of the {@link Path#getElements() elements} property for the instance constructed by this builder.*/ @SuppressWarnings("unchecked") public B elements(java.util.Collection x) { this.elements = x; __set |= 1 << 0; return (B) this; } /** Set the value of the {@link Path#getElements() elements} property for the instance constructed by this builder. */ public B elements(PathElement... x) { return elements(java.util.Arrays.asList(x)); } /** Set the value of the {@link Path#getFillRule() fillRule} property for the instance constructed by this builder. */ @SuppressWarnings("unchecked") public B fillRule(FillRule x) { this.fillRule = x; __set |= 1 << 1; return (B) this; } /** Make an instance of {@link Path} based on the properties set on this builder. */ public Path build() { Path x = new Path(); applyTo(x); return x; } /** * Add a ArcTo. element * * @param radiusX horizontal radius of the arc * @param radiusY vertical radius of the arc * @param xAxisRotation the x-axis rotation in degrees * @param x horizontal position of the arc end point * @param y vertical position of the arc end point * @param largeArcFlag large arg flag: determines which arc to use (large/small) * @param sweepFlag sweep flag: determines which arc to use (direction) */ public B arcTo(double radiusX, double radiusY, double xAxisRotation, double x, double y, boolean largeArcFlag, boolean sweepFlag) { elementsInline.add(new ArcTo(radiusX,radiusY,xAxisRotation, x, y, largeArcFlag, sweepFlag)); __set |= 1 << 2; return (B) this; } /** * Add a path element which closes the current path. */ public B closePath() { elementsInline.add(new ClosePath()); __set |= 1 << 2; return (B) this; } /** * Add a CubicCurveTo. * @param controlX1 the X coordinate of the first Bézier control point * @param controlY1 the Y coordinate of the first Bézier control point * @param controlX2 the X coordinate of the second Bézier control point * @param controlY2 the Y coordinate of the second Bézier control point * @param x the X coordinate of the final end point * @param y the Y coordinate of the final end point */ public B cubicCurveTo(double controlX1, double controlY1, double controlX2, double controlY2, double x, double y) { elementsInline.add(new CubicCurveTo(controlX1, controlY1, controlX2, controlY2, x, y)); __set |= 1 << 2; return (B) this; } /** * Add a HLineTo. * @param x the horizontal coordinate to line to */ public B hLineTo(double x) { elementsInline.add(new HLineTo(x)); __set |= 1 << 2; return (B) this; } /** * Add a LineTo. * @param x the horizontal coordinate of the line end point * @param y the vertical coordinate of the line end point */ public B lineTo(double x, double y) { elementsInline.add(new LineTo(x, y)); __set |= 1 << 2; return (B) this; } /** * Add a MoveTo. * @param x the horizontal coordinate to move to * @param y the vertical coordinate to move to */ public B moveTo(double x, double y) { elementsInline.add(new MoveTo(x, y)); __set |= 1 << 2; return (B) this; } /** * Add a QuadCurveTo. * @param controlX the X coordinate of the quadratic control point * @param controlY the Y coordinate of the quadratic control point * @param x the X coordinate of the final end point * @param y the Y coordinate of the final end point */ public B quadCurveTo(double controlX, double controlY, double x, double y) { elementsInline.add(new QuadCurveTo(controlX, controlY, x, y)); __set |= 1 << 2; return (B) this; } /** * Add a VLineTo. * @param y the vertical coordinate to line to */ public B vLineTo(double y) { elementsInline.add(new VLineTo(y)); __set |= 1 << 2; return (B) this; } }