Well, it could very well be that I am missing the big picture, in that I'm
really using the wrong tools to do what I need.
Our application has several layers. Each layer has one or more data
handlers. The data handlers, which all ultimately extend
AbstractLocationHandler, are responsible for populating the OMGraphicList's.
As the application runs, all the information in the various datahandlers
change. I stumbled onto the doPrepare() method as a convenient way to do it
all: regather the graphic objects, project, render and paint, all within
its own SwingWorker thread. I created a manager class that kicks off the
doPrepare() for each layer, then listens for LayerStatusEvent's to
determine when all the threads have completed. When this manager's methods
are called, they don't return until the painting is done, which was
important for us.
I was doing all the necessary calls myself. Using doPrepare() simplifies my
life.
As a side note Don, I had told you awhile ago we would send you some screen
shots and description of our product. We have been waiting for client sign
off, which we now have. See the article below for a description of the
application. We use OpenMap in the GUI to draw all the things going on with
their North American operations.
<http://globalarchive.ft.com/globalarchive/article.html?id=020430000298&query=tom+lloyd>http://globalarchive.ft.com/globalarchive/article.html?id=020430000298&query=tom+lloyd
Jeff
At 01:19 PM 4/30/2002 -0400, Don Dietrick wrote:
>I just wanted to mention a couple of things:
>
>The doPrepare() isn't a standard Layer method - it only exists on certain
>layers. Ed, you may want to check out different OpenMap layers to see how
>it is used, usually to kick off a SwingWorker to tell a layer to re-gather
>graphics, project them and call repaint(). But, if your OMGraphics are
>pretty set, you can create a method (if you don't have one) to just
>project your graphics and call repaint().
>
>How you manage your OMGraphics is completely up to you - you may want to
>create them in the constructor, you may want to provide a method in your
>layer so that other objects can create them. You may even want an object
>in the MapHandler to hold on to them instead of your layer. It all
>depends on how you want to organize and display your data. All a layer is
>*really* responsible for, when you get right down to it, is painting the
>OMGraphics in the right spot on the map relative to other layers
>(depth). You just need to try to make sure that the only thing that gets
>done in the paint() method of a layer is rendering. Doing more makes the
>application feel slower.
>
>I don't think you want the MapHandler to be doing more than it already
>does, which is enabling objects to find each other. If anything, I would
>let a different object create your layer's OMGraphics, and then use the
>MapHandler to let the layer find that object to get the graphics (or vice
>versa). This requires that there some design coordination between the
>layer and the object, but that's cool.
>
>- Don
>
>On Tuesday, April 30, 2002, at 12:04 PM, Jeff Mathis wrote:
>
>>Hi Ed,
>>
>>Glad to see you still hacking away.
>>
>>We do this all the time, as you might know. The key is when an object has
>>been changed, you need to render the graphic and then repaint the layer.
>>
>>The doPrepare() method on Layer does most of this for you. What you have
>>to realize here is that each layer is repainted in its own thread, but if
>>you don't care then no extra handling is needed.
>>
>>Here is a snippet. This method is executed after the user is done
>>dragging a map object to a new location:
>>
>> /**
>> * Specified by the DrawingToolRequestor interface. This method is
>> called after
>> * the edit has been performed on a given location.
>> * @param omg the OMGraphic object, which should be a MapEntity
>> * @param oma the OMAction
>> */
>> public void drawingComplete(OMGraphic omg, OMAction oma) {
>> Debug.message("entitylocationlayer","EntityLocationLayer: called
>> drawingComplete");
>> // reset the text label based on the circles coordinates
>> MapEntity ent = (MapEntity)omg;
>> OMGraphic g = ent.getLocationMarker();
>> com.biosgroup.alac.model.general.Location newloc = null;
>> if (g instanceof OMRect) {
>> OMRect rect = (OMRect)g;
>> ent.setLocation(rect.getNorthLat(), rect.getWestLon());
>> newloc = new
>> com.biosgroup.alac.model.general.Location((float)rect.getNorthLat(),
>> (float)rect.getWestLon());
>> } else if (g instanceof OMCircle) {
>> OMCircle circ = (OMCircle)g;
>> LatLonPoint l = circ.getLatLon();
>> ent.setLocation(l.getLatitude(), l.getLongitude());
>> newloc = new
>> com.biosgroup.alac.model.general.Location((float)l.getLatitude(),
>> (float)l.getLongitude());
>> }
>> ((Locatable)ent.getAppObject()).setLocation(newloc);
>> g.setVisible(true);
>> ApplicationState.fireApplicationChangeEvent(
>> new ApplicationChangeEvent(this,
>>
>>ApplicationChangeEvent.LOCATION_EDITED));
>> }
>>
>>then, when the ApplicationChangeEvent is received by my layer manager, it
>>calls doPrepare() on the layer to repaint itself.
>>
>>At 09:40 PM 4/29/2002 -0600, Ed MacKerrow wrote:
>>
>>>Dear OpenMappers,
>>>
>>>I am still on the steep end of the OM learning curve and I think I
>>>missing out on the "bigger picture".
>>>
>>>I have built a few layers that I have been able to display my objects
>>>on, however, I did this by instantiating the objects, which are
>>>displayed by association with a OMGraphic that has the same (lat,lon)
>>>as the App objs. The mistake that I believe I have done, is to
>>>instantiate these objects and OMGraphics by calling a "buildObjs()"
>>>method from inside the constructor for the layer. The layer constructor
>>>is invoked from the properties file call (i.e. like in the OpenMap
>>>app). Should I be instantiating these objects from a mapHandler instead?
>>>
>>>The reason I am asking is that I don't know how to update the positions
>>>of those objects on the layer, since I do not have an instantiated
>>>object that represents my layer class. I guess my basic question is:
>>>
>>>How do I update the position values of objects that are displayed on a
>>>layer? ( are there any simple examples of updating the positions of
>>>objects that are displayed on a layer out there?)
>>>
>>>Thanks for your help,
>>>
>>>ed
>>
>>Jeff Mathis
>>Senior Scientist / Group Leader
>>BiosGroup, Inc.
>>317 Paseo de Peralta
>>Santa Fe, NM 87501
>>direct: 505-992-6737
>>fax: 505-988-2229
>>jeff.mathis@biosgroup.com
>>http://www.biosgroup.com
>>
>>--
>>[To unsubscribe to this list send an email to "majdart@bbn.com"
>>with the following text in the BODY of the message "unsubscribe
>>openmap-users"]
>>
>
>
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>Don Dietrick, BBN Technologies, dietrick@bbn.com
>10 Moulton Street, Cambridge, MA 02138
>617-873-3031 [fax]-2794
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Jeff Mathis
Senior Scientist / Group Leader
BiosGroup, Inc.
317 Paseo de Peralta
Santa Fe, NM 87501
direct: 505-992-6737
fax: 505-988-2229
jeff.mathis@biosgroup.com
http://www.biosgroup.com
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Tue Apr 30 17:27:50 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT