package Current.popups.Unfold; import Current.*; import Current.manage.*; import java.awt.*; import java.awt.event.*; import java.io.Serializable; public class UnfoldContainer extends Container { protected Manager M; public ColorSettings colors; public UnfoldCanvas U; public UnfoldControlCanvas UC; public BoxAnalyzerCanvas BAC; public UnfoldFunctionCanvas F; public Container C; /** Creates a new instance of UnfoldContainer */ public UnfoldContainer(Manager M) { this.M=M; M.addListener(this); colors=(ColorSettings)(M.settings.getDefault(ColorSettings.class)); // the order of these lines is becoming quite delicate // ...ugh C=new Container(); C.setLayout(new BorderLayout()); U=new UnfoldCanvas(M,this); F=new UnfoldFunctionCanvas(M); UC=new UnfoldControlCanvas(M,U,F); U.addUnfoldControlCanvas(UC); UC.addUnfoldContainer(this); if (UC.L[2].on==1) // add only if it wants to display functions C.add(F,"North"); F.setSize(695,65); U.setSize(615,165); UC.setSize(80,165); F.setBackground(new Color(0,0,80)); U.setBackground(Color.black); setLayout(new BorderLayout()); add(UC,"West"); add(U,"Center"); add(C,"South"); setBackground(Color.black); if (U.shouldBoxAnalyze()) { showBoxAnalyzer(); } } /** This function hides the enclosed Function canvas */ public void hideFunction(){ C.remove(F); C.validate(); validate(); } /** This function shows the enclosed Function canvas */ public void showFunction(){ C.add(F,"North"); C.validate(); validate(); } /** This function hides the enclosed Function canvas */ public void hideControls(){ remove(UC); C.validate(); validate(); } /** This function shows the enclosed Function canvas */ public void showControls(){ add(UC,"West"); C.validate(); validate(); } public void showBoxAnalyzer() { if (UC==null) { System.out.println("ok..."); } if (BAC==null) { if (U==null) { System.out.println("huh?"); } BAC=new BoxAnalyzerCanvas(U); C.add(BAC,"South"); C.validate(); validate(); } BAC.update(); } public void hideBoxAnalyzer() { if (BAC!=null) { C.remove(BAC); C.validate(); validate(); BAC=null; } } /** This must be called when the containing popup is closed, so that * the manager no longer tries to contact these components. */ public void mcbCleanup() { M.remove(UC); M.remove(U); M.remove(F); } public static class ColorSettings implements Serializable { public String getTitle() { return "unfold window colors"; } public Color bgColor=Color.black; public static final String bgColor_name="background color"; public Color triColor=new Color(0,80,120,200); public static final String triColor_name="triangle color"; public Color edgeColor=new Color(0,120,120); public static final String edgeColor_name="edge color"; public Color saddleColor=new Color(255,255,0); public static final String saddleColor_name="connection color"; public Color spineColor=new Color(255,0,255); public static final String spineColor_name="spine color"; public Color annColor=new Color(0,0,255,100); public static final String annColor_name="annulus color"; public Color annBdColor=new Color(50,110,255,200); public static final String annBdColor_name="annulus boundary color"; public Color selectColor=new Color(255,0,255); public static final String selectColor_name="highlight color"; } public void mcbReceive(ColorSettings s) { repaint(); U.doUnfold(); UC.doSpine(); U.repaint(); UC.repaint(); F.repaint(); } }