Java Reference
In-Depth Information
Figure 1b. Second part of RotatingCube
34.
protected Node buildShape()
35.
{
36.
return new ColorCube(0.4);
37.
}
38.
39.
public void actionPerformed(ActionEvent e)
40.
{
41.
dispose();
42.
System.exit(0);
43.
}//end actionPerformed
44.
45.
public RotatingCube()
46.
{
GraphicsConfiguration
47.
config=SimpleUniverse.getPreferredConfiguration();
48.
Canvas3D Canvas3D_1=new Canvas3D(config);
49.
BranchGroup scene=buildContentBranch(buildShape());
50.
U1=new SimpleUniverse(Canvas3D_1);
51.
U1.getViewingPlatform().setNominalViewingTransform();
52.
U1.addBranchGraph(scene);
53.
setTitle("RotatingCube");
54.
setSize(600,600);
55.
setLayout(new BorderLayout());
56.
add("Center",myCanvas3D);
57.
add("South",myButton);
58.
myButton.addActionListener(this);
59.
setVisible(true);
60.
}//end RotatingCube()
61.
62.
public static void main(String[] args)
63.
{
64.
RotatingCube rc=new RotatingCube();
65. }
66. }//end RotatingCube class
seconds with respect to the vertical y axis. Note that there is an exit button that spans the
entire window width at the bottom of the window and that the program can be stopped by
pressing this button.
In the new few subsections, we will outline the fundamental underlying concepts and
graphical model specified by the program code in Figure 1 and show how this leads to
the 3D outputs of Figure 2. This will serve as an overview before these concepts and the
associated applications are discussed in more details in subsequent chapters.
Search WWH ::




Custom Search