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