[Introduction to figPac | figPac API ]
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. 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) ; (fig.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 and that both arrays were previously defined.
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. 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" ; }In both drawgfx and drawps, the values of the appropriate environment variables are to be taken from env.
[Introduction to figPac | figPac API ]