MyGroup1.java

Command window results shows transformations

C:\ece538\JavaFX\circuit_dev>java MyGroup1
Translate [x=200.0, y=200.0, z=0.0]
Scale [x=48.0, y=48.0, z=1.0, pivotX=0.0, pivotY=0.0, pivotZ=0.0]

Create concatenated matrix?
Scale [x=48.0, y=48.0, z=1.0, pivotX=-204.25531914893617, pivotY=-204.25531914893617, pivotZ=0.0]

and Bounds

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]


MyGroup1.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 MyGroup1 extends Application {
    public void start(Stage stage) {
        Group grp = new Group();
        Scene scene = new Scene(grp, 400, 400);

	Translate tr = new Translate(scene.getWidth()/2,scene.getHeight()/2);
	int res = 48; //98;
	Scale scl = new Scale(res,res);

	grp.getTransforms().addAll(tr,scl);

	ObservableList<Transform> tlist = grp.getTransforms();
	for (Transform t: tlist) System.out.println(t);

	System.out.format("\nCreate concatenated matrix?\n");
	Transform s = scl.createConcatenation(tr);
	System.out.println(s);


	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);
		ol.add(nl);
		nl = new Line(v,-u,v,u);
		lines.add(nl);
		ol.add(nl);			
	}
	for (Line ln: lines) {
		ln.setStrokeWidth(1.0/res);
		ln.setStroke(c);
	}
	// 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("MyGroup1");
        stage.setScene(scene);
        stage.show();
    }
}


Maintained by John Loomis, updated Fri Feb 02 17:53:33 2018