|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
getItemsForMapMenu() not working with multiple layers.Please hear me out, I've read the other posts on this subject, but they don't seem to be addressing the same exact problem.
I have two layers that extend OMGraphicHandlerLayer (let's call them layer Alpha and layer Beta). In both of these layers I have overridden the getItemsForMapMenu() method and return a List of JMenuItem objects from each. The problem is, when I right click on a spot on the map the popup menu that is displayed only contains the menu items for one of the layers (Alpha), not both. If I remove the Alpha layer from the map, the menu items for Beta are displayed in the popup menu. NOTE: This is not a problem with the mouse events being consumed by the Alpha layer. I have put debug (System.out calls) in the getItemsForMapMenu method in the Beta layer, and when I right click on the map I see a menu with the menu items from the Alpha layer, but the System.out calls are getting written out from the Beta layer. So, how do I make my right click menu contain the menu items from all of my layers (in this case, Alpha and Beta)? Thanks in advance... -Kennedy |
|
|
Re: getItemsForMapMenu() not working with multiple layers.Hi Kennedy,
The StandardMapMouseInterpreter is limiting you, the object assigned to the OMGraphicHandlerLayer to manage MouseEvents. It creates a new JPopupMenu for the layer in response to a right click, and there's probably something in awt that is getting confused with multiple JPopupMenus being created. To get what you want, I think the MapMouseSupport and StandardMapMouseInterpreter need to be modified so that the MapMouseSupport makes the call for the JPopupMenu, based on the items that the StandardMapMouseInterpreters return. What might work well would be to add a variable slot in the MapMouseEvent object to contain a list of Components for the menu. If the MouseMode detects that list is not null after it has been passed to the layers, it would display a popup. So MapMouseSupport, MapMouseEvent and StandardMapMouseInterpreter would need to be modified, and that would be it. If you want to take a shot at these updates, that would be great. Otherwise, I'll add them to my todo list. - Don On Apr 29, 2008, at 9:32 AM, Davidian wrote: > > Please hear me out, I've read the other posts on this subject, but > they don't > seem to be addressing the same exact problem. > > I have two layers that extend OMGraphicHandlerLayer (let's call them > layer > Alpha and layer Beta). In both of these layers I have overridden the > getItemsForMapMenu() method and return a List of JMenuItem objects > from > each. > > The problem is, when I right click on a spot on the map the popup > menu that > is displayed only contains the menu items for one of the layers > (Alpha), not > both. If I remove the Alpha layer from the map, the menu items for > Beta are > displayed in the popup menu. > > NOTE: This is not a problem with the mouse events being consumed by > the > Alpha layer. I have put debug (System.out calls) in the > getItemsForMapMenu > method in the Beta layer, and when I right click on the map I see a > menu > with the menu items from the Alpha layer, but the System.out calls are > getting written out from the Beta layer. > > So, how do I make my right click menu contain the menu items from > all of my > layers (in this case, Alpha and Beta)? > > Thanks in advance... > > -Kennedy > -- > View this message in context: http://www.nabble.com/getItemsForMapMenu%28%29-not-working-with-multiple-layers.-tp16960449p16960449.html > Sent from the OpenMap mailing list archive at Nabble.com. > > -- > [To unsubscribe to this list send an email to "majdart@..." > with the following text in the BODY of the message "unsubscribe > openmap-users"] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Don Dietrick, dietrick@... BBN Technologies, Cambridge MA =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- [To unsubscribe to this list send an email to "majdart@..." with the following text in the BODY of the message "unsubscribe openmap-users"] |
|
|
Re: getItemsForMapMenu() not working with multiple layers.Hi Don,
I am facing almost exactly the same issue, and I don't quite understand you workaround solution. Could you elaborate? Adams On Wed, Apr 30, 2008 at 12:32 AM, Don Dietrick <dietrick@...> wrote: Hi Kennedy, |
|
|
Re: getItemsForMapMenu() not working with multiple layers.Sure - right now the mouse event flow goes from the MapBean ->
(MapMouseMode using its MapMouseModeSupport) -> (Layer using its MapMouseListener/StandardMapMouseInterpreter). The popup menu is being managed at the StandardMapMouseInterpreter level, which doesn't know anything about other layers or Interpreters. My suggestion was modifying the MapMouseModeSupport to handle the popups. Off the top of my head, there are two ways you could do this. - You could modify the MapMouseListener API and have the MapMouseListenerSupport determine when a right-mouse click occured and make calls into all the layers/interpreters to be filled. - You can modify the MapMouseModeSupport to check the MapMouseEvent for a new variable containing items returned from the layers, and if it's not null, present the popup. I was describing the second option below because it doesn't have an API change. So basically, the StandardMapMouseInterpreter already knows when to ask for menu items. If it gets anything back, it can add that list in a new method on the MapMouseEvent. When the MapMouseSupport has finished with calling the MapMouseListeners with the current MapMouseEvent (mouseReleased), it would check the list in the MapMouseEvent and present a popup if the list isn't null and empty. That might also require some calculations to figure out when the popup should be hidden (not on more mouse movements, but on another mousePressed(), maybe)? Hope this helps, Don Adams Tan wrote: > Hi Don, > > I am facing almost exactly the same issue, and I don't quite understand > you workaround solution. Could you elaborate? > > Adams > > On Wed, Apr 30, 2008 at 12:32 AM, Don Dietrick <dietrick@... > <mailto:dietrick@...>> wrote: > > Hi Kennedy, > > The StandardMapMouseInterpreter is limiting you, the object assigned > to the OMGraphicHandlerLayer to manage MouseEvents. It creates a > new JPopupMenu for the layer in response to a right click, and > there's probably something in awt that is getting confused with > multiple JPopupMenus being created. > > To get what you want, I think the MapMouseSupport and > StandardMapMouseInterpreter need to be modified so that the > MapMouseSupport makes the call for the JPopupMenu, based on the > items that the StandardMapMouseInterpreters return. > > What might work well would be to add a variable slot in the > MapMouseEvent object to contain a list of Components for the menu. > If the MouseMode detects that list is not null after it has been > passed to the layers, it would display a popup. So MapMouseSupport, > MapMouseEvent and StandardMapMouseInterpreter would need to be > modified, and that would be it. > > If you want to take a shot at these updates, that would be great. > Otherwise, I'll add them to my todo list. > > - Don > > > On Apr 29, 2008, at 9:32 AM, Davidian wrote: > > > Please hear me out, I've read the other posts on this subject, > but they don't > seem to be addressing the same exact problem. > > I have two layers that extend OMGraphicHandlerLayer (let's call > them layer > Alpha and layer Beta). In both of these layers I have > overridden the > getItemsForMapMenu() method and return a List of JMenuItem > objects from > each. > > The problem is, when I right click on a spot on the map the > popup menu that > is displayed only contains the menu items for one of the layers > (Alpha), not > both. If I remove the Alpha layer from the map, the menu items > for Beta are > displayed in the popup menu. > > NOTE: This is not a problem with the mouse events being > consumed by the > Alpha layer. I have put debug (System.out calls) in the > getItemsForMapMenu > method in the Beta layer, and when I right click on the map I > see a menu > with the menu items from the Alpha layer, but the System.out > calls are > getting written out from the Beta layer. > > So, how do I make my right click menu contain the menu items > from all of my > layers (in this case, Alpha and Beta)? > > Thanks in advance... > > -Kennedy > -- > View this message in context: > http://www.nabble.com/getItemsForMapMenu%28%29-not-working-with-multiple-layers.-tp16960449p16960449.html > Sent from the OpenMap mailing list archive at Nabble.com. > > -- > [To unsubscribe to this list send an email to "majdart@... > <mailto:majdart@...>" > with the following text in the BODY of the message "unsubscribe > openmap-users"] > > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Don Dietrick, dietrick@... <mailto:dietrick@...> > BBN Technologies, Cambridge MA > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > > > > -- > [To unsubscribe to this list send an email to "majdart@... > <mailto:majdart@...>" > with the following text in the BODY of the message "unsubscribe > openmap-users"] > > -- [To unsubscribe to this list send an email to "majdart@..." with the following text in the BODY of the message "unsubscribe openmap-users"] |
| Free embeddable forum powered by Nabble | Forum Help |