Search in sources :

Example 1 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project Board-Instrumentation-Framework by intel.

the class ShapeConverter method processPath.

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;
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) SVGPath(javafx.scene.shape.SVGPath) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) VLineTo(javafx.scene.shape.VLineTo) HLineTo(javafx.scene.shape.HLineTo) ArcTo(javafx.scene.shape.ArcTo) QuadCurveTo(javafx.scene.shape.QuadCurveTo) VLineTo(javafx.scene.shape.VLineTo) HLineTo(javafx.scene.shape.HLineTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 2 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project contentment by GeePawHill.

the class BezierSplit method setPathToBefore.

public void setPathToBefore(Path path) {
    path.getElements().clear();
    path.getElements().add(new MoveTo(before.start.x, before.start.y));
    path.getElements().add(new CubicCurveTo(before.handle1.x, before.handle1.y, before.handle2.x, before.handle2.y, before.end.x, before.end.y));
}
Also used : MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 3 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project latexdraw by arnobl.

the class ViewFactory method flushPathElement.

public void flushPathElement(final PathElement elt) {
    if (elt instanceof LineTo) {
        final LineTo lineTo = (LineTo) elt;
        lineTo.xProperty().unbind();
        lineTo.yProperty().unbind();
    } else if (elt instanceof MoveTo) {
        final MoveTo moveTo = (MoveTo) elt;
        moveTo.xProperty().unbind();
        moveTo.yProperty().unbind();
    } else if (elt instanceof CubicCurveTo) {
        final CubicCurveTo cct = (CubicCurveTo) elt;
        cct.xProperty().unbind();
        cct.yProperty().unbind();
        cct.controlX1Property().unbind();
        cct.controlX2Property().unbind();
        cct.controlY1Property().unbind();
        cct.controlY2Property().unbind();
    }
}
Also used : LineTo(javafx.scene.shape.LineTo) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 4 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project tilesfx by HanSolo.

the class HighLowTileSkin method drawTriangle.

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);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 5 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project tilesfx by HanSolo.

the class Helper method smoothPath.

// Smooth given path defined by it's list of path elements
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);
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) LineTo(javafx.scene.shape.LineTo) ArrayList(java.util.ArrayList) CubicCurveTo(javafx.scene.shape.CubicCurveTo) ClosePath(javafx.scene.shape.ClosePath) PathElement(javafx.scene.shape.PathElement) MoveTo(javafx.scene.shape.MoveTo)

Aggregations

CubicCurveTo (javafx.scene.shape.CubicCurveTo)14 MoveTo (javafx.scene.shape.MoveTo)13 ClosePath (javafx.scene.shape.ClosePath)9 LineTo (javafx.scene.shape.LineTo)8 Path (javafx.scene.shape.Path)4 PathElement (javafx.scene.shape.PathElement)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 QuadCurveTo (javafx.scene.shape.QuadCurveTo)2 IntStream (java.util.stream.IntStream)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 Point2D (javafx.geometry.Point2D)1 Color (javafx.scene.paint.Color)1 ArcTo (javafx.scene.shape.ArcTo)1 HLineTo (javafx.scene.shape.HLineTo)1 Rectangle (javafx.scene.shape.Rectangle)1 SVGPath (javafx.scene.shape.SVGPath)1 Shape (javafx.scene.shape.Shape)1