Re: [OpenMap Users] Implementing a Layer that Hijacks Mouse Clicks

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Mon, 21 May 2012 10:21:06 -0400

Yes, if you are going to extend the OverlayMapPanel, you have to
create your own application class, by extending Main or writing your
own. I think I've done both in one class, doing an inline override of
certain OverlayMapPanel methods when it was instantiated in my
overridden Main class.

- Don

On Mon, May 21, 2012 at 10:09 AM, Renton Ian
<ian.renton_at_uk.atlas-elektronik.com> wrote:
>
> Thanks, extending OverlayMapPanel definitely looks like a better way to go.
>
> One more question though: Is there a way to specify my OverlapMapPanel child from the properties file?  AFAICS there isn't - OverlayMapPanel is specifically requested by name from the Main class rather than by a property.  So would I also have to extend the Main class to get it to load my OverlayMapPanel instead of the default?
>
> Thanks again,
>
> Ian
>
> --
> Ian Renton
> UX / Software Engineer
> ATLAS ELEKTRONIK UK
> Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
> Tel: +44 (0) 1305 212341
> -----Original Message-----
> From: Don Dietrick [mailto:dfdietrick_at_gmail.com]
> Sent: 18 May 2012 16:12
> To: Renton Ian
> Cc: openmap-users_at_bbn.com
> Subject: Re: [OpenMap Users] Implementing a Layer that Hijacks Mouse Clicks
>
> Hi Ian,
>
> I would probably go the route of using OverlayMapPanel and embed Swing components on top of the map - if only for this reason: you probably don't want the layer with the controls showing up as an overlay in the LayerHandler or any other layer controls.
>
> You could do what you want with an OMGraphicHandlerLayer - when your 'button' gets clicked on select gets called, but you can control what happens after that at the layer level, you don't have to get the drawing tool involved.
>
> The OMGraphicHandlerLayer method receivesMapEvents usually returns false, which cause the events not occurring over OMGraphics to fall through to lower layers.  I'd check to make sure you're not overriding that method if nothing is getting through to lower layers.
>
> If you want to get a little deeper, you can extend the MapMouseInterpreter your layer uses and have it do a bunch of different things.  That object is used by the OMGraphicHandler layer to figure out what the mouse events are doing and how they are affecting the OMGraphics on it.
>
> To put application controls on the map, though, I'd go the OverlayMapPanel route, and override layoutPanel() as you need.
>
> - Don
>
> On Fri, May 18, 2012 at 4:04 AM, Renton Ian <ian.renton_at_uk.atlas-elektronik.com> wrote:
>> Don,
>>
>> Thanks for your reply.
>>
>> I'm trying to implement a layer that sits on the top of the layer stack and displays various information, but that the user can also click on elements of, e.g. "click here to expand this section" or "click here to hide" buttons.
>>
>> I am drawing these elements using OMGraphic types, and extending OMGraphicHandlerLayer, but I want the layer to handle mouse clicks on the elements in special ways rather than the standard OMGraphic-editing way.
>>
>> So for example, if I were to draw a button as an OMRect, when the user clicks on it, I don't want them to select the OMRect - I want the layer to notice that it's been clicked on, and fire off some handling method.
>>
>> Ideally I would also like clicks that are *not* on an element in my layer to fall through, but as my layer can be switched on and off that isn't a great concern.
>>
>> It dawns on me that it might be a better idea to do something with the OverlayMapPanel rather than implementing this as a proper layer, would you agree?  In the mean time I will look at InteractionLayer and see if I understand more after reading the comments there.
>>
>> Thanks,
>>
>> Ian
>>
>> --
>> Ian Renton
>> UX / Software Engineer
>> ATLAS ELEKTRONIK UK
>> Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
>> Tel: +44 (0) 1305 212341
>> -----Original Message-----
>> From: Don Dietrick [mailto:dfdietrick_at_gmail.com]
>> Sent: 17 May 2012 22:39
>> To: Renton Ian
>> Cc: openmap-users_at_bbn.com
>> Subject: Re: [OpenMap Users] Implementing a Layer that Hijacks Mouse
>> Clicks
>>
>> Hi Ian,
>>
>> There's a better way to do what you want to do, but I'm not sure what you want to do.  Do you want to do anything in particular with the mouse events, or how to interact with OMGraphics on your layer?  You get a lot of help doing this if your overlay layer extends OMGraphicHandlerLayer.  If you are extending OMGraphicHandlerLayer and want events to fall through to other layers, set the consumeEvents flag to false on your layer.
>>
>> If you want to interact with the OMGraphics on your layer, I suggest taking a look at the code for the com.bbn.openmap.layer.learn.InteractionLayer.  There are comments in the code explaining all the different aspects of receiving and managing MouseEvents with the current MapMouseModes.
>>
>> If you want to do something else, or have question about that layer or your layer, let me know.  If you have more specifics that'll help, too.
>>
>> Cheers,
>>
>> Don
>>
>>
>> On Thu, May 17, 2012 at 5:29 AM, Renton Ian <ian.renton_at_uk.atlas-elektronik.com> wrote:
>>> Hi,
>>>
>>> I am attempting to create an OpenMap layer that handles mouse events internally.
>>>
>>> OpenMap's Layer.addMouseListener() method prevents me from attaching my own mouse listener as it rejects any listener that isn't part of javax.swing.  The Javadoc helpfully points out that this is to stop classes stealing the mouse events and thus not letting them fall through to the map.
>>>
>>> However, that's exactly what I want to do.  My "overlay"-type layer gets switched on and off, but when it's on, it sits on top and steals mouse clicks to handle them itself rather than passing them through to the layers below.
>>>
>>> Can I only do this by overriding OpenMap's Layer class to remove the check, or is there a better way to do what I'm trying to do?
>>>
>>> Thanks,
>>>
>>> Ian
>>>
>>> --
>>> Ian Renton
>>> UX / Software Engineer
>>> ATLAS ELEKTRONIK UK
>>> Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
>>> Tel: +44 (0) 1305 212341
>>> The information contained within this e-mail and any files attached to this e-mail are private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure.
>>>
>>> If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system.
>>>
>>> Atlas Elektronik UK Limited Registered Office Meadows Road, Queensway
>>> Meadows, Newport, South Wales NP19 4SS, UK.  Company No. 05582639
>>>
>>> --
>>> [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"]
>>
>> The information contained within this e-mail and any files attached to this e-mail are private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure.
>>
>> If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system.
>>
>> Atlas Elektronik UK Limited Registered Office Meadows Road, Queensway
>> Meadows, Newport, South Wales NP19 4SS, UK.  Company No. 05582639
>>
>> --
>> [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"]
>
> The information contained within this e-mail and any files attached to this e-mail are private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure.
>
> If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system.
>
> Atlas Elektronik UK Limited Registered Office Meadows Road, Queensway Meadows, Newport, South Wales NP19 4SS, UK.  Company No. 05582639
>
> --
> [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"]

--
[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 May 21 2012 - 10:22:14 EDT

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