[Introduction to figPac | figPac API ]
fig = new Figure(this, 4, 2) ;creates a new Figure named "fig" that is four inches wide and two inches high. The first argument is the instance of the class Container in which the figure is to be drawn. Often the Container is the instance of the class Applet that contains the statement "fig = new Figure(this, 4, 2) ;". In java, the reserved word "this" means the current object. The statement
fig = new Figure(4, 2) ;creates a new Figure named "fig" that is four inches wide and two inches high and is not to be displayed to a computer screen at all.
fig.limits(xmin, ymin, xmax, ymax) ;sets up the coordinate system of the Figure named "fig" so that x=xmin is the left hand edge of the figure, y=ymin is the bottom of the figure and so on. For more about coordinate systems see here.
fig.append( new fLine(10,20, 100,150) ) ;adds to the Figure named "fig" a new line starting at (10,20) and ending at (100,150). Statements of the form
figureName.append( new fSomething(arguments) ) ;are so common that I have built into Figure a bunch of "shortform" methods
figureName.fSomething(arguments) ;whose action is precisely figureName.append( new fSomething(arguments) ) .
In an attempt to reduce the number of keystrokes required to prepare Figures, I have also prepared a "template" class called Template that has built in typical methods for displaying figures. The code that prepares a Figure using this class has the form
import figPac.* ; import java.applet.* ; import java.awt.* ; public class figureName extends Template { static { templateClass = new figureName() ; } public static void setup() { initialization code } public static void prepareFigure(Figure canvas) { figure preparation code } }
The method setup() is used to set the values of various parameters. It may be empty if all the default values are acceptable. The possible variables and their default values are
filePrefix = "myfig" ; // used as the prefix for any ps or lbl files written outputPsFile = true ; outputLblFile = true ; xsize = 3 ; // in inches ysize = 3 ; // in inches xmin = -100 ; xmax = 100 ; ymin = -100 ; ymax = 100 ; useZoom = true ; useDrag = true ; showCoords = true ; showCanvasBoundary = true ;
The method prepareFigure(Figure canvas) is of course used for the actual figure preparation code. I have included in Template a large number of "shortform" methods
fSomething(arguments) ;whose action is precisely
canvas.append( new fSomething(arguments) ) ;as well as some shortform variables liked FILLED which is equal to Figure.FILLED, fCurve.FILLED, fPolygon.FILLED etc.
[Introduction to figPac | figPac API ]