root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutEvents.java @ 9811
History | View | Annotate | Download (6.85 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-jul-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.project.documents.layout; |
46 |
|
47 |
import java.awt.event.ActionEvent; |
48 |
import java.awt.event.ActionListener; |
49 |
import java.awt.event.ComponentEvent; |
50 |
import java.awt.event.ComponentListener; |
51 |
import java.awt.event.MouseEvent; |
52 |
import java.awt.event.MouseListener; |
53 |
import java.awt.event.MouseMotionListener; |
54 |
|
55 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
56 |
import com.iver.cit.gvsig.project.documents.layout.gui.FPopupMenu; |
57 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
58 |
import com.iver.utiles.exceptionHandling.ExceptionHandlingSupport; |
59 |
import com.iver.utiles.exceptionHandling.ExceptionListener; |
60 |
|
61 |
|
62 |
/**
|
63 |
* Eventos que se realizan sobre el Layout.
|
64 |
*
|
65 |
* @author Vicente Caballero Navarro
|
66 |
*/
|
67 |
public class LayoutEvents implements ActionListener, ComponentListener, |
68 |
MouseMotionListener, MouseListener{ |
69 |
private Layout layout = null; |
70 |
private ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport(); |
71 |
|
72 |
/**
|
73 |
* Crea un nuevo EventsHandler.
|
74 |
*
|
75 |
* @param l Referencia al Layout.
|
76 |
*/
|
77 |
public LayoutEvents(Layout l) {
|
78 |
layout = l; |
79 |
} |
80 |
|
81 |
/**
|
82 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
83 |
*/
|
84 |
public void componentHidden(ComponentEvent arg0) { |
85 |
} |
86 |
|
87 |
/**
|
88 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
89 |
*/
|
90 |
public void componentMoved(ComponentEvent arg0) { |
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
95 |
*/
|
96 |
public void componentResized(ComponentEvent arg0) { |
97 |
layout.getLayoutControl().fullRect(); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
102 |
*/
|
103 |
public void componentShown(ComponentEvent arg0) { |
104 |
} |
105 |
|
106 |
/**
|
107 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
108 |
*/
|
109 |
public void actionPerformed(ActionEvent arg0) { |
110 |
layout.repaint(); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
115 |
*/
|
116 |
public void mouseDragged(MouseEvent e) { |
117 |
if (e.getButton() != MouseEvent.BUTTON3) { |
118 |
layout.getLayoutControl().setLastPoint(); |
119 |
layout.repaint(); |
120 |
} |
121 |
try {
|
122 |
layout.getLayoutControl().getCurrentLayoutTool().mouseDragged(e); |
123 |
} catch (BehaviorException t) {
|
124 |
throwException(t); |
125 |
} |
126 |
layout.getLayoutControl().setPosition(e.getPoint()); |
127 |
} |
128 |
|
129 |
/**
|
130 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
|
131 |
*/
|
132 |
public void mouseMoved(MouseEvent e) { |
133 |
try {
|
134 |
layout.getLayoutControl().getCurrentLayoutTool().mouseMoved(e); |
135 |
} catch (BehaviorException t) {
|
136 |
throwException(t); |
137 |
} |
138 |
layout.getLayoutControl().setPosition(e.getPoint()); |
139 |
layout.repaint(); |
140 |
} |
141 |
|
142 |
/**
|
143 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
144 |
*/
|
145 |
public void mouseClicked(MouseEvent e) { |
146 |
try {
|
147 |
layout.getLayoutControl().getCurrentLayoutTool().mouseClicked(e); |
148 |
} catch (BehaviorException t) {
|
149 |
throwException(t); |
150 |
} |
151 |
} |
152 |
|
153 |
/**
|
154 |
* A?ade un listener de tipo ExceptionListener.
|
155 |
*
|
156 |
* @param o ExceptionListener.
|
157 |
*/
|
158 |
public void addExceptionListener(ExceptionListener o) { |
159 |
exceptionHandlingSupport.addExceptionListener(o); |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Borra la ExceptioListener que se pasa como par?metro.
|
164 |
*
|
165 |
* @param o ExceptionListener.
|
166 |
*
|
167 |
* @return True si se borra correctamente.
|
168 |
*/
|
169 |
public boolean removeExceptionListener(ExceptionListener o) { |
170 |
return exceptionHandlingSupport.removeExceptionListener(o);
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Lanza una Excepci?n.
|
175 |
*
|
176 |
* @param t Excepci?n.
|
177 |
*/
|
178 |
protected void throwException(Throwable t) { |
179 |
exceptionHandlingSupport.throwException(t); |
180 |
} |
181 |
|
182 |
/**
|
183 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
184 |
*/
|
185 |
public void mouseEntered(MouseEvent e) { |
186 |
layout.getLayoutControl().clearMouseImage(); |
187 |
try {
|
188 |
layout.getLayoutControl().getCurrentLayoutTool().mouseEntered(e); |
189 |
} catch (BehaviorException t) {
|
190 |
throwException(t); |
191 |
} |
192 |
} |
193 |
|
194 |
/**
|
195 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
196 |
*/
|
197 |
public void mouseExited(MouseEvent e) { |
198 |
try {
|
199 |
layout.getLayoutControl().getCurrentLayoutTool().mouseExited(e); |
200 |
} catch (BehaviorException t) {
|
201 |
throwException(t); |
202 |
} |
203 |
} |
204 |
|
205 |
/**
|
206 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
207 |
*/
|
208 |
public void mousePressed(MouseEvent e) { |
209 |
if (e.getButton() == MouseEvent.BUTTON1) { |
210 |
layout.getLayoutControl().setPointAnt(); |
211 |
layout.getLayoutControl().setFirstPoint(); |
212 |
try {
|
213 |
layout.getLayoutControl().getCurrentLayoutTool().mousePressed(e); |
214 |
} catch (BehaviorException t) {
|
215 |
throwException(t); |
216 |
} |
217 |
} else
|
218 |
if (e.getButton() == MouseEvent.BUTTON3) { |
219 |
FPopupMenu popmenu = new FPopupMenu(layout);
|
220 |
layout.add(popmenu); |
221 |
popmenu.show(e.getComponent(), e.getX(), e.getY()); |
222 |
} |
223 |
} |
224 |
|
225 |
/**
|
226 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent)
|
227 |
*/
|
228 |
public void mouseReleased(MouseEvent e) { |
229 |
if (e.getButton() != MouseEvent.BUTTON3) { |
230 |
layout.getLayoutControl().setLastPoint(); |
231 |
} |
232 |
|
233 |
if (e.getButton() == MouseEvent.BUTTON1) { |
234 |
try {
|
235 |
layout.getLayoutControl().getCurrentLayoutTool().mouseReleased(e); |
236 |
} catch (BehaviorException t) {
|
237 |
throwException(t); |
238 |
} |
239 |
layout.getLayoutControl().setCancelDrawing(false);
|
240 |
} else if (e.getButton() == MouseEvent.BUTTON3) { |
241 |
} |
242 |
|
243 |
|
244 |
} |
245 |
} |