All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class crw.data2.PlotCanvas2

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----crw.data2.PlotCanvas2

public class PlotCanvas2
extends Canvas
Canvas to hold and plot multiple GraphSets. Each GraphSet consists of x-axis, y-axis, and one or more Data. It is important to set the Axis property properly before attempting to plot the Graphs. The order of graph initialization is as follows:
	
	(1) create a GraphSet object.
	(2) specify axis property:
			(i) set the begining and ending coordinates and 
				location on Canvas.
			(ii) set the values at begining and ending coordinates.
	(3) call the GraphSet.init() method.  This calculates the 
		conversion factors for data values to the x-axis and y-axis scales.
	(4) instantiate and add Data objects to GraphSet by add(Data2).
	(5) add GraphSet object to PlotCanvas2 object.
	(6) add any other GraphSet objects to canvas.
	(7) finally, add the PlotCanvas2 object to applet or application.
	In summary, new GraphSet() => GraphSet.getAxisX().setXXXs()
	=> GraphSet.init() => PlotCanvas2.add(GraphSet) => 
	=> Applet.add(PlotCanvas2).
	In many applications, the axes may be tied to an external
	reference for the coordinates on Canvas.  This can be set 
	using Axis2.setAxisCoordinateRef(AxisCoordinateRef) and 
	specifying the needed info.
	
	For example,
		//(1)
		GraphSet graph = new GraphSet();
		//(2)
		AxisX x = graph.getAxisX();
		x.setLocation(100); // y-coordinate on Canvas
		x.setBegin(150); //beginning x-coordinate
		x.setEnd(50); //ending x-coordinate on canvas
		x.setVBegin(0.24); //Value at begin
		x.setVEnd(3.57); //value at end
		AxisY y = graph.getAxisY();
		y.setLocation(200); //x-coordinate
		y.setBegin(170);//beginning y-coordinate
		y.setEnd(20); //ending y-coordinate
		y.setVBegin(1E12); //value at begin
		y.setVEnd(1E16); //value at end
		//(3)
		graph.init(); //initializes the conversion factors
		//(4)
		graph.add(new MyFunctionData() );
		//(5)
		PlotCanvas2 canvas = new PlotCanvas2();
		canvas.add(graph);
		//(6) add any other graphs
		//(7)
		MyApplet applet = new MyApplet();
		applet.add(canvas);


Constructor Index

 o PlotCanvas2()

Method Index

 o add(GraphSet)
 o paint(Graphics)
 o update(Graphics)

Constructors

 o PlotCanvas2
 public PlotCanvas2()

Methods

 o add
 public void add(GraphSet graph)
 o update
 public void update(Graphics g)
Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Canvas

All Packages  Class Hierarchy  This Package  Previous  Next  Index