Re: [OpenMap Users] OMGraphicHandlerLayer's mouseModes issue

From: Don Dietrick <dietrick_at_bbn.com>
Date: Wed, 13 Sep 2006 08:39:08 -0400

Hi Stephane,

If you were going to make the call a lot, I'd make your Layer a
LayerListener and add it to the LayerHandler as such, so it's always
told of the latest layers being added to the MapBean.

If this is a more intermittent operation and you don't want your
layer in the LayerEvent notification loop, you could call:

MapHandler mh = (MapHandler) getBeanContext();
LayerHandler lh = (LayerHandler) mh.get
(com.bbn.openmap.LayerHandler.class);
Layer[] layers = lh.getCurrentLayers();

And get the active layer stack directly from the source.

- Don


On Sep 13, 2006, at 4:14 AM, Stéphane Wasserhardt wrote:

> Hi Don,
>
> It's exactly the problem. I already found that calling
> setupMouseModeWithLayers() would solve the problem, but then I have
> to get the layers array from the layer which want to set new mouse
> modes ids list.
> In order to get this array, my layer needs to hold a reference to
> the layerHandler (since the MouseDelegator doesn't give public
> access to its "currentLayers" mermber), which is something I'd like
> to avoid. So this solution is not a really good one for me.
> That's why the only way I found to call setupMouseModeWithLayers()
> was to subclass the MouseDelegator in order to add the following
> methods :
>
> public Layer[] getCurrentLayers() {
> return currentLayers;
> }
>
> public void layersMouseModesChanged() {
> setupMouseModesWithLayers(getCurrentLayers());
> }
>
> Note that the latter one is not really needed, it's just a helper...
>
> The only bad thing about this workaround is that I must ensure I'm
> using this new MouseDelegator class in my application, and my layer
> must check if the MouseDelegator is an instance of this class to
> call the layersMouseModesChanged() method...
> Maybe adding a "getCurrentLayers()" method in MouseDelegator would
> be an improvement for future releases ? That's not necessary at all
> since the layer can get a reference to the layerHandler through the
> beanMembership... I don't really know what's the best way to handle
> this...
>
> Thank you for your help, and also for the "graphics.create()" hint
> (for paintListeners) !
>
> Stephane
>
> Le 23:43 12/09/2006,Don Dietrick écrit:
>> Hi Stephane,
>>
>> It looks like everything gets reset when the layers change in the
>> MapBean, i.e. when the LayerHandler sends out it's LayerEvent that
>> the MapBean (and LayerMenu/MouseDelegator) receive.
>>
>> You can get the MouseDelegator to reset the ids programatically by
>> calling setupMouseModeWithLayers(Layer[]).
>>
>> - Don
>>
>> On Sep 8, 2006, at 9:19 AM, Stéphane Wasserhardt wrote:
>>
>>> Hello !
>>>
>>> I think there's an issue with the "setMouseModeIDsForEvents" method
>>> in OMGraphicHandlerLayer.
>>>
>>> Here is what I understood :
>>>
>>> This method is called in OMGraphicHandlerLayer.setProperty(...),
>>> that is to say BEFORE the layer is added to the beanContext.
>>> When the layer is added to the beanContext, an event is fired. This
>>> event reaches the mouseDelegator which calls its
>>> "setupMouseModeWithLayers" method. Then the mouseDelegator will
>>> forward any mouse events to the layer if the current mouse mode id
>>> is one of the ids given in setMouseModeIDsForEvents.
>>> The same thing also happens when a new mouseMode is added to the
>>> beanContext.
>>>
>>> Here is the issue I found :
>>>
>>> I put all mouseModes and all layers I need in the beanContext.
>>> AFTER that, I change the mouseModeIDs of one of the
>>> OMGraphicsHandlerLayers, using setMouseModeIDsForEvents.
>>> No more layers and no more mouseModes will be added the the
>>> beanContext after that, so no event will ever reach the
>>> mouseDelegator.
>>> The mouseDelegator's setupMouseModeWithLayers method will never be
>>> called again, that's why the layer will not recieve any awaited
>>> mouse events :-(
>>>
>>> Maybe I'm missing something here...
>>> If this is a real bug, I don't know how to properly correct it,
>>> because I'm not used enough to this mechanism.
>>> I think I will use some kind of workaround for the moment, until I
>>> recieve some answer from this list...
>>> So, any comments would be really appreciated! Thanks in advance!!
>>>
>>> Stephane
>>>
>>> --
>>> [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"]
>>
>>
>>
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>> Don Dietrick, dietrick_at_bbn.com
>> BBN Technologies, Cambridge, MA
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>
>>
>>



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 Wed Sep 13 2006 - 08:41:24 EDT

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