Re: [OpenMap Users] Openmap and threads

From: Don Dietrick <>
Date: Tue, 22 Mar 2005 12:36:00 -0500

On Mar 22, 2005, at 10:36 AM, Andrew Schulak wrote:

> I was wondering if there is a guide available discussing openmap and
> threading?

Kind of, there's information in the Developer's Guide:

> In particular, I am wondering what thread the following operations
> should be run on (Swing event thread, or a worker thread like
> SwingWorker)
> - Centering the map with mapBean.setCenter
> - Changing the map scale

I looked into doing this, but it often leads to an indeterminate state
due to how the layers react to those events. It shouldn't be a problem
if the layers are doing the right thing and launching a SwingWorker
thread to do work. Support for the SwingWorker thread is built into
the OMGraphicHandlerLayer. If you do your work for the layer in the
prepare() method, the layer is smart enough to respond to
projectionChanged() method calls by calling its doPrepare() method -
doPrepare() launches a SwingWorker thread to call prepare().

> - Adding graphics to an OMGraphicHandlerLayer

Maybe. That's pretty application specific. You could launch any
runnable to do this, though.

> In specific, let's say on a button click I want to :
> - Add a graphic to a layer
> - change the scale of the projection
> - center the map
> What thread should all of this happen on, or what threads?

For adding *a* graphic, or several, I would just use the event thread.
If you have to do work to figure out what graphics to add to a layer,
then launch a thread. I wouldn't use a SwingWorker thread for that,
create your own Runnable and have it call a method on the layer when
it's ready to.

For changing the projection on the Map, just use the event thread.
Again, though, if you have to do a lot of work to figure out what the
new projection should be, launch a thread.

- Don

Don Dietrick,
BBN Technologies, Cambridge, MA

[To unsubscribe to this list send an email to ""
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Mar 22 2005 - 12:36:46 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT