[OpenMap Users] OMGraphicList and appObject

From: Tore Halset <halset@pvv.ntnu.no>
Date: Tue Feb 27 2007 - 08:49:20 EST

Hello.

All my OMGraphics have appObject to point back to the underlying
feature object. In a Layer I can then do a prepare().findAll(...) if
a user wants information about some features.

This works pretty well in most situations, but not so elegant for
features that need a OMGraphicList to represent the view. The problem
is that OMGraphicList.setAppObject does not make sure all the
graphics in the list have the same appObject, so findAll() may return
OMGraphics without a appObject.

To overcome this problem I have created my own subclass of
OMGraphicList that overrides setAppObject to set appObject on all
subgraphics as well and _add to set the appObject on OMGraphics added
at a later point in time. See attached code.

Do you think this should be the default behaviour of OMGraphicList?
Any reason to why this may *not* be a good

(On a side note: I sure hope it (in the future) will be possible to
still have the appObject as a single Object ref and not a Map as I
operate with a huge number of OMGraphics and do not want all those
extra Map-objects.)

Regards,
  - Tore.

     public synchronized void setAppObject(Object obj) {
         super.setAppObject(obj);

         for (Iterator it = iterator(); it.hasNext();) {
             OMGraphic g = (OMGraphic) it.next();
             if (g.getAppObject() == null) {
                 g.setAppObject(obj);
             }
         }
     }

     protected synchronized void _add(OMGeometry g) {
         Object appObject = getAppObject();
         if (g.getAppObject() == null) {
             g.setAppObject(appObject);
         }

         super._add(g);
     }

--
[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 Feb 27 08:59:08 2007

This archive was generated by hypermail 2.1.8 : Tue Feb 27 2007 - 08:59:58 EST