Search in sources :

Example 26 with Group

use of javafx.scene.Group in project latexdraw by arnobl.

the class ViewShape method getActivatedGroupNodes.

private static Collection<Shape> getActivatedGroupNodes(final Group gp) {
    // Adding all the shape children
    final Collection<Shape> shapes = gp.getChildren().stream().filter(node -> node instanceof Shape && node.isVisible() && !node.isDisable()).map(node -> (Shape) node).collect(Collectors.toList());
    // Adding all the view shape children
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ViewShape<?> && node.isVisible() && !node.isDisable()).map(vs -> ((ViewShape<?>) vs).getActivatedShapes()).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the shapes contained in groups that are not view shapes
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof Group && !(node instanceof ViewShape<?>)).map(node -> getActivatedGroupNodes((Group) node)).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the images contained in the group
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ImageView && node.isVisible() && !node.isDisable()).map(node -> {
        final Bounds bounds = node.getBoundsInParent();
        Rectangle rec = new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
        rec.setFill(Color.WHITE);
        rec.getTransforms().setAll(gp.getLocalToSceneTransform());
        return rec;
    }).collect(Collectors.toList()));
    return shapes;
}
Also used : Platform(javafx.application.Platform) Parent(javafx.scene.Parent) Color(javafx.scene.paint.Color) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ImageView(javafx.scene.image.ImageView) Collection(java.util.Collection) Optional(java.util.Optional) Rectangle(javafx.scene.shape.Rectangle) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Group(javafx.scene.Group) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Rectangle(javafx.scene.shape.Rectangle) ImageView(javafx.scene.image.ImageView)

Example 27 with Group

use of javafx.scene.Group in project latexdraw by arnobl.

the class TestCanvas method testViewsPanePositionORIGIN.

@Test
public void testViewsPanePositionORIGIN() {
    Group group = getPane();
    assertEquals(Canvas.ORIGIN.getX(), group.getLayoutX(), 0.000001);
    assertEquals(Canvas.ORIGIN.getY(), group.getLayoutY(), 0.000001);
}
Also used : Group(javafx.scene.Group) Test(org.junit.Test)

Example 28 with Group

use of javafx.scene.Group in project tilesfx by HanSolo.

the class CountryTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    // poiLocations       = FXCollections.observableHashMap();
    // chartDataLocations = FXCollections.observableHashMap();
    // circleHandlerMap   = new HashMap<>();
    country = tile.getCountry();
    if (null == country) {
        country = Country.DE;
    }
    clickHandler = event -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor())));
    countryPaths = Helper.getHiresCountryPaths().get(country.name());
    countryMinX = Helper.MAP_WIDTH;
    countryMinY = Helper.MAP_HEIGHT;
    countryMaxX = 0;
    countryMaxY = 0;
    countryPaths.forEach(path -> {
        path.setFill(tile.getBarColor());
        countryMinX = Math.min(countryMinX, path.getBoundsInParent().getMinX());
        countryMinY = Math.min(countryMinY, path.getBoundsInParent().getMinY());
        countryMaxX = Math.max(countryMaxX, path.getBoundsInParent().getMaxX());
        countryMaxY = Math.max(countryMaxY, path.getBoundsInParent().getMaxY());
    });
    /*
        tile.getPoiList()
            .forEach(poi -> {
                String tooltipText = new StringBuilder(poi.getName()).append("\n")
                                                                     .append(poi.getInfo())
                                                                     .toString();
                Circle circle = new Circle(3, poi.getColor());
                circle.setOnMousePressed(e -> poi.fireLocationEvent(new LocationEvent(poi)));
                Tooltip.install(circle, new Tooltip(tooltipText));
                poiLocations.put(poi, circle);
            });
        */
    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    text = new Text(tile.getCountry().getDisplayName());
    text.setFill(tile.getTextColor());
    Helper.enableNode(text, tile.isTextVisible());
    countryGroup = new Group();
    countryGroup.getChildren().setAll(countryPaths);
    countryContainer = new StackPane();
    countryContainer.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    countryContainer.getChildren().setAll(countryGroup);
    valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
    valueText.setFill(tile.getValueColor());
    valueText.setTextOrigin(VPos.BASELINE);
    Helper.enableNode(valueText, tile.isValueVisible());
    unitText = new Text(" " + tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    unitText.setTextOrigin(VPos.BASELINE);
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());
    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);
    valueUnitFlow.setMouseTransparent(true);
    getPane().getChildren().addAll(titleText, countryContainer, valueUnitFlow, text);
// getPane().getChildren().addAll(poiLocations.values());
}
Also used : TileEvent(eu.hansolo.tilesfx.events.TileEvent) Group(javafx.scene.Group) ChartData(eu.hansolo.tilesfx.chart.ChartData) Text(javafx.scene.text.Text) TextFlow(javafx.scene.text.TextFlow) StackPane(javafx.scene.layout.StackPane)

Example 29 with Group

use of javafx.scene.Group in project tilesfx by HanSolo.

the class SmoothedChart method getPaths.

/**
 * Returns an array of paths where the first entry represents the fill path
 * and the second entry represents the stroke path
 * @param SERIES
 * @return an array of paths where [0] == FillPath and [1] == StrokePath
 */
private Path[] getPaths(final Series<X, Y> SERIES) {
    if (!getData().contains(SERIES)) {
        return null;
    }
    Node seriesNode = SERIES.getNode();
    if (null == seriesNode) {
        return null;
    }
    Group seriesGroup = (Group) seriesNode;
    if (seriesGroup.getChildren().isEmpty() || seriesGroup.getChildren().size() < 2) {
        return null;
    }
    return new Path[] { /* FillPath   */
    (Path) (seriesGroup).getChildren().get(0), /* StrokePath */
    (Path) (seriesGroup).getChildren().get(1) };
}
Also used : ClosePath(javafx.scene.shape.ClosePath) Path(javafx.scene.shape.Path) Group(javafx.scene.Group) Node(javafx.scene.Node)

Example 30 with Group

use of javafx.scene.Group in project Labyrinthe3d by FauconFan.

the class Init method makeWalls.

/**
 * Dessine les murs du Maze
 * @return Le groupe contenant les murs
 */
public static Group makeWalls(Scale sc, MainMaze maze) {
    Material mat;
    try {
        String texturePath = maze.getContentMazeCurrentLevel().getTexturePath();
        if (texturePath == null) {
            // Default
            texturePath = "assets/Brick_wall_002_COLOR.jpg";
        }
        Image img = new Image(new FileInputStream(texturePath), 400, 400, true, false);
        mat = new PhongMaterial(Color.WHITE, img, null, null, null);
    } catch (Exception e) {
        mat = new PhongMaterial(Color.GREEN);
    }
    Group walls = new Group();
    // On scale les murs
    walls.getTransforms().add(sc);
    final float delta = 0.001f;
    ContentMaze[] cms = maze.getContentMaze();
    for (int i = 0; i < cms.length; i++) {
        for (LineWall l : cms[i].getLineWalls()) {
            LineWall[] broken = LineWall.breakWallsIntoSimpleOnes(l);
            for (int j = 0; j < broken.length; j++) {
                Box w = new Box();
                Consumer<Float> setEpais;
                Consumer<Float> setLarg;
                float largeur;
                double trX;
                double trZ;
                float isStart = (j == 0) ? broken[j].getEpaisseur() / 2 - delta : 0;
                float isEnd = (j == broken.length - 1) ? broken[j].getEpaisseur() / 2 - delta : 0;
                if (// Mur "vertical" dans le plan
                !broken[j].isHorizontal()) {
                    largeur = broken[j].getY2() - broken[j].getY1();
                    setLarg = w::setDepth;
                    setEpais = w::setWidth;
                    trX = broken[j].getX1();
                    trZ = broken[j].getY1() + largeur / 2.0;
                } else // Mur horizontal
                {
                    largeur = broken[j].getX2() - broken[j].getX1();
                    setLarg = w::setWidth;
                    setEpais = w::setDepth;
                    trX = broken[j].getX1() + largeur / 2.0;
                    trZ = broken[j].getY1();
                }
                w.setHeight(1);
                setEpais.accept(broken[j].getEpaisseur());
                setLarg.accept(largeur + isStart + isEnd);
                w.setTranslateX(trX);
                w.setTranslateZ(trZ);
                w.setTranslateY(-i - 0.5);
                w.setMaterial(mat);
                walls.getChildren().add(w);
            }
        }
    }
    return (walls);
}
Also used : Group(javafx.scene.Group) Material(javafx.scene.paint.Material) PhongMaterial(javafx.scene.paint.PhongMaterial) LineWall(src.model.board.LineWall) Box(javafx.scene.shape.Box) Image(javafx.scene.image.Image) ContentMaze(src.model.ContentMaze) FileInputStream(java.io.FileInputStream) View(src.view.View) PhongMaterial(javafx.scene.paint.PhongMaterial)

Aggregations

Group (javafx.scene.Group)121 Scene (javafx.scene.Scene)64 Rotate (javafx.scene.transform.Rotate)41 KeyCode (javafx.scene.input.KeyCode)32 PerspectiveCamera (javafx.scene.PerspectiveCamera)31 MouseEvent (javafx.scene.input.MouseEvent)28 Text (javafx.scene.text.Text)25 PointLight (javafx.scene.PointLight)24 Color (javafx.scene.paint.Color)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Pane (javafx.scene.layout.Pane)16 AnimationTimer (javafx.animation.AnimationTimer)15 ArrayList (java.util.ArrayList)14 Node (javafx.scene.Node)14 Label (javafx.scene.control.Label)14 Rectangle (javafx.scene.shape.Rectangle)13 Translate (javafx.scene.transform.Translate)13 Canvas (javafx.scene.canvas.Canvas)11 Stage (javafx.stage.Stage)11 Point3D (org.fxyz.geometry.Point3D)11