import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; /**This is the main routine**/ public class Main extends Applet { GridBagLayout game; GridBagConstraints c; Plotter PLOT1,PLOT2; PolyDisplay POLY1,POLY2; ControlCanvas CON; KeyCanvas KEYBOARD; TextCanvas TEXT; Hub HUB; Panel P1,P2,P3; public static void main(String[] args) { Main a=new Main(); Frame2 F=new Frame2("OctoMap II by Rich Schwartz",a); a.setBackground(new Color(0,0,100)); a.init(); F.add(a); F.pack(); F.addWindowListener(new WinList(F)); F.setVisible(true); } public void init() { /*****************/ int SIZE=520; Color BORDERS=new Color(0,100,200); Color BACK=Color.black; Color NAVY=new Color(0,0,100); /*****************/ game=new GridBagLayout(); c=new GridBagConstraints(); c.gridwidth=GridBagConstraints.REMAINDER; setLayout(game); setBackground(Color.black); /**list the components*/ P1=new Panel(); P2=new Panel(); P3=new Panel(); PLOT1=new Plotter(1); PLOT2=new Plotter(0); POLY1=new PolyDisplay(0); TEXT=new TextCanvas(); HUB=new Hub(); POLY2=new PolyDisplay(1); CON=new ControlCanvas(); KEYBOARD=new KeyCanvas(); /**set the component sizes**/ PLOT1.setSize(SIZE,SIZE); PLOT2.setSize(SIZE,SIZE); int s=(int)(SIZE/2); POLY1.setSize(s-2,s); POLY2.setSize(s-3,s); TEXT.setSize(2*s,s); HUB.setSize(200,s); CON.setSize(200,SIZE); KEYBOARD.setSize(2*SIZE+210,51); /**set the colors**/ PLOT1.setBackground(BACK); PLOT2.setBackground(BACK); POLY1.setBackground(BACK); POLY2.setBackground(BACK); TEXT.setBackground(BACK); HUB.setBackground(Color.blue); P1.setBackground(BORDERS); P2.setBackground(BORDERS); P3.setBackground(BORDERS); CON.setBackground(NAVY); KEYBOARD.setBackground(new Color(100,0,0)); /**make the layout**/ /**top layer**/ P1.add(PLOT1); P1.add(CON); P1.add(PLOT2); /**middle layer**/ P3.add(KEYBOARD); /**bottom layer**/ P2.add(TEXT); P2.add(HUB); P2.add(POLY1); P2.add(POLY2); c.ipady=-5; game.setConstraints(P1,c); game.setConstraints(P3,c); c.ipady=0; game.setConstraints(P2,c); add(P1); add(P3); add(P2); /**allow the components to communicate thru the manager.**/ Manager M=new Manager(); M.PD1=POLY1; M.PD2=POLY2; M.PL1=PLOT1; M.PL2=PLOT2; M.K=KEYBOARD; M.C=CON; M.H=HUB; M.TEXT=TEXT; TEXT.M=M; POLY1.M=M; POLY2.M=M; PLOT1.M=M; PLOT2.M=M; CON.M=M; KEYBOARD.M=M; HUB.M=M; } public static class Frame2 extends Frame implements ComponentListener { Main a; public Frame2(String W,Main a) { super(W); this.a=a; addComponentListener(this); } public void componentHidden(ComponentEvent e) {} public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) {} public void componentShown(ComponentEvent e) {} } }