I have the following mouseDragged method in my PositionMouseMode (similar
to the normal NavMouseMode).
The map drag performance is quite reasonable even though I don't have a
particularly fast machine by today's standards.
public void mouseDragged(MouseEvent e) {
///////////////////////////////////// mouseDragged event
//
if (Context.debugging("MouseModeMouseEvents")) debugMouseEvent(e);
//
//
if ((e.getSource() instanceof MapBean) == false) // If not
from MapBean
return; // Then return
//
MapFrame mapFrame = niApp.getMapFrame(); // Get the map
frame
MapBean map = (MapBean)e.getSource(); // Get the map bean
dragPoint = e.getPoint(); // Get mouse position
dragPoint.x = Math.max(dragPoint.x, 0); // Don't allow -ve
dragPoint.y = Math.max(dragPoint.y, 0); // Don't allow -ve
dragPoint.x = Math.min(dragPoint.x, (map.getWidth() - 1)); //
Keep on the map
dragPoint.y = Math.min(dragPoint.y, (map.getHeight() - 1)); //
Keep on the map
mouseDragging = true; // Flag it is being dragged
//
// Now drag the map. //
int xCentre = map.getWidth() / 2; // X middle
int yCentre = map.getHeight() / 2; // Y middle
int newX = xCentre + (mouseDownPoint.x - e.getX()); // Get new
X centre
int newY = yCentre + (mouseDownPoint.y - e.getY()); // Get new
Y centre
LatLonPoint newCentre = map.getProjection().inverse(newX, newY);
// Get as latlon
map.setCenter(newCentre); // Shift the world
mouseDownPoint.x = e.getX(); // Remember where it
mouseDownPoint.y = e.getY(); // Came from
//
mapFrame.reportLocation(e); // Report position & scale
//
}
////////////////////////////////////////////////////////////////////////
End of mouseDragged()
regards,
Adrian
_____________________________________________
Dr. Adrian Lumsden
Product Specialist
Scientific Software and Systems Limited
Tel: +64 4 917-6680 (direct)
+64 4 917-6670 (reception)
Fax: +64 4 917-6671
E-mail: Adrian.Lumsden@sss.co.nz
Visit us on the Web at: http://www.sss.co.nz
_____________________________________________
This e-mail passed SSS's content security scan.
It is covered by the confidentiality clauses at
http://www.sss.co.nz/content_and_confidentiality
Don Dietrick <dietrick@bbn.com>
Sent by: owner-openmap-users@bbn.com
26/02/04 02:54
To: Lior Graf <liorg@mercury.co.il>
cc: "'openmap-users@bbn.com'" <openmap-users@bbn.com>
Subject: Re: [OpenMap Users] navigating the map using the mouse
Hi Lior,
I think I would modify the NavMouseMode to interpret the mouse events
as you like.
Getting the map to drag 'live' would be a little harder, you might have
to get involved with the BufferedMapBean/BufferedLayerMapBean image
buffer and translate it based on the mouse drag events. You would have
a handle to the MapBean as the source of the MouseEvent, so you don't
have to configure your mouse mode to look for it.
- Don
On Feb 25, 2004, at 5:12 AM, Lior Graf wrote:
> Hi,
>
>
>
> I'd like to know whether it is possible to navigate the map using the
> mouse (clicking a point and then dragging the mouse to a certain
> direction, will cause the map to move to that direction).
>
>
>
> Where do I start implementing that?
>
>
>
> Regards,
>
>
>
> Lior Graf
>
> Software Developer
>
> Mercury Interactive
>
>
>
> Tel: 972 3 5399925
>
> Mobile: 972 66 507302
>
> Fax: 972 3 5331617
>
> Email: liorg@mercury.co.il
>
>
>
>
> _______________________________________________________________________
> _
> This email has been scanned for all viruses.
>
> Mercury Interactive Corporation
> Optimizing Business Processes to Maximize Business Results
>
-- [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 Feb 25 14:50:38 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT