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;
}
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));
}
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();
}
}
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);
}
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);
}
Aggregations