TOC
Create the MainPanel:

The MainPanel.java is the Top-level GraphicComposite and it inherites from the Framework's SuperMainPanel.java class, which is inherited from the Panel.java class. The Main Panel is divided into two parts: the upper part is the amplifier circuit and the lower part is the characteristic curve. So the MainPanel.java should contain two GraphicComposite. They are the AmplifierCircuit.java and CharacterCurve.java classes.

In order to communicate with the Controller module, we need an instance of the AmpEventHandler.java class. Also in order to communicate with the Algorithm module, we need an instance of the AmpAlgorithm.java classs.

In the MainPanel.java, we first call its super class to initialize all the things we need in the applet. Then we create the instance of the AmpAlgorithm.java class and set the Algorithm in the ApplotLogic.java class.

super(educApplet);

alg = new AmpAlgorithm();

AmpAppletLogic.setAlgorithm(alg);

//this should be done before the components

//go to this class to get some data they need.

AmpAppletLogic.init();
 
 

After that, we are ready to create and add the two children GraphicComposite -- objects of the AmplifierCircuit.java and CharacterCurve.java classes into this MainPanel.java. If the coordinate system of any of the children GraphicComposite/GraphicComponent is different from its parent coordinate system, which is this MainPanel, then we need to translate the coordinate into a proper position in its parent's coordinate system. One more thing we need to do is to specify is a child GraphicComposite/GraphicComponent is change or fixed during the applet updates, so that the framework will know which part (the changed part) it needs to redraw and which part (the fixed part) can be stored in a fixed buffer image and redered entirely. If a GraphicComposite/GraphicComponent is fixed, we can specify it by call the

objectOfGraphicComponent.setThisComponentAlwaysChanging(false);

In this MainPanel class, since both the two children GraphicComposite, the AmplifierCircuit part and the CharacterCurve part, contain the moving waveforms, and the moving waveforms are always changed, so we don't need to do anything in this class.

this.aCircuit = new AmplifierCircuit(new Dimension(xCoord,150));

aCircuit.translate(10,20);

this.cCurve = new CharacterCurve(new Dimension(360, 220));

cCurve.translate(10,160);

this.addGraphicComponent(cCurve);

this.addGraphicComponent(aCircuit);

eHandler = new AmpEventHandler(this);

this.addMouseListener(eHandler);

this.addMouseMotionListener(eHandler);