MyGroup3.java


MyGroup3.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 MyGroup3 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 = 98; //98;
	grp.setScaleX(res);
	grp.setScaleY(res);

	//grp.setRotate(10.0);

	drawGrid(grp);

	Capacitor2 c = new Capacitor2();
	c.draw(grp);
	c.setPosition(0.0,1.0);

	Capacitor2 c2 = new Capacitor2();
	c2.clr = Color.BLUE;
	c2.draw(grp);
	c2.setAngle(30.0);
	c2.setPosition(1.0,0.0);

	//for (Node n: ol) System.out.println(n);

        stage.setTitle("MyGroup3");
        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;
	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);
}	
}


Maintained by John Loomis, updated Fri Feb 02 12:41:59 2018