Re: Basic question -- I am missing the "big picture" ...

From: Jeff Mathis <jeff.mathis@biosgroup.com>
Date: Tue Apr 30 2002 - 12:04:46 EDT

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"]
Received on Tue Apr 30 12:05:30 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT