Yes I would agree. Just don't consume your mouse events.
Our application sounds similar to yours. We have several instances of the
same layer, each of which has multiple data handlers. Our particular
situation is that lines are drawn between points on the map, and we need to
highlight the lines (and all of the lines related to it) when moused over.
Imagine a routing problem
I overrode the findClosestLocation(MouseEvent evt) method to change the
parameter that determines the acceptable distance between the mouse pointer
and the nearest line (called "limit"). By tweaking this, you can grab
graphic objects arbitrarily close or far from the mouse pointer.
here is a snippet:
/**
* Finds the closest line to the current mouse pointer. We are interested
* in Routes and Pheromones
* @param evt the MouseEvent containing the current location
* @return a ResultLine if we can find one, or null if not
*/
protected ResultLine findClosestResultLine(MouseEvent evt) {
ResultLine closest = null;
OMGraphicList list = new OMGraphicList();
LocationHandler[] handlers = getDataHandlers();
if (handlers != null) {
for (int i=0; i<handlers.length; i++) {
OMGraphic g =
((OptimizerResultHandler)handlers[i]).findClosestResultLine(evt.getX(),
evt.getY());
if (g != null) {
list.add(g);
}
}
}
if (!list.isEmpty()) {
closest = (ResultLine)list.findClosest(evt.getX(), evt.getY(),
3f);
}
return closest;
}
At 04:52 PM 1/16/2002 +0100, 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"]
-- [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 12:56:43 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:32 EDT