svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontrol / src / org / gvsig / fmap / mapcontrol / tools / Behavior / Behavior.java @ 23645
History | View | Annotate | Download (5.29 KB)
1 | 21203 | vcaballero | /*
|
---|---|---|---|
2 | * Created on 28-oct-2004
|
||
3 | */
|
||
4 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | *
|
||
6 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
21 | *
|
||
22 | * For more information, contact:
|
||
23 | *
|
||
24 | * Generalitat Valenciana
|
||
25 | * Conselleria d'Infraestructures i Transport
|
||
26 | * Av. Blasco Ib??ez, 50
|
||
27 | * 46010 VALENCIA
|
||
28 | * SPAIN
|
||
29 | *
|
||
30 | * +34 963862235
|
||
31 | * gvsig@gva.es
|
||
32 | * www.gvsig.gva.es
|
||
33 | *
|
||
34 | * or
|
||
35 | *
|
||
36 | * IVER T.I. S.A
|
||
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | *
|
||
41 | * +34 963163400
|
||
42 | * dac@iver.es
|
||
43 | */
|
||
44 | 21711 | vcaballero | package org.gvsig.fmap.mapcontrol.tools.Behavior; |
45 | 21203 | vcaballero | |
46 | import java.awt.Cursor; |
||
47 | import java.awt.Graphics; |
||
48 | 23645 | vcaballero | import java.awt.Image; |
49 | 21203 | vcaballero | import java.awt.event.MouseEvent; |
50 | import java.awt.event.MouseWheelEvent; |
||
51 | import java.awt.image.BufferedImage; |
||
52 | |||
53 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
54 | import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
||
55 | import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
||
56 | |||
57 | |||
58 | |||
59 | /**
|
||
60 | * <p>When user is working with a tool on a {@link MapControl MapControl} instance, <code>Behavior</code> defines
|
||
61 | * the basic ways of interacting: selecting a point, a circle, a rectangle, or ...</p>
|
||
62 | *
|
||
63 | * <p>All events generated will be <code>MouseEvent</code>, and will depend on the nature of the
|
||
64 | * <i>behavior</i>, like the kind of tool for applying the changes.</p>
|
||
65 | 23645 | vcaballero | *
|
66 | 21203 | vcaballero | * <p><code>Behavior</code> defines the common and basic functionality for all kinds of interacting ways
|
67 | * with the <code>MapControl</code> object.</p>
|
||
68 | *
|
||
69 | * @see IBehavior
|
||
70 | *
|
||
71 | * @author Luis W. Sevilla
|
||
72 | */
|
||
73 | public abstract class Behavior implements IBehavior { |
||
74 | /**
|
||
75 | * Reference to the <code>MapControl</code> object that uses.
|
||
76 | 23645 | vcaballero | *
|
77 | 21203 | vcaballero | * @see #getMapControl()
|
78 | * @see #setMapControl(MapControl)
|
||
79 | */
|
||
80 | private MapControl mapControl;
|
||
81 | |||
82 | 23645 | vcaballero | /*
|
83 | 21203 | vcaballero | * (non-Javadoc)
|
84 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getListener()
|
||
85 | */
|
||
86 | public abstract ToolListener getListener(); |
||
87 | |||
88 | /*
|
||
89 | * <p>Draws as much of the associated <code>MapControl</code> image as is currently available. The image
|
||
90 | * is drawn with its top-left corner at (0, 0) in this graphics context's coordinate space. Transparent
|
||
91 | * pixels in the image do not affect whatever pixels are already there.</p>
|
||
92 | 23645 | vcaballero | *
|
93 | 21203 | vcaballero | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#paintComponent(java.awt.Graphics)
|
94 | */
|
||
95 | public void paintComponent(Graphics g) { |
||
96 | BufferedImage img = getMapControl().getImage();
|
||
97 | |||
98 | if (img != null) { |
||
99 | g.drawImage(img, 0, 0, null); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | /* (non-Javadoc)
|
||
104 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#setMapControl(com.iver.cit.gvsig.fmap.MapControl)
|
||
105 | */
|
||
106 | public void setMapControl(MapControl mc) { |
||
107 | mapControl = mc; |
||
108 | } |
||
109 | |||
110 | /* (non-Javadoc)
|
||
111 | 23645 | vcaballero | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getImageCursor()
|
112 | 21203 | vcaballero | */
|
113 | 23645 | vcaballero | public Image getImageCursor(){ |
114 | return getListener().getImageCursor();
|
||
115 | 21203 | vcaballero | } |
116 | |||
117 | /* (non-Javadoc)
|
||
118 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getMapControl()
|
||
119 | */
|
||
120 | public MapControl getMapControl() {
|
||
121 | return mapControl;
|
||
122 | } |
||
123 | |||
124 | /* (non-Javadoc)
|
||
125 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseClicked(java.awt.event.MouseEvent)
|
||
126 | */
|
||
127 | public void mouseClicked(MouseEvent e) throws BehaviorException { |
||
128 | } |
||
129 | |||
130 | /* (non-Javadoc)
|
||
131 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseEntered(java.awt.event.MouseEvent)
|
||
132 | */
|
||
133 | public void mouseEntered(MouseEvent e) throws BehaviorException { |
||
134 | } |
||
135 | |||
136 | /* (non-Javadoc)
|
||
137 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseExited(java.awt.event.MouseEvent)
|
||
138 | */
|
||
139 | public void mouseExited(MouseEvent e) throws BehaviorException { |
||
140 | } |
||
141 | |||
142 | /* (non-Javadoc)
|
||
143 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mousePressed(java.awt.event.MouseEvent)
|
||
144 | */
|
||
145 | public void mousePressed(MouseEvent e) throws BehaviorException { |
||
146 | } |
||
147 | |||
148 | /* (non-Javadoc)
|
||
149 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseReleased(java.awt.event.MouseEvent)
|
||
150 | */
|
||
151 | public void mouseReleased(MouseEvent e) throws BehaviorException { |
||
152 | } |
||
153 | |||
154 | /* (non-Javadoc)
|
||
155 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseDragged(java.awt.event.MouseEvent)
|
||
156 | */
|
||
157 | public void mouseDragged(MouseEvent e) throws BehaviorException { |
||
158 | } |
||
159 | |||
160 | /* (non-Javadoc)
|
||
161 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseMoved(java.awt.event.MouseEvent)
|
||
162 | */
|
||
163 | public void mouseMoved(MouseEvent e) throws BehaviorException { |
||
164 | } |
||
165 | |||
166 | /* (non-Javadoc)
|
||
167 | * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseWheelMoved(java.awt.event.MouseWheelEvent)
|
||
168 | */
|
||
169 | public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException { |
||
170 | } |
||
171 | } |