use of javafx.scene.shape.Path in project FXyzLib by Birdasaur.
the class Text3DHelper method generatePath.
private Path generatePath() {
Path path = new Path(new MoveTo(list.get(0).x, list.get(0).y));
list.stream().skip(1).forEach(p -> path.getElements().add(new LineTo(p.x, p.y)));
path.getElements().add(new ClosePath());
path.setStroke(Color.GREEN);
// Path must be filled to allow Shape.intersect
path.setFill(Color.RED);
return path;
}
use of javafx.scene.shape.Path in project bitsquare by bitsquare.
the class CandleStickChart method seriesRemoved.
@Override
protected void seriesRemoved(XYChart.Series<Number, Number> series) {
// remove all candle nodes
for (XYChart.Data<Number, Number> d : series.getData()) {
final Node candle = d.getNode();
if (shouldAnimate()) {
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(0);
ft.setOnFinished((ActionEvent actionEvent) -> {
getPlotChildren().remove(candle);
});
ft.play();
} else {
getPlotChildren().remove(candle);
}
}
if (series.getNode() instanceof Path) {
Path seriesPath = (Path) series.getNode();
if (shouldAnimate()) {
FadeTransition ft = new FadeTransition(Duration.millis(500), seriesPath);
ft.setToValue(0);
ft.setOnFinished((ActionEvent actionEvent) -> {
getPlotChildren().remove(seriesPath);
seriesPath.getElements().clear();
});
ft.play();
} else {
getPlotChildren().remove(seriesPath);
seriesPath.getElements().clear();
}
}
}
use of javafx.scene.shape.Path in project FXyzLib by Birdasaur.
the class Text3DMesh method createLetter.
private void createLetter(String letter) {
Text3DHelper helper = new Text3DHelper(letter, font.get(), fontSize.get());
List<Point3D> origin = helper.getOffset();
final int ind = indSegments.get();
helper.getLineSegment().stream().map(poly -> poly.getPath()).forEach(path -> letterPath = Shape.union(letterPath, path));
helper.getLineSegment().stream().forEach(poly -> {
final List<Point3D> points = poly.getPoints();
List<List<Point3D>> holes = null;
if (poly.getHoles().size() > 0) {
holes = poly.getHoles().stream().map(LineSegment::getPoints).collect(Collectors.toList());
}
List<Point3D> invert = IntStream.range(0, points.size()).mapToObj(i -> points.get(points.size() - 1 - i)).distinct().collect(Collectors.toList());
Bounds bounds = null;
if (joinSegments.get()) {
bounds = letterPath.getBoundsInParent();
}
TriangulatedMesh polyMesh = new TriangulatedMesh(invert, holes, level.get(), height.get(), 0d, bounds);
if (indSegments.get() > ind && joinSegments.get()) {
MeshHelper mh = new MeshHelper((TriangleMesh) meshes.get(meshes.size() - 1).getMesh());
MeshHelper mh1 = new MeshHelper((TriangleMesh) polyMesh.getMesh());
mh1.addMesh(mh);
polyMesh.updateMesh(mh1);
meshes.set(meshes.size() - 1, polyMesh);
} else {
meshes.add(polyMesh);
}
polyMesh.getTransforms().addAll(new Translate(offset.get(ind).x - origin.get(0).x + indLetters.get() * gap.doubleValue(), 0, 0));
polyMesh.setCullFace(CullFace.BACK);
polyMesh.setDrawMode(DrawMode.FILL);
polyMesh.setDepthTest(DepthTest.ENABLE);
polyMesh.setId(poly.getLetter());
System.out.println("l " + poly.getLetter());
indSegments.getAndIncrement();
});
indLetters.getAndIncrement();
}
use of javafx.scene.shape.Path in project FXyzLib by Birdasaur.
the class Text3DMesh method updateMesh.
protected final void updateMesh() {
// 1. Full Text to get position of each letter
Text3DHelper helper = new Text3DHelper(text3D.get(), font.get(), fontSize.get());
offset = helper.getOffset();
// 2. Create mesh for each LineSegment
meshes = FXCollections.<TexturedMesh>observableArrayList();
indLetters = new AtomicInteger();
indSegments = new AtomicInteger();
letterPath = new Path();
text3D.get().chars().mapToObj(i -> (char) i).filter(c -> c != SPACE).forEach(letter -> createLetter(letter.toString()));
getChildren().setAll(meshes);
updateTransforms();
}
use of javafx.scene.shape.Path in project fxexperience2 by EricCanull.
the class SplineEditor method createPath.
private Path createPath(Color stroke, double width, double a, double b) {
Path path = new Path();
path.setStroke(stroke);
path.strokeWidthProperty().set(width);
path.getStrokeDashArray().addAll(a, b);
return path;
}
Aggregations