Search in sources :

Example 1 with Path

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

Example 2 with 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();
        }
    }
}
Also used : Path(javafx.scene.shape.Path) FadeTransition(javafx.animation.FadeTransition) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node) XYChart(javafx.scene.chart.XYChart)

Example 3 with Path

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();
}
Also used : IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Function(java.util.function.Function) IntegerProperty(javafx.beans.property.IntegerProperty) CullFace(javafx.scene.shape.CullFace) TriangleMesh(javafx.scene.shape.TriangleMesh) ArrayList(java.util.ArrayList) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ColorPalette(org.fxyz.utils.Palette.ColorPalette) Mesh(javafx.scene.shape.Mesh) Patterns(org.fxyz.utils.Patterns) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) Color(javafx.scene.paint.Color) Translate(javafx.scene.transform.Translate) TextureMode(org.fxyz.shapes.primitives.helper.TextureMode) Group(javafx.scene.Group) DrawMode(javafx.scene.shape.DrawMode) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Stream(java.util.stream.Stream) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) DepthTest(javafx.scene.DepthTest) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) Translate(javafx.scene.transform.Translate) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment)

Example 4 with Path

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();
}
Also used : Path(javafx.scene.shape.Path) IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Function(java.util.function.Function) IntegerProperty(javafx.beans.property.IntegerProperty) CullFace(javafx.scene.shape.CullFace) TriangleMesh(javafx.scene.shape.TriangleMesh) ArrayList(java.util.ArrayList) LineSegment(org.fxyz.shapes.primitives.helper.LineSegment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ColorPalette(org.fxyz.utils.Palette.ColorPalette) Mesh(javafx.scene.shape.Mesh) Patterns(org.fxyz.utils.Patterns) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper) Color(javafx.scene.paint.Color) Translate(javafx.scene.transform.Translate) TextureMode(org.fxyz.shapes.primitives.helper.TextureMode) Group(javafx.scene.Group) DrawMode(javafx.scene.shape.DrawMode) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Stream(java.util.stream.Stream) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) DepthTest(javafx.scene.DepthTest) MeshHelper(org.fxyz.shapes.primitives.helper.MeshHelper) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) Bounds(javafx.geometry.Bounds) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Text3DHelper(org.fxyz.shapes.primitives.helper.Text3DHelper)

Example 5 with Path

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

Aggregations

Path (javafx.scene.shape.Path)9 Node (javafx.scene.Node)5 FadeTransition (javafx.animation.FadeTransition)4 XYChart (javafx.scene.chart.XYChart)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Objects (java.util.Objects)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2 Stream (java.util.stream.Stream)2 BooleanProperty (javafx.beans.property.BooleanProperty)2 DoubleProperty (javafx.beans.property.DoubleProperty)2 IntegerProperty (javafx.beans.property.IntegerProperty)2 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)2 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)2 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)2 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)2 StringProperty (javafx.beans.property.StringProperty)2