Re: [OpenMap Users] mouse events

From: Cary O'Brien <cobrien_at_cornet.com>
Date: Fri, 03 Dec 2004 08:56:42 -0500

SteveC wrote:

>Hi,
>
>I have an applet using a BufferedMapBean only. It works fine but I'm not
>getting mouse events. It basically follows the SimpleMap.java example
>with my own Layer subclass being used. I've written a MapMouseListener
>and the get method etc etc etc in. I know I have to use a
>SimpleMapHandler or similar to actually get events. But I don't know
>how.
>
>There is a SimpleMap2 example here:
>
>http://openmap.bbn.com/src/openmap/com/bbn/openmap/examples/simple/SimpleMap2.java
>
>but I can't get it to work without having to use an OpenMapFrame, which
>I don't want.
>
>Is there an example using just the bean (not the toolbar, menu, etc)
>somewhere or could someone give me a quick snippet of code that should
>work?
>
>
DISCLAMER: I'm just getting started with OpenMap, so any and all of this
may be
completly wrong!

I'm working on REALLY understanding how mouse events work in openmap,
but I'm not there
yet. That being said, I have gotten a few custom mouse behaviors to
work, so I have some idea
of how it is all put together.

There seem to be a bunch of different ways to get mouse events, at
different levels in the system.

The easy way:

The ShapeLayer subclassesOMGraphicHandlerLayer, which has extensive
support for pre-defined
mouse events. This means if you want to know when a specific OMGraphic
is selected or provide
a pop-up menu for the item, you can do this by subclassing ShapeLayer,
and overriding any methods
in GestureResponsePolicy you want to handle , like select() or
getToolTipText().

You also need to set the mouse mode, and if you want to switch between
navigate mouse mode
(drag out a square and go there) and Gesture mouse mode (select an
OMGraphic) you need a
MouseDelegator (??) and MouseModePanel.

Well, perhaps this is not that easy.

The fancy way:

You'd have to set up your own response policy. I really don't
understand how to do this yet.

A low-level way:

Another way, I guess, would be to subclass the layer and have it return
its own MapMouseListener when getMapMouseListener() is called. I
haven't tried
this, so I'm not sure what is necessary to get this to work.
Implementing a MapMouseListener
gets you lower level mouse movements such as mousePressed(),
mouseReleased(), mouseDragged().
The methods are passed only the java.awt.event.MouseEvent, so you don't
get any map
related events.

Another simple way:

At a lower level, If you want to just get the very low-level swing
events, you can just
do mapBean.addMouseListener(), addMouseMotionListener() and get that
information,
but all you'll get is x-y, you'd have to convert to lat-long with the
projection of the bean.

The point?

I guess how to get the mouse modes depends on what sort of information
you want. If you want to manipulate a graphic on the map, the first way
is the best. If you
just want to get xy clicks, then one of the last two would be better.

If you provide more information on what you are trying to do, I may be
able to put together
an example, either of the OMGraphic-centered events, or xy based mouse
events.

-- cary

>TIA!
>
>have fun,
>
>SteveC steve_at_fractalus.com http://www.fractalus.com/steve/
>--
>[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 Fri Dec 03 2004 - 09:13:28 EST

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