svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.fmap.control / src / main / java / org / gvsig / fmap / mapcontrol / tools / Behavior / MouseMovementBehavior.java @ 43550
History | View | Annotate | Download (3.34 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.mapcontrol.tools.Behavior; |
25 |
|
26 |
import java.awt.event.MouseEvent; |
27 |
|
28 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
29 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
30 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
31 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener; |
32 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
33 |
|
34 |
|
35 |
|
36 |
/**
|
37 |
* <p>Behavior that permits user to move and drag the mouse on the image of the associated
|
38 |
* <code>MapControl</code> instance using a {@link PointListener PointListener}.</p>
|
39 |
*
|
40 |
* @author Vicente Caballero Navarro
|
41 |
*/
|
42 |
public class MouseMovementBehavior extends Behavior { |
43 |
/**
|
44 |
* Tool listener used to work with the <code>MapControl</code> object.
|
45 |
*
|
46 |
* @see #getListener()
|
47 |
* @see #setListener(ToolListener)
|
48 |
*/
|
49 |
protected PointListener listener;
|
50 |
|
51 |
/**
|
52 |
* <p>Creates a new behavior for moving or dragging the mouse on the image of the associated <code>MapControl</code> instance.</p>
|
53 |
*
|
54 |
* @param mli listener used to permit this object to work with the associated <code>MapControl</code>
|
55 |
*/
|
56 |
public MouseMovementBehavior(PointListener mli) {
|
57 |
listener = mli; |
58 |
} |
59 |
|
60 |
/*
|
61 |
* (non-Javadoc)
|
62 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
|
63 |
*/
|
64 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
65 |
mouseMoved(e); |
66 |
} |
67 |
|
68 |
/*
|
69 |
* (non-Javadoc)
|
70 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
|
71 |
*/
|
72 |
@Override
|
73 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
74 |
PointEvent event = new PointEvent(e.getPoint(), e, this.getMapControl()); |
75 |
listener.point(event); |
76 |
} |
77 |
|
78 |
/**
|
79 |
* <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
|
80 |
*
|
81 |
* @param listener a <code>PointListener</code> object for this behavior
|
82 |
*/
|
83 |
public void setListener(ToolListener listener) { |
84 |
this.listener = (PointListener) listener;
|
85 |
} |
86 |
|
87 |
/*
|
88 |
* (non-Javadoc)
|
89 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
|
90 |
*/
|
91 |
public ToolListener getListener() {
|
92 |
return listener;
|
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(org.gvsig.fmap.mapcontrol.MapControlDrawer)
|
98 |
*/
|
99 |
public void paintComponent(MapControlDrawer mapControlDrawer) { |
100 |
} |
101 |
} |