|
From: John A. T. <ja...@ja...> - 2005-10-11 17:27:57
|
The main rendering class is given an output object and a tile object, and
renders the tile on the output device. The output object implements an
interface containing usual graphics primites, such as setting the clipping
region, drawing lines, arcs, polygons, text, etc. Colors and other
parameters are abstracted out using style objects -- this is important
because screen drawing will need to use RGB while most printing needs CMYK
to get accurate colors, plus the user may want to tweak the color mapping
for thier display (personally my preference would be to have the user
properly calibrate their display but there may be other reasons such as
accessibility to color blind users).
A particular instance of an object that implements the Output interface
(possibly an abstract class if we need to share some methods between
subclasses) is created external to the rendering code, including whatever
additional context is needed. For example, a graphical Output subclass
might have a handle to GUI object that it will draw on, while a Postscript
renderer might have a file handle on which it is to write the PS code as
well as parameters describing how the PS code is to be generated (such as
EPSF compliant). All positions passed to the Output object are in polar
coordinates centered at the center of the tile and scaled by the size of
the tile, so the Output object is responsible for scaling and positioning
the final output. Here is a snippet of how some map drawing code might
use it:
Render render;
FileWriter outputFile=new FileWriter("output.ps");
OutputPS output(outputFile,62.35385); // size in points for tile
output.setOrientation(OutputPS.LANDSCAPE);
output.generateHeader();
for(int row=0; row<nrows; row++) {
for(int col=0; col<ncols; col++) {
output.position(computePosition(row,col));
Tile tile=getMapTile(row,col);
render.drawTile(output,tile);
}
}
output.generateTrailer();
Does this plan fit with what you want in rails?
--
John A. Tamplin ja...@ja...
770/436-5387 HOME 4116 Manson Ave
Smyrna, GA 30082-3723
|