[udig-devel] dpi issues
Jody Garnett
jgarnett at refractions.net
Fri Mar 28 13:59:12 PDT 2008
Vince Darley wrote:
>>> Is it possible to have udig render directly to the Graphics2D
>>> supplied rather than render first to images (for each layer) which
>>> are then copied to the Graphics2D?
>> Yes; that is what the printing system does when printing to paper.
>> The udig renderer api has an entry point that takes a Graphics2D
>> (rather than a raster).
> Any pointers for how to do that (a name of a class or something)? (Or
> suggestions on how to modify ApplicationGIS.drawMap() to allow this
> possibility?)
I don't have the code open in front of me; off the top of my head I
would sent up a rendering stack and ask it to draw one layer at a time
onto the Graphic2D I got from the printer...
Let me open up the code and see how close my answer is...
1. net.refractions.udig.printing.ui.internal.PrintAction, sets up a
PrinterJob
2. there is a net.refractions.udig.printing.ui.internal.PrintingEngine
that does the work...
3. that goes ahead and calls box.getBoxPrinter().draw(graphics2d, monitor);
4. looking at BoxPrinter subclasses I can find MapBoxPrinter
5. which calls ApplicationGIS.drawMap(new DrawMapParameter(graphics,
awtSize, getMap(), monitor));
6. stepping through the code I see it using the graphics as passed in as
a DrawMapParameter; calling clearRectangle etc...
7. RendererCreator is called to sort out which Renderer is needed for
each layer
8. Eventually each renderer is called with: renderer.render((Graphics2D)
params.graphics.create(), monitor);
9. That is they are called with a copy of the origional graphics2d; that
will let them directly renderer to whatever is backing the render
(printer, svg, etc...)
A couple notes:
- I remember a printing bug when the graphics 2d state was not reset;
and layers got smaller and smaller each run due to scaling. W
- If needed we could push & pop state grraphics 2d state - and avoid the
graphics2d create() (which is really more like a clone) if some
implementations like Batick cannot handle it
- the normal rendering path used for the screen is different in that it
is threaded and several images can be created for different renderers to
work on at the same time (you can see the seperate images in action if
you turn on the Mylar effect)
Cheers,
Jody
>
>
> Vince.
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
More information about the udig-devel
mailing list