Re: [OpenMap Users] Destroying a layer?

From: Don Dietrick <dietrick@bbn.com>
Date: Mon Feb 23 2004 - 04:09:51 EST

The layer.added() method is called when the layer is added to the
MapBean, as a Component notification.

The layer.removed() method is called when the layer is removed from the
MapBean, but that call is delayed until after the projection changes in
the MapBean.

The prepare() method in the OMGraphicHandlerLayer is called whenever a
new projection is received by the OMGHL, which occurs when the layer is
added to the MapBean, and thereafter when the projection changes (pans,
zooms, resizes, projection type changes). If the layer already has the
current projection when projectionChanged is called, prepare() won't be
called.

If the LayerHandler is being used to control layers on the MapBean, the
layer's visibility will change when the layer is added and removed from
the MapBean. A ComponentListener to the layer will receive
ComponentEvents for visibility changes.

The apparent overlap between the projectionChanged(), added and removed
methods allow a subtle optimization when the map is toggled on and off
the Map. If the Layer is removed and added to the MapBean without the
projection changing, the visibility will be toggled, and only
added/projectionChanged will be called. The layer won't know it wasn't
part of the map. You don't want the layer to do extra work to present
itself again for the same projection it has, so it doesn't. That's why
the removed call is delayed until after the projection changes in the
MapBean.

- Don

On Feb 22, 2004, at 2:36 PM, Ben Podoll wrote:

> By the way I also want to know where I should put code that should
> only be
> called when the layer is toggled on...
>
> The reason I am asking this stuff is that I have huge datasets that
> take a
> lot of memory and I need to get them out of memory when they are
> toggled off
> (but also need to setup some objects when it is toggled on, and only
> when it
> is toggled on)
>
> I am under the impression that the prepare method is the one that gets
> called when the layer is added, but also when any repainting is needed
> (resizing, new layer added, etc.), right?
>
> \\\ ///
> ( o o )
> +---.oOOo-( )------------------
>
> Ben Podoll
> 701-772-7152
> benjamin.podoll@und.edu
>
> .ooo0
> ( ) 0ooo.
> +----\ (----oOOo.--( )-------
> \_) ) /
> (_/
>
>
> YOU>-----Original Message-----
> YOU>From: Don Dietrick [mailto:dietrick@bbn.com]
> YOU>Sent: Sunday, February 22, 2004 1:13 PM
> YOU>To: Ben Podoll
> YOU>Cc: openmap-users@bbn.com
> YOU>Subject: Re: [OpenMap Users] Destroying a layer?
> YOU>
> YOU> From the javadocs:
> YOU>
> YOU> /**
> YOU> * This method is called after the layer is removed from the
> YOU> * MapBean and when the projection changes. We recommend
> that
> YOU> * Layers override this method and nullify memory-intensive
> YOU> * variables.
> YOU> * @param cont Container
> YOU> */
> YOU>
> YOU>Note that it gets called after the projection changes. That way,
> YOU>toggling the layer on/off doesn't force extra work to be
> performed by
> YOU>the layer.
> YOU>
> YOU>- Don
> YOU>
> YOU>
> YOU>On Feb 22, 2004, at 1:52 PM, Ben Podoll wrote:
> YOU>
> YOU>> I added this to my layer and it never fires (when I remove my
> YOU>layer)...
> YOU>>
> YOU>> //---Called when the layer is removed
> YOU>> public void removed(Container c){
> YOU>> System.out.println("I am being removed.");
> YOU>> }
> YOU>>
> YOU>> Do I need to do more than this for my class declaration...
> YOU>>
> YOU>> public class MyLayer extends OMGraphicHandlerLayer {
> YOU>>
> YOU>> Also I see an added method, is that simpliar to prepare?
> YOU>>
> YOU>>
> YOU>> \\\ ///
> YOU>> ( o o )
> YOU>> +---.oOOo-( )------------------
> YOU>>
> YOU>> Ben Podoll
> YOU>> 701-772-7152
> YOU>> benjamin.podoll@und.edu
> YOU>>
> YOU>> .ooo0
> YOU>> ( ) 0ooo.
> YOU>> +----\ (----oOOo.--( )-------
> YOU>> \_) ) /
> YOU>> (_/
> YOU>>
> YOU>>
> YOU>> -------Original Message-----
> YOU>> --From: owner-openmap-users@bbn.com [mailto:owner-openmap-
> YOU>> --users@bbn.com] On Behalf Of Don Dietrick
> YOU>> --Sent: Saturday, February 21, 2004 10:14 PM
> YOU>> --To: Ben Podoll
> YOU>> --Cc: openmap-users@bbn.com
> YOU>> --Subject: Re: [OpenMap Users] Destroying a layer?
> YOU>> --
> YOU>> --Hi Ben,
> YOU>> --
> YOU>> --There's a removed(Container c) method that the layer can
> use
> YOU>to
> YOU>> find
> YOU>> --out when its been removed from the map. By default, it
> YOU>doesn't
> YOU>> do
> YOU>> --anything. That action a layer takes is determined by the
> YOU>layer
> YOU>> --author.
> YOU>> --
> YOU>> --- Don
> YOU>> --
> YOU>> --On Feb 21, 2004, at 6:06 PM, Ben Podoll wrote:
> YOU>> --
> YOU>> --> If I extend the OMGraphicHandlerLayer and do my
> drawing, the
> YOU>> --prepare
> YOU>> --> method
> YOU>> --> is called when the layer is turned on, but what if the
> layer
> YOU>> is
> YOU>> --> removed, is
> YOU>> --> there a method (like destroy)? And if not does all the
> YOU>images
> YOU>> I
> YOU>> --drew
> YOU>> --> stay in
> YOU>> --> memory or do they get removed by something internal?
> YOU>> -->
> YOU>> --> \\\ ///
> YOU>> --> ( o o )
> YOU>> --> +---.oOOo-( )------------------
> YOU>> -->
> YOU>> --> Ben Podoll
> YOU>> --> 701-772-7152
> YOU>> --> benjamin.podoll@und.edu
> YOU>> -->
> YOU>> --> .ooo0
> YOU>> --> ( ) 0ooo.
> YOU>> --> +----\ (----oOOo.--( )-------
> YOU>> --> \_) ) /
> YOU>> --> (_/
> YOU>> -->
> YOU>> -->
> YOU>> -->
> YOU>> -->
> YOU>> --> --
> YOU>> --> [To unsubscribe to this list send an email to
> YOU>> "majdart@bbn.com"
> YOU>> --> with the following text in the BODY of the message
> YOU>> "unsubscribe
> YOU>> --> openmap-users"]
> YOU>> -->
> YOU>> --
> YOU>> ----
> YOU>> --[To unsubscribe to this list send an email to
> YOU>"majdart@bbn.com"
> YOU>> --with the following text in the BODY of the message
> YOU>"unsubscribe
> YOU>> --openmap-users"]
> YOU>>
> YOU>>
> YOU>> --
> YOU>> [To unsubscribe to this list send an email to "majdart@bbn.com"
> YOU>> with the following text in the BODY of the message "unsubscribe
> YOU>> openmap-users"]
> YOU>>
>
>

--
[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 Mon Feb 23 04:11:03 2004

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