svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / LayoutEvents.java @ 772
History | View | Annotate | Download (7.15 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.app.project.documents.layout; |
23 |
|
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
import java.awt.event.ComponentEvent; |
27 |
import java.awt.event.ComponentListener; |
28 |
import java.awt.event.MouseEvent; |
29 |
import java.awt.event.MouseListener; |
30 |
import java.awt.event.MouseMotionListener; |
31 |
|
32 |
import org.gvsig.app.project.documents.layout.gui.FPopupMenu; |
33 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
35 |
import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport; |
36 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
37 |
|
38 |
/**
|
39 |
* Eventos que se realizan sobre el Layout.
|
40 |
*
|
41 |
* @author Vicente Caballero Navarro
|
42 |
*/
|
43 |
public class LayoutEvents implements ActionListener, ComponentListener, |
44 |
MouseMotionListener, MouseListener { |
45 |
|
46 |
private LayoutPanel layout = null; |
47 |
private ExceptionHandlingSupport exceptionHandlingSupport =
|
48 |
new ExceptionHandlingSupport();
|
49 |
|
50 |
/**
|
51 |
* Crea un nuevo EventsHandler.
|
52 |
*
|
53 |
* @param l
|
54 |
* Referencia al Layout.
|
55 |
*/
|
56 |
public LayoutEvents(LayoutPanel l) {
|
57 |
layout = l; |
58 |
} |
59 |
|
60 |
/**
|
61 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
62 |
*/
|
63 |
public void componentHidden(ComponentEvent arg0) { |
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
68 |
*/
|
69 |
public void componentMoved(ComponentEvent arg0) { |
70 |
} |
71 |
|
72 |
/**
|
73 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
74 |
*/
|
75 |
public void componentResized(ComponentEvent arg0) { |
76 |
// layout.getLayoutControl().fullRect();
|
77 |
layout.getLayoutControl().refresh(); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
82 |
*/
|
83 |
public void componentShown(ComponentEvent arg0) { |
84 |
} |
85 |
|
86 |
/**
|
87 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
88 |
*/
|
89 |
public void actionPerformed(ActionEvent arg0) { |
90 |
layout.repaint(); |
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
95 |
*/
|
96 |
public void mouseDragged(MouseEvent e) { |
97 |
if (e.getButton() != MouseEvent.BUTTON3) { |
98 |
layout.getLayoutControl().setLastPoint(); |
99 |
layout.repaint(); |
100 |
} |
101 |
try {
|
102 |
layout.getLayoutControl().getCurrentLayoutTool().mouseDragged(e); |
103 |
} catch (BehaviorException t) {
|
104 |
throwException(t); |
105 |
} |
106 |
layout.getLayoutControl().setPosition(e.getPoint()); |
107 |
} |
108 |
|
109 |
/**
|
110 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
|
111 |
*/
|
112 |
public void mouseMoved(MouseEvent e) { |
113 |
layout.getLayoutControl().setPosition(e.getPoint()); |
114 |
try {
|
115 |
layout.getLayoutControl().getCurrentLayoutTool().mouseMoved(e); |
116 |
} catch (BehaviorException t) {
|
117 |
throwException(t); |
118 |
} |
119 |
layout.repaint(); |
120 |
} |
121 |
|
122 |
/**
|
123 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
124 |
*/
|
125 |
public void mouseClicked(MouseEvent e) { |
126 |
try {
|
127 |
layout.getLayoutControl().getComponent().requestFocusInWindow(); |
128 |
layout.getLayoutControl().getCurrentLayoutTool().mouseClicked(e); |
129 |
} catch (BehaviorException t) {
|
130 |
throwException(t); |
131 |
} |
132 |
} |
133 |
|
134 |
/**
|
135 |
* A?ade un listener de tipo ExceptionListener.
|
136 |
*
|
137 |
* @param o
|
138 |
* ExceptionListener.
|
139 |
*/
|
140 |
public void addExceptionListener(ExceptionListener o) { |
141 |
exceptionHandlingSupport.addExceptionListener(o); |
142 |
} |
143 |
|
144 |
/**
|
145 |
* Borra la ExceptioListener que se pasa como par?metro.
|
146 |
*
|
147 |
* @param o
|
148 |
* ExceptionListener.
|
149 |
*
|
150 |
* @return True si se borra correctamente.
|
151 |
*/
|
152 |
public boolean removeExceptionListener(ExceptionListener o) { |
153 |
return exceptionHandlingSupport.removeExceptionListener(o);
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* Lanza una Excepci?n.
|
158 |
*
|
159 |
* @param t
|
160 |
* Excepci?n.
|
161 |
*/
|
162 |
protected void throwException(Throwable t) { |
163 |
exceptionHandlingSupport.throwException(t); |
164 |
} |
165 |
|
166 |
/**
|
167 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
168 |
*/
|
169 |
public void mouseEntered(MouseEvent e) { |
170 |
layout.getLayoutControl().clearMouseImage(); |
171 |
try {
|
172 |
layout.getLayoutControl().getCurrentLayoutTool().mouseEntered(e); |
173 |
} catch (BehaviorException t) {
|
174 |
throwException(t); |
175 |
} |
176 |
} |
177 |
|
178 |
/**
|
179 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
180 |
*/
|
181 |
public void mouseExited(MouseEvent e) { |
182 |
try {
|
183 |
layout.getLayoutControl().getCurrentLayoutTool().mouseExited(e); |
184 |
} catch (BehaviorException t) {
|
185 |
throwException(t); |
186 |
} |
187 |
} |
188 |
|
189 |
/**
|
190 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
191 |
*/
|
192 |
public void mousePressed(MouseEvent e) { |
193 |
if (e.getButton() == MouseEvent.BUTTON1) { |
194 |
layout.getLayoutControl().setPointAnt(); |
195 |
layout.getLayoutControl().setFirstPoint(); |
196 |
try {
|
197 |
layout.getLayoutControl().getCurrentLayoutTool() |
198 |
.mousePressed(e); |
199 |
} catch (BehaviorException t) {
|
200 |
throwException(t); |
201 |
} |
202 |
} else
|
203 |
if (e.getButton() == MouseEvent.BUTTON3) { |
204 |
FPopupMenu popmenu = new FPopupMenu(layout);
|
205 |
layout.add(popmenu); |
206 |
popmenu.show(e.getComponent(), e.getX(), e.getY()); |
207 |
} |
208 |
} |
209 |
|
210 |
/**
|
211 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent)
|
212 |
*/
|
213 |
public void mouseReleased(MouseEvent e) { |
214 |
if (e.getButton() != MouseEvent.BUTTON3) { |
215 |
layout.getLayoutControl().setLastPoint(); |
216 |
} |
217 |
|
218 |
if (e.getButton() == MouseEvent.BUTTON1) { |
219 |
try {
|
220 |
layout.getLayoutControl().getCurrentLayoutTool() |
221 |
.mouseReleased(e); |
222 |
} catch (BehaviorException t) {
|
223 |
throwException(t); |
224 |
} |
225 |
layout.getLayoutControl().setCancelDrawing(false);
|
226 |
} else
|
227 |
if (e.getButton() == MouseEvent.BUTTON3) { |
228 |
} |
229 |
|
230 |
} |
231 |
} |