Hi again,
So I’ve solved the problem of the map clearing before a
redraw. It turns out that the problem lied between my monitor and the
back of my chair J. I had been calling RenderManager.refresh() from within a
Job. This wasn’t happening within the Display thread, so putting
the relevant code within a Runnable and calling Display.syncExecute() sorted
things out.
Thanks once again to Jody for taking the time to put me on the
right path.
//Stephen
From: Stephen.Egan@xxxxxxxx
[mailto:Stephen.Egan@xxxxxxxx]
Sent: Thursday, 20 January 2011 3:37 PM
To: jody.garnett@xxxxxxxxx; jesse.eichar@xxxxxxxxxxxxxx
Cc: udig-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: Re: [udig-devel] ApplicationGIS drawMap example
Hi Jody & Jesse,
I’ve made a bit of progress here since yesterday after you
put me on the right track. I adjusted the BasicRenderListener inner class
in BasicFeatureRenderer (eventually found it – Eclipse’s
“Open Type” couldn’t pick it up). Commenting out the
code in the featureRenderer() method that periodically called setState() seems
to get me half of the way there. Now the layer is displayed all in one go
rather than updating on screen.
However, the map is still cleared before the rendering takes
place, whereas I would rather the previous image is maintained until the
updated one is ready, providing a smoother animation. It’s worth
noting that this behaviour only occurs when there is a very large number of
features to render (>12,000 is when it becomes an issue with what I am
doing). I’m fiddling around with the RedrawJob in
RenderExecutorComposite, but so far no luck. I will vandalise RenderJob
next to get the clearBounds() method to do nothing and see if that gets me
closer.
No doubt there is a less idiotic approach that can be taken,
which I’ll be only to delighted to hear about.
Thanks again for your help,
Stephen.
From: Jody Garnett
[mailto:jody.garnett@xxxxxxxxx]
Sent: Thursday, 20 January 2011 3:25 PM
To: Jody Andrew Garnett; Jesse Eichar
Cc: User-friendly Desktop Internet GIS; Egan, Stephen (CES, Highett)
Subject: Re: ApplicationGIS drawMap example
Okay in discussion on IRC the actual request turned out a
bit different.
The idea is to delay a layer refresh; until the entire image
is ready. The idea is to update a style; and not watch the screen draw the new
features in. Since the rendering system is listening to the renderer turn
over and issue events; perhaps we could configure the renderer to only issue an
event when it is "done" ?
Jesse you are a bit more familiar with the rendering system
at this level; could we, place something on the style blackboard and then
modify the BasicFeatureRenderer to issue less events in this case?
On 19/01/2011, at 2:21 PM, Jody Garnett wrote:
Here is a cut&paste of calling AppplicationGIS.drawMap
(it comes from the box preview code used in printing):
public void
createPreview( Graphics2D graphics, final
IProgressMonitor monitor ) {
Dimension
size = getBox().getSize();
preview
= new BufferedImage(size.width, size.height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = preview.createGraphics();
ApplicationGIS.drawMap(new
DrawMapParameter(g, new java.awt.Dimension(
size.width, size.height), this.map, monitor));
current
= new State(map.getViewportModel(),
getBox().getSize());
graphics.drawImage(preview, 0, 0, size.width,
size.height, 0, 0,
preview.getWidth(), preview.getHeight(),
null);
PrintingModelPlugin.log("", e); //$NON-NLS-1$
String message = "Error
rendering Map: " + e.getMessage(); //$NON-NLS-1$
drawErrorMessage(graphics, message);
You
could do something similar to get an image; for use in a View.
To
make a single threaded renderer we could use this code as an example; MapEditor
uses the "widget" MapViewer to get the job done; perhaps we can teach
it to be single threaded using something similar to ApplicationGIS.drawMap.
Out
of curiosity why are you interested in a single threaded renderer?