All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface figPac.fElement

public interface fElement
A figure element is any instance of any class that implements the interface fElement. This means that it must contain two methods with signature
public void drawgfx(Figure fig, Hashtable env, V2V usr2pxl) ;
public String drawps(Figure fig, Hashtable env, V2V usr2ps) ;
The job of the first is to take the figure element, use usr2pxl to represent it in pxl coordinates (which has the origin at the upper left hand corner and uses as a unit one pixel) and plot the result in the Graphics object of fig. The job of the second is to take the figure element, use usr2ps to represent it in postscript coordinates (which has the origin at the lower left hand corner and uses as a unit one Adobe point, which is 1/72 inch) and return a string which plots the result in postscript. In both, the values of the appropriate environment variables are to be taken from env.


Method Index

 o drawgfx(Figure, Hashtable, V2V)
The job of this method is to plot the figure element in the Graphics object of the Figure fig.
 o drawps(Figure, Hashtable, V2V)
The job of this method is to return a string which plots the figure element in postscript.

Methods

 o drawgfx
 public abstract void drawgfx(Figure fig,
                              Hashtable env,
                              V2V usr2pxl)
The job of this method is to plot the figure element in the Graphics object of the Figure fig. It should first use usr2pxl to represent the figure element in pxl coordinates (which has the origin at the upper left hand corner and uses as a unit one pixel). The values of the appropriate environment variables are to be taken from env. For example, here is a drawgfx which draws a line
public void drawgfx(Figure fig, Hashtable env, V2V usr2pxl) {
double[] pxlfrom, pxlto ;
pxlfrom = usr2pxl.map(from) ;
pxlto  =  usr2pxl.map(to) ;
gfx.drawLine((int)pxlfrom[0],(int)pxlfrom[1],
(int)pxlto[0],(int)pxlto[1]) ;
}
This routine assumes that the starting point of the line is a two component aray called from and that the end point of the line is a two component array called to.

 o drawps
 public abstract String drawps(Figure fig,
                               Hashtable env,
                               V2V usr2ps)
The job of this method is to return a string which plots the figure element in postscript. It should first use usr2ps to represent the figure element in postscript coordinates (which has the origin at the lower left hand corner and uses as a unit one Adobe point, which is 1/72 inch). The values of the appropriate environment variables are to be taken from env. Here is the example which handles a line
public String drawps(Figure fig, Hashtable env, V2V usr2ps) {
double[] psfrom, psto ;
psfrom = usr2ps.map(from) ;
psto  =  usr2ps.map(to) ;
return "newpath\n"
+psfrom[0]+"  "+psfrom[1]+"  moveto\n"
+psto[0]+"  "+psto[1]+"  lineto stroke\n" ;
}


All Packages  Class Hierarchy  This Package  Previous  Next  Index