MyGroup4.javaimport javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.collections.*;
import java.lang.Math;
public class MyGroup4 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);
drawGrid(grp);
stage.setTitle("MyGroup4");
stage.setScene(scene);
stage.show();
}
public void drawGrid(Group grp) {
double res = grp.getScaleX();
ObservableList<Node> ol = grp.getChildren();
Color c = Color.rgb(220,200,255);
double u = 4.0;
Path p1 = new Path();
ObservableList<PathElement> p = p1.getElements();
for (int i=-4; i<=4; i++) {
double v = i;
p.add(new MoveTo(-u,v));
p.add(new LineTo(u,v));
p.add(new MoveTo(v,-u));
p.add(new LineTo(v,u));
}
p1.setStrokeWidth(1.0/res);
p1.setStroke(c);
ol.add(p1);
// locate origin
Path p2 = new Path();
p = p2.getElements();
u = 0.05;
p.add(new MoveTo(-u,u));
p.add(new LineTo(u,-u));
p.add(new MoveTo(-u,-u));
p.add(new LineTo(u,u));
p2.setStrokeWidth(1.0/res);
ol.add(p2);
}
}
Maintained by John Loomis, updated Fri Feb 02 20:58:09 2018