RE: [OpenMap Users] MouseMode Support for cursorID Property

From: Renton Ian <ian.renton_at_uk.atlas-elektronik.com>
Date: Mon, 28 May 2012 08:46:46 +0100

Don,

At the moment I can use any MouseMode with OverlayMapPanel, and I can set a cursor for each MouseMode, but when using OverlayMapPanel the cursor requests are not respected. (When using BasicMapPanel instead, the cursor requests *are* respected.)

I am assuming that this is because, when using OverlayMapPanel, the MapBean is no longer the topmost panel. The OverlayMapPanel sticks centerContainer over the top. setCursor() is being called on the MapBean when the MouseMode changes, but on my machine at least, the cursor does not change unless you call setCursor() on centerContainer instead/as well.

My patch therefore listens for cursor changes on the MapBean and replicates that change on the OverlayMapPanel's centerContainer as well.

Ian


--
Ian Renton
UX / Software Engineer
ATLAS ELEKTRONIK UK
Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
Tel: +44 (0) 1305 212341
________________________________
From: Don Dietrick [mailto:dfdietrick_at_gmail.com]
Sent: 25 May 2012 16:11
To: Renton Ian
Cc: openmap-users_at_bbn.com
Subject: Re: [OpenMap Users] MouseMode Support for cursorID Property
I'm pretty sure you can use any mouse mode with OverlayMapPanel.  I don't recall putting any restrictions in it.  You should be able to change the cursor on any mouse mode, too.
I don't quite understand the intent of the patch.  Are you changing mouse modes and want the MapBean to control which cursor they use?  Do you have one mouse mode and you just want to set the cursor?
- Don
- Don
=-=-=-=-=-=-=-=-=
Don Dietrick
_at_dfdietrick
=-=-=-=-=-=-=-=-=
On Friday, May 25, 2012 at 10:57 AM, Renton Ian wrote:
Thanks, it might be handy for us to have a single MouseMode with multiple functions.
Would it still be worth allowing OverlayMapPanel to use the MapBean's desired cursor, though? In the past few minutes I think I have come up with a reasonable way to do this. The diff is included below, though it might get mangled by our mail clients. If you think it's worth implementing, I'll post it on Bugzilla.
Diff follows:
--- C:/Documents and Settings/irenton/Desktop/OverlayMapPanel.java Fri May 25 15:54:14 2012
+++ C:/Documents and Settings/irenton/Desktop/OverlayMapPanel-new.java Fri May 25 15:54:37 2012
_at__at_ -36,6 +36,9 @@
import com.bbn.openmap.omGraphics.OMGraphicConstants;
import com.bbn.openmap.proj.ProjectionStack;
import com.bbn.openmap.util.PropUtils;
+import java.awt.Cursor;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
/**
* An extension of the BasicMapPanel that uses an OverlayLayout on the panel in
_at__at_ -50,7 +53,7 @@
* whatever property prefix is given to the panel.
*/
public class OverlayMapPanel
- extends BasicMapPanel {
+ extends BasicMapPanel implements PropertyChangeListener {
private static final long serialVersionUID = 1L;
_at__at_ -78,6 +81,8 @@
*/
protected JPanel widgets;
+ private JPanel centerContainer = new JPanel();
+
/**
* Creates an empty OverlayMapPanel that creates its own empty
* PropertyHandler. The MapPanel will contain a MapBean, a MapHandler,
_at__at_ -125,6 +130,7 @@
*/
protected void addMapBeanToPanel(MapBean map) {
layoutPanel(map);
+ map.addPropertyChangeListener(this);
}
public DrawingAttributes getActiveWidgetColors() {
_at__at_ -159,8 +165,6 @@
protected void layoutPanel(MapBean map) {
Dimension minimumSize = new Dimension(MapBean.DEFAULT_WIDTH, MapBean.DEFAULT_HEIGHT);
- JPanel centerContainer = new JPanel();
-
JPanel hackPanel = new JPanel();
hackPanel.setLayout(new BorderLayout());
hackPanel.setOpaque(false);
_at__at_ -302,6 +306,14 @@
}
});
+ }
+ _at_Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if (evt.getPropertyName().equals(MapBean.CursorProperty))
+ {
+ centerContainer.setCursor(((Cursor) evt.getNewValue()));
+ }
}
}
--
Ian Renton
UX / Software Engineer
ATLAS ELEKTRONIK UK
Atlas House, Dorset Green Tech. Park, DT2 8ZB, U.K.
Tel: +44 (0) 1305 212341
________________________________
From: Don Dietrick [mailto:dfdietrick_at_gmail.com]
Sent: 25 May 2012 15:43
To: Renton Ian
Cc: openmap-users_at_bbn.com<mailto:openmap-users_at_bbn.com>
Subject: Re: [OpenMap Users] MouseMode Support for cursorID Property
The OverlayMapPanel uses a different MouseMode that has a "Gestures" id - it's called the OMMouseMode, and is specified in the properties. You should be able to change the cursor for it.
OMMouseMode is a combination of NavMouseMode, SelectMouseMode and PanMouseMode.
- Don
=-=-=-=-=-=-=-=-=
Don Dietrick
_at_dfdietrick
=-=-=-=-=-=-=-=-=
On Friday, May 25, 2012 at 10:16 AM, Renton Ian wrote:
Daniel,
Thanks for mentioning BasicMapPanel - I think I've figured out where the issue must be!
The default build of OpenMap 5.0 uses OverlayMapPanel instead of BasicMapPanel so that it can draw the embedded nav & scale panels over the map. My software uses that too, and the MouseMode cursorIDs do not work with this MapPanel.
If I switch my application to using BasicMapPanel, the cursors work perfectly. (But of course, I lose the overlays.)
I can't see anything obvious in OverlayMapPanel that breaks it, so presumably it's just that the topmost element on the map area is the hackPanel and not a Layer. No obvious way to fix this bug springs to mind, but I will keep poking around the source.
If you're wondering where the other MouseModes are in the default build, the properties file has them in the "openmap.components" property, but not in the "main.components". If you add "selectMouseMode navMouseMode distanceMouseMode panMouseMode" (and maybe also "mouseModePanel" if you want it) to main.components, they will be available.
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: Straub, Daniel [mailto:Daniel.Straub_at_cassidian.com]
Sent: 25 May 2012 14:41
To: openmap-users_at_bbn.com<mailto:openmap-users_at_bbn.com>
Subject: RE: [OpenMap Users] MouseMode Support for cursorID Property
Yes, i am using openmap 5.0, too.
On my system (Win XP 32-bit with SP3) runs [Java(TM) SE Runtime Environment (build 1.6.0_20-b02)].
I don't think the difference in the java-version is the problem. First thing i would think of is: Do you overwrite the cursor somewhere else?
I only set up a BasicMapPanel by
mapPanel = new BasicMapPanel(new
PropertyHandler(propertiesPath));
and it works...
I tried to set the cursor in the default build but this doesn't work for me, too. I'm also wondering where all the MouseModes are, which are defined in the properties (selectMouseMode navMouseMode distanceMouseMode panMouseMode). If i go to the menu, only the gestures-MouseMode is visible which should be the selectMouseMode.
Perhaps there is something else in the properties file, preventing the set cursor to get active? Did you try to set up a new properties-file only containing the settings you need?
Hope someone else knows more about that.
Daniel Straub
-----Original Message-----
From: Renton Ian [mailto:ian.renton_at_uk.atlas-elektronik.com]
Sent: Friday, May 25, 2012 2:07 PM
To: openmap-users_at_bbn.com<mailto:openmap-users_at_bbn.com>
Subject: RE: [OpenMap Users] MouseMode Support for cursorID Property
Thanks Daniel.
I did add the mousemode to my components list.
I've also attempted to set cursorIDs in the properties file of the default build of OpenMap 5.0, just to rule out anything weird I've done in my software, and it doesn't work there either. Are you using 5.0, or an earlier/later one?
For the record I'm also on Sun JRE 6 r23, Win XP 32-bit SP3.
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: Straub, Daniel [mailto:Daniel.Straub_at_cassidian.com]
Sent: 25 May 2012 12:41
To: openmap-users_at_bbn.com<mailto:openmap-users_at_bbn.com>
Subject: RE: [OpenMap Users] MouseMode Support for cursorID Property
Hi,
Using the following lines in the properties-file worked for me:
openmap.components=DistanceMouseMode
DistanceMouseMode.class=com.bbn.openmap.event.DistanceMouseMode
DistanceMouseMode.cursorID=CROSSHAIR_CURSOR
Did you add the mousemode to the components?
In the DistanceMouseMode.java-file i see the following:
// if you really want to change the cursor shape // setModeCursor(cursor.getPredefinedCursor(cursor.CROSSHAIR_CURSOR));
But that should be the same as you did. Perhaps someone else knows what's going wrong here...
Hope I could help.
Daniel Straub
-----Original Message-----
From: Renton Ian [mailto:ian.renton_at_uk.atlas-elektronik.com]
Sent: Friday, May 25, 2012 1:16 PM
To: openmap-users_at_bbn.com<mailto:openmap-users_at_bbn.com>
Subject: [OpenMap Users] MouseMode Support for cursorID Property
Hi,
It looks from the source of AbstractMouseMode that MouseModes support a cursorID property that sets the cursor to use when that MouseMode is active. It looks for one of the static defined cursors in java.awt.Cursor, e.g. CROSSHAIR_CURSOR.
However, I can't get it to work in any MouseMode. I've tried loading it as a property, e.g.
distanceMouseMode.cursorID=HAND_CURSOR
...and I've tried extending the class and setting the cursor programatically, e.g.
public class DistanceMouseMode2 extends DistanceMouseMode
{
public DistanceMouseMode2()
{
super();
setModeCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
}
}
...but the cursor remains the normal pointer.
Can anyone tell me what I'm doing wrong?
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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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"]
Received on Mon May 28 2012 - 03:49:16 EDT

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