Re: [OpenMap Users] BasicGeometry.setAttribute woes

From: Don Dietrick <dietrick_at_bbn.com>
Date: Mon, 4 Apr 2005 15:08:03 -0400

Hi Thomas,

It's a bug in the BasicGeometry class, I've fixed it. This method
needs to be replaced in your version:

     /**
      * A call used by the BasicGeometry to replace a current
      * appication object with an Object Map while also adding that
      * application object to the Map under the APP_OBJECT_KEY key
      * value.
      */
     protected void replaceAppObjectWithAttributeMap() {
         if (!checkAttributeMap()) {
             // OK, we know we need to create a Map for the attributes,
             // and place it in the appObject of this BasicGeometry.
             // So, get whatever is already there,
             Object appObj = getAppObject(false);

             // Create the new Map, set a pointer to itself so we know
             // it's the attribute Map (and not just replacing a Map
             // that someone else was using before
             Map attributes = createAttributeMap();
             attributes.put(ATT_MAP_KEY, attributes);
             setAppObject(attributes, false);

             // Now, set the old appObject if appropriate.
             if (appObj != null) {
                 attributes.put(APP_OBJECT_KEY, appObj);
             }
         }
     }

The problem is that the attribute hashtable wasn't being set properly
with a self-pointing entry (which lets it know that the attribute table
is indeed itself, instead of a user-set appObject Map set previously).
This was affecting the first attribute set.

- Don


On Apr 4, 2005, at 1:26 PM, Lepkowski, Thomas M., CTR, OSD-PA&E wrote:

> Classification: UNCLASSIFIED
>  
>  
> Hello,
>  
> Has anybody run into difficulty using setAttribute or getAttribute?
>  
> I can get an OMGraphic object to store attributes if I say
>  
> <code>
> ...
> omg.setAttributes( new HashMap() );  // line 10
> omg.putAttribute(SOME_KEY, someData );
> omg.putAttribute(ANOTHER_KEY, someOtherData );
>  
> // then later in the code
> System.out.println( "SOME_KEY =>" +omg.getAttribute(SOME_KEY) );  //ok
>  
> //does NOT print null because line 10
> System.out.println( omg.getAttribute(ANOTHER_KEY)  );
>  
>  
> OMPoint omPt = new OMPoint();
>  
> //   everything works so far
>  
> // now I want to replace omg with omPt
> // I need to swap app attributes.
>  
> // THIS BREAKS
> omPt.setAttributes(  omg.getAttributes() );  //line 468
>  
> </code>
>  
> Here's the Exception: 
>  
> <dump>
>
> java.lang.NullPointerException
>
> at java.util.Hashtable.put(Unknown Source)
>
> at
> com.bbn.openmap.omGraphics.geom.BasicGeometry.setAttributes(BasicGeomet
> ry.java:407)
>
> at com.bbn.openmap.layer.UnitsLayer.replaceOMGraphic(MyLayer.java:468)
>
> </dump>
>
> Debug print of omg.getAttributes() showing key => value pairs :
>
> the Map size=4
>
> 2 => someData
>
> app_object_key => {app_object_key=null}
>
> 1 => someOtherDate
>
> att_map_key => {2=someData, app_object_key={app_object_key=null},
> 1=someOtherData, att_map_key=(this Map)}
>
>  
> Any Ideas?
>  
>  
>  
>  
> -----Original Message-----
> From: owner-openmap-users_at_bbn.com
> [mailto:owner-openmap-users_at_bbn.com]On Behalf Of Tobias Gorgs
> Sent: Saturday, April 02, 2005 3:19 AM
> To: openmap-users_at_bbn.com
> Subject: [OpenMap Users] DTED
>
>
> Hi,
>  
> I have two questions about DTEDLayers.
>  
> 1) How is it possible to change the Opaqueness of a DTEDLayer?
> This is how I tried it:
>    
> dtedLayer.setOpaqueness(135);
> dtedLayer.doPrepare();
>    
> This lines of code should be processed, when a special button of my
> user interface is         pressed. If I ask for the new opaqueness
> (getOpaqueness()) the value is 135. But nothing     happens. The
> DTEDLayer is already added to the MapHandler. If I let OpenMap show
> the palette to change DTED-Properties it works. Any ideas?
>  
> 2) Is it possible to remove a DTEDLayer from the MapHandler and later
> add it again? I want to show DTED Level 0 until a defined scale-level
> is reached and then show DTED Level 1. To save memory I thought I
> remove DTED Level 1 until the application has the defined scale and
> then add it. Is this the right idea?
>  
> I already tried with:
> mapHandler.remove(dtedLayer);
> mapHandler.add(dtedLayer);
>  
> The boolean which is returned is true for both lines of code. After
> the layer was removed it isn`t shown at the map anymore. This is
> great, but after I added the layer - it doesn`t appear on my map
> either. Can anyone help me with this topic?
>  
> Thanks a lot.
> Tobi
>  
>  
>


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Apr 04 2005 - 15:09:42 EDT

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