Re: [OpenMap Users] How to export coord info to clipboard (UNCLASSIFIED)

From: Carsten . Madsen <com_at_navicon.dk>
Date: Mon, 25 Jun 2007 19:52:33 +0200

Hi Michael

I did a quick test and it works fine at my desk.

First I did:

|*package *dk.navicon.openmap.gui;

*import *java.awt.Toolkit;
*import *java.awt.datatransfer.Clipboard;
*import *java.awt.datatransfer.StringSelection;
*import *java.awt.datatransfer.Transferable;
*import *java.awt.event.MouseEvent;

*import *com.bbn.openmap.LatLonPoint;
*import *com.bbn.openmap.MapBean;
*import *com.bbn.openmap.event.PanMouseMode;

*public class *ClipboardMouseMode *extends *PanMouseMode {
    *public **void *mouseClicked(MouseEvent e) {
        System.out.println("ClipboardMouseMode MouseEvent e="+e);
        *super*.mouseClicked(e);
        LatLonPoint llp = *null*;
        *int *x = e.getX();
        *int *y = e.getY();
        *if *(e.getSource() *instanceof *MapBean) {
            llp = ((MapBean) e.getSource()).getProjection().inverse(x, y);
            Clipboard systemClipboard = Toolkit.getDefaultToolkit()
                    .getSystemClipboard();
            // format, UTM convert llp here
            Transferable transferableText = *new *StringSelection(llp.toString());
            systemClipboard.setContents(transferableText, *null*);
        }
    }

}|


The I patched my openmap.properties file to:

#panMouseMode.class=com.bbn.openmap.event.PanMouseMode
panMouseMode.class=dk.navicon.openmap.gui.ClipboardMouseMode

Then I launched OM. If it works you should see that the button in the
toolbar for switching to PanMouseMode has lost it's icon and just shows
the text "Pan" causing the toolbar to look weird. Now switch to Pan
mouse and you should see the print outs like this:

ClipboardMouseMode MouseEvent
e=java.awt.event.MouseEvent[MOUSE_CLICKED,(404,177),absolute(592,294),button=1,modifiers=Button1,clickCount=1]
on com.bbn.openmap.BufferedLayerMapBean_at_17a1767

BR
Carsten


Lackey, Michael B. (SED/BTI) wrote:
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> Hello Carsten,
>
> What am I doing wrong? I have a derived class ClipboardMouseMode, and is being properly instantiated/loaded by component factory. I know this because (1) I have enabled componenet factory detail debugging, and (2) because I have placed Debug.Output("ClipboardMouse Constructor") in the constructor, and see that output on the console.
>
> But, debug statements indicate no mouse events are being called, e.g., mousePressed(), mouseClicked(), and mouseDragged().
>
> Have tried:
>
> public class ClipboardMouseMode extends PanMouseMode
> and
> public class ClipboardMouseMode extends NavMouseMode
> and
> public class ClipboardMouseMode extends CoordMouseMode
>
> For each, have tried changing mouse mode using main menu item Control/MouseMode/Navigation... But this does not seem to help.
>
> I am running OpenMap executable using OpenMap.bat found in the bin directory, and with the default openmap.properties (but with my changes) found in openmap-4.6.3 folder. Should I be using a different properties file?
>
> Mike Lackey
> Brockwell Technologies, Inc.
> 256-876-0167
>
> -----Original Message-----
> From: "Carsten . Madsen" [mailto:com_at_navicon.dk]
> Sent: Thursday, June 21, 2007 4:43 PM
> To: Lackey, Michael B. (SED/BTI)
> Cc: openmap-users_at_bbn.com
> Subject: Re: [OpenMap Users] How to export coord info to clipboard (UNCLASSIFIED)
>
> Hi
>
> Install your own mouse mode via the openmap.properties file, e.g., extend the PanMouseMode and override mouseClicked to do the copy to clip board
>
> class ClipboardMouseMode extends PanMouseMode {
>
> public void mouseClicked(MouseEvent e) {
> super.mouseClicked(e);
> LatLonPoint llp = null;
> int x = e.getX();
> int y = e.getY();
> if (e.getSource() instanceof MapBean) {
> llp = ((MapBean) e.getSource()).getProjection().inverse(x, y);
> Clipboard systemClipboard = Toolkit.getDefaultToolkit()
> .getSystemClipboard();
> // format, UTM convert llp here
> Transferable transferableText = new StringSelection(llp);
> systemClipboard.setContents(transferableText, null);
> }
> }
>
> }
>
> Then add
>
> panMouseMode.class=ClipboardMouseMode
>
> to openmap.properties in your home dir and add ClipboardMouseMode to the classpath before launching OM.
>
> BR
> Carsten
>
>
> Lackey, Michael B. (SED/BTI) wrote:
>
>> Classification: UNCLASSIFIED
>> Caveats: NONE
>>
>> Hello All,
>>
>> Question for the group.
>>
>> When using OpenMap, vanilla installation, no mods, would like to
>> right-click and have the s/w place the coord info (lat/lon, or even
>> better UTM) on the clipboard. Such that it can then be copied
>> (pasted) into another app.
>>
>> Searched the arhives for "clipboard", not much luck.
>>
>> Browsing the source, I see that file CoordMouseMode.java derives from
>> AbstractMouseMode, and has access to current coord info.
>>
>> So I think it might be possible to modify the source, and override
>> AbstractMouseMode.MouseClick(). But I'm rather not modify the source,
>> if there's an alternative.
>>
>> Question: is it possible to add a layer which does noting more than
>> catch mouse events and export data to the clipboard? As outlined in
>> the FAQ? This requires registering a mouse listener with the MapBean?
>> If this info is already in the list archives, please point it out.
>>
>> I realize I'm at 30,000 ft. and asking a 3,000 ft question, but time
>> is (as always) of the essence.
>>
>>
>> Mike Lackey
>> Brockwell Technologies, Inc.
>> 256-876-0167
>>
>> Classification: UNCLASSIFIED
>> Caveats: NONE
>>
>> --
>> [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"]
>>
>>
> Classification: UNCLASSIFIED
> Caveats: NONE
>
>



--
[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 Jun 25 2007 - 13:54:03 EDT

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