Re: OMGraphicsList.findClosest()

From: Donald Dietrick <dietrick@bbn.com>
Date: Wed Jan 16 2002 - 13:44:31 EST

There's something else you can do, too:

You can create an object that implements the MapMouseListener interface,
that knows how to interpret mouse events to define a query box. Once it
has an area defined, you can have it ask your layers for any objects in
that area. You can have your layers return a separate OMGraphicList
containing the objects, or you can provide an OMGraphicsList in the
query method for them to append the graphics to.

OK, so there are a couple of questions: how does this object receive
the MouseEvents, and how does it find the layers?

First, you make it a special MapMouseListener that gets added to the
MapHander (BeanContext) as an openmap component. The Layers get added
as well (set Layer.addToBeanContext = true), and the layers look for the
object to use as their MapMouseListener. At this time, they can also
add themselves to it as layers to be queried.
The layers will probably have to implement another interface (that you
create) that lets the layers be queried for their graphics. You might
want to check for layer visibility if you only want to get the layers
that are on the map - you might not, too, it depends on the
functionality you're looking for.

The MapMouseListener should consume the events - since all of your
layers are using it as it's MapMouseListener, only the top one needs to
funnel the event to the MML. The lower layers just never receive it.

Once this component has the graphic list, you can do with it what you
like - it can change the appearance of the graphics, whatever. You
could also make the layers smart enough to use it to render other
graphics, too, like the bounding box, etc. You might have to make the
component smart enough to realize which layer sent it events, and to let
it know when it should draw its stuff.

You can also use the BeanContext to connect the component with anything
else that needs the information about the list.

- Don

On Wednesday, January 16, 2002, at 10:52 AM, alexander sokolov wrote:

>> Now for the REALLY tricky part :) I have a Layer which is
>> basically a
>> view to a data model. On my map, I have 3 instances of this layer, all
>> looking at different types of the same data.
>>
>> Somehow, I want to compile the results from these clicks into a
>> single
>> selection dialog, which will cover hits from all three layers. At the
>> moment, I'm not sure this is even possible. I've got some workaround
>> ideas,
>> but most of them aren't reliable and the ones that are aren't good
>> interface
>> design.
>>
>> Anyone ever worked with pulling click results from multiple layers
>> into a
>> single action? Any ideas on how this might go? At the moment my best
>> option is a static list as part of the class, which gets populated as
>> the
>> event passes through each layer, until the last one actually displays
>> the
>> results. Worry with this is layer visibility - events don't get
>> passed to
>> invisible layers, correct?
>
> I don't think so, events get passed to all layers. Just be sure the
> event has not been consumed
> by previous layer
>
> public boolean mouseMoved(MouseEvent e) {
> int x = e.getX();
> int y = e.getY();
> LatLonPoint ll = projection.inverse(x, y);
> return true; // to consume the event or false otherwise
> }
>
> So, you can collect information under mouse from all layers. It works
> well.
>
> Regards
> Alexander
>
>
>
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Donald Dietrick, dietrick@bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed Jan 16 13:44:41 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:32 EDT