Bounds information are shown in the command window:
BoundsInLocal BoundingBox [minX:-4.5, minY:-4.5, minZ:0.0, width:9.0, height:9.0, depth:0.0, maxX:4.5, maxY:4.5, maxZ:0.0] BoundsInParent BoundingBox [minX:-23.50276756286621, minY:-23.50276756286621, minZ:0.0, width:447.00555419921875, height:447.00555419921875, depth:0.0, maxX:423.50278663635254, maxY:423.50278663635254, maxZ:0.0]
Compare the above bounds (with rotation) to those from MyGroup1.java
BoundsInLocal BoundingBox [minX:-4.5, minY:-4.5, minZ:0.0, width:9.0, height:9.0, depth:0.0, maxX:4.5, maxY:4.5, maxZ:0.0] BoundsInParent BoundingBox [minX:-16.0, minY:-16.0, minZ:0.0, width:432.0, height:432.0, depth:0.0, maxX:416.0, maxY:416.0, maxZ:0.0]
MyGroup2.java
import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Group; import javafx.scene.transform.Scale; import javafx.scene.transform.Translate; import javafx.scene.transform.Transform; import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.shape.*; import javafx.collections.*; import java.util.ArrayList; import java.lang.Math; public class MyGroup2 extends Application { public void start(Stage stage) { Group grp = new Group(); Scene scene = new Scene(grp, 400, 400); grp.setTranslateX(scene.getWidth()/2); grp.setTranslateY(scene.getHeight()/2); double res = 48; //98; grp.setScaleX(res); grp.setScaleY(res); grp.setRotate(10.0); ObservableList<Node> ol = grp.getChildren(); Color c = Color.rgb(220,200,255); double u = 4.0; ArrayList<Line> lines = new ArrayList<Line>(); Line nl; for (int i=-4; i<=4; i++) { double v = i; nl = new Line(-u,v,u,v); lines.add(nl); nl = new Line(v,-u,v,u); lines.add(nl); } for (Line ln: lines) { ln.setStrokeWidth(1.0/res); ln.setStroke(c); ol.add(ln); } // locate origin //g2.setPaint(Color.BLACK); u = 0.05; nl = new Line(-u,u,u,-u); nl.setStrokeWidth(1.0/res); ol.add(nl); nl = new Line(-u,-u,u,u); nl.setStrokeWidth(1.0/res); ol.add(nl); System.out.format("\nBounds\n\n"); System.out.println("BoundsInLocal " + grp.getBoundsInLocal()); System.out.println("BoundsInParent " + grp.getBoundsInParent()); stage.setTitle("Group Test"); stage.setScene(scene); stage.show(); } }
Maintained by John Loomis, updated Fri Feb 02 19:10:44 2018