TOC
Create CharacterCurve.java:

In the low part, there are the Characteristic Curves of BJT and the input and output waveforms of the single-stage common-emmiter amplifier. So we can have a class CharacterCurve.java represent this part and make it a GraphicComposite and have it contain the BJT characteristic curves and the waveforms as its children GraphicComponents.

The CharacterCurve.java is inherited from the GraphicComposite.java class. It contains the objects of its children GraphicComponents classes -- the PlotCurves.java, which draws the BJT's characteristic curve and the WaveformGraph.java, which represents the movingwaveform set -- the inputand output waveforms. Both of these classes are inherited from GraphicComponent.java class.

The constructor of the CharacterCurve.java class receives a parameter imgSize as its arguemnt. The type of imgSize is Dimension. It is the image size of this GraphiComposite. In the constructer of a GraphicComposite.java's subclass, the first thing we need to do is to call its super class the GraphicComposite.java class to set up the image size. In the constructor of CharacterCurve.java the first statement is

super(imgSize);

to pass the imgSize to its super class and set up the parameter in the super class.

Next we are ready to instantiate the two GraphicComponents -- the BJT characteristic curve and the moving waveforms set, which is composed by the amplifier's input and output waveforms.

We first instantiate the objects of the classes -- PlotCurves.java and WavefromGraph.java. Each of these two classes is a GraphicComponent and hense should be inherited from the GraphicComponent.java class.

Now, the GraphicComponent.java has two constructors. One needs no argument and the other receives an image size as the argument of Dimension type. This one argument represents the image size of the GraphicComponent. If a GraphicComponent is a fixed during an operation, then it can be saved in a fixed image buffer and the argument image size is used by the top-level GraphicComposite to construct the image buffer for this GraphicComponent. If, on the other hand, a GraphicComponent is always changed, then we don't need a fixed buffer image to save it and when the screen is updated, the GraphicComponent is drawn directly into its parent GraphicComposite's image buffer. In this case we can use the constructor of the GraphicComponent.java class, which has no argument.

Since the BJT character curve is a fixed part in the applet, and we need a buffer image to save its graphic. In contrast, the input and output waveforms in the moving waveform set are always changed. According to the above description, now let's create the objects of the two GraphicComponents class.

//create the image size for the GraphicComponent -- the characteristic curve

Dimension imageSize = new Dimension(320, 195);

//at this point, don't worry about the plotSize, this is needed by the plotCurve.java class,

//not by the GraphicComponent.java class.

Dimension plotSize = new Dimension(width, height);

//instantiate the object of the PlotCurve.java class

plot = new PlotCurves(imageSize, plotSize, loadLineData);

//add the plotcurve GraphicComponent to its parent GraphicComposite,

//which is this CharacterCurve.java class

this.addGraphicComponent(plot);

//then translate it into a proper position

plot.translate(xPos_curve, yPos_curve);

//since the characteristic curve is fixed, we set the state by the following call

plot.setThisComponentAlwaysChanging(false);
 
 

Next, we are going to create the moving waveform set.

//construct an object of the WaveformGraph.java class -- called graph

//the WaveformGraph component for the moving waveforms.

//here the noWaves = 2, since we have two moving waveforms in the moving waveform set, //the input and the output waveform

//the length of each waveform

int[] length = new int[noWaves];

for(int i=0; i<noWaves; i++)

length[i]=(int)(AmpAppletLogic.period/2);

//the offset of each waveform

int[] offset = new int[noWaves];

offset[0] = 0;

offset[1] = 0;

//the orientation of each of the waveforms, HORIZONTAL and VERTICAL are of type int

int[] orientation = new int[noWaves];

orientation[0] = HORIZONTAL; orientation[1] = VERTICAL;

//create the object of the moving waveform set

graph = new WaveformGraph(length, offset, noWaves, orientation);

//add the moving waveform set GraphicComponent to its parent GraphicComposite class,

//which is this CharacterCurve.java class

this.addGraphicComponent(graph);

//translate it into a proper position

graph.translate(xPos_wave, yPos_wave);
 
 

Once we have got all the children GraphicComponents -- the characteristic curve and the moving wavefrom set -- ready, this GraphicComposite is done. Again, this is simplified sample of the construction of the Single-Stage Common-Emmiter Amplifier applet. It just works as a tutorial of How to use the Framework. The actual program of the Single-Stage Common-Emmiter Amplifier applet is much more complicated and is not appropriate to serve as a tutorial. Please refer to the applet program for details.

One more thing that we can do in a GraphicComposite object or a GraphicComponent object (Note for GraphicComponent object, it must have a non-zero image size as its constructor's argument) is that we can draw a fixed background image by implementing the method drawThisCompFixedImg(). If this method is left blank, then there is no background for this GraphicComposite/GraphicComponent.