Revision 1074 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/EventsHandler.java
EventsHandler.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Created on 27-jul-2004 |
3 | 3 |
* |
4 |
* To change the template for this generated file go to |
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments |
|
6 | 4 |
*/ |
7 | 5 |
package com.iver.cit.gvsig.gui.layout; |
8 | 6 |
|
7 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
|
8 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
|
9 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
|
10 |
|
|
9 | 11 |
import java.awt.Cursor; |
10 | 12 |
import java.awt.Point; |
11 | 13 |
import java.awt.event.ActionEvent; |
... | ... | |
17 | 19 |
import java.awt.event.MouseMotionListener; |
18 | 20 |
import java.awt.geom.Point2D; |
19 | 21 |
import java.awt.geom.Rectangle2D; |
22 |
|
|
20 | 23 |
import java.util.ArrayList; |
21 | 24 |
|
22 |
import com.iver.andami.PluginServices; |
|
23 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
|
24 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
|
25 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
|
26 | 25 |
|
27 |
|
|
28 | 26 |
/** |
29 | 27 |
* Eventos que se realizan sobre el Layout. |
30 | 28 |
* |
31 | 29 |
* @author Vicente Caballero Navarro |
32 | 30 |
*/ |
33 | 31 |
public class EventsHandler implements ActionListener, ComponentListener, |
34 |
MouseMotionListener, MouseListener {
|
|
35 |
private Layout layout = null;
|
|
36 |
private Point2D.Double m_pointSelected = null;
|
|
37 |
private int index = 0;
|
|
38 |
private ArrayList lastSelect = new ArrayList();
|
|
39 |
private FLayoutFunctions events = null;
|
|
40 |
private FLayoutZooms zooms = null;
|
|
32 |
MouseMotionListener, MouseListener {
|
|
33 |
private Layout layout = null;
|
|
34 |
private Point2D.Double m_pointSelected = null;
|
|
35 |
private int index = 0;
|
|
36 |
private ArrayList lastSelect = new ArrayList();
|
|
37 |
private FLayoutFunctions events = null;
|
|
38 |
private FLayoutZooms zooms = null;
|
|
41 | 39 |
|
42 |
/**
|
|
43 |
* Crea un nuevo EventsHandler.
|
|
44 |
*
|
|
45 |
* @param l DOCUMENT ME!
|
|
46 |
*/
|
|
47 |
public EventsHandler(Layout l) {
|
|
48 |
layout = l;
|
|
49 |
events = new FLayoutFunctions(layout);
|
|
50 |
zooms = new FLayoutZooms(layout);
|
|
51 |
}
|
|
40 |
/**
|
|
41 |
* Crea un nuevo EventsHandler.
|
|
42 |
*
|
|
43 |
* @param l Referencia al Layout.
|
|
44 |
*/
|
|
45 |
public EventsHandler(Layout l) {
|
|
46 |
layout = l;
|
|
47 |
events = new FLayoutFunctions(layout);
|
|
48 |
zooms = new FLayoutZooms(layout);
|
|
49 |
}
|
|
52 | 50 |
|
53 |
/**
|
|
54 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
|
55 |
*/
|
|
56 |
public void componentHidden(ComponentEvent arg0) {
|
|
57 |
}
|
|
51 |
/**
|
|
52 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
|
53 |
*/
|
|
54 |
public void componentHidden(ComponentEvent arg0) {
|
|
55 |
}
|
|
58 | 56 |
|
59 |
/**
|
|
60 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
|
61 |
*/
|
|
62 |
public void componentMoved(ComponentEvent arg0) {
|
|
63 |
}
|
|
57 |
/**
|
|
58 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
|
59 |
*/
|
|
60 |
public void componentMoved(ComponentEvent arg0) {
|
|
61 |
}
|
|
64 | 62 |
|
65 |
/**
|
|
66 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
|
67 |
*/
|
|
68 |
public void componentResized(ComponentEvent arg0) {
|
|
69 |
layout.fullRect();
|
|
70 |
}
|
|
63 |
/**
|
|
64 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
|
65 |
*/
|
|
66 |
public void componentResized(ComponentEvent arg0) {
|
|
67 |
layout.fullRect();
|
|
68 |
}
|
|
71 | 69 |
|
72 |
/**
|
|
73 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
|
74 |
*/
|
|
75 |
public void componentShown(ComponentEvent arg0) {
|
|
76 |
}
|
|
70 |
/**
|
|
71 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
|
72 |
*/
|
|
73 |
public void componentShown(ComponentEvent arg0) {
|
|
74 |
}
|
|
77 | 75 |
|
78 |
/**
|
|
79 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
|
80 |
*/
|
|
81 |
public void actionPerformed(ActionEvent arg0) {
|
|
82 |
layout.repaint();
|
|
83 |
}
|
|
76 |
/**
|
|
77 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
|
78 |
*/
|
|
79 |
public void actionPerformed(ActionEvent arg0) {
|
|
80 |
layout.repaint();
|
|
81 |
}
|
|
84 | 82 |
|
85 |
/**
|
|
86 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
|
87 |
*/
|
|
88 |
public void mouseDragged(MouseEvent e) {
|
|
89 |
if (e.getButton() != MouseEvent.BUTTON3) {
|
|
90 |
layout.setLastPoint(e.getPoint());
|
|
91 |
layout.repaint();
|
|
92 |
}
|
|
93 |
}
|
|
83 |
/**
|
|
84 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
|
|
85 |
*/
|
|
86 |
public void mouseDragged(MouseEvent e) {
|
|
87 |
if (e.getButton() != MouseEvent.BUTTON3) {
|
|
88 |
layout.setLastPoint(e.getPoint());
|
|
89 |
layout.repaint();
|
|
90 |
}
|
|
91 |
}
|
|
94 | 92 |
|
95 |
/**
|
|
96 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
|
|
97 |
*/
|
|
98 |
public void mouseMoved(MouseEvent E) {
|
|
99 |
if (layout.getTool() == Layout.SELECT) {
|
|
100 |
Cursor cursor = null;
|
|
101 |
Point2D.Double p = new Point2D.Double(E.getX(), E.getY());
|
|
93 |
/**
|
|
94 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
|
|
95 |
*/
|
|
96 |
public void mouseMoved(MouseEvent E) {
|
|
97 |
if (layout.getTool() == Layout.SELECT) {
|
|
98 |
Cursor cursor = null;
|
|
99 |
Point2D.Double p = new Point2D.Double(E.getX(), E.getY());
|
|
102 | 100 |
|
103 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
104 |
IFFrame auxfframe = (IFFrame) layout.getFFrames().get(i);
|
|
101 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
102 |
IFFrame auxfframe = (IFFrame) layout.getFFrames().get(i);
|
|
105 | 103 |
|
106 |
if ((auxfframe.getSelected() != FFrame.NOSELECT)) {
|
|
107 |
cursor = auxfframe.getMapCursor(p);
|
|
108 |
}
|
|
104 |
if ((auxfframe.getSelected() != FFrame.NOSELECT)) {
|
|
105 |
cursor = auxfframe.getMapCursor(p);
|
|
106 |
}
|
|
109 | 107 |
|
110 |
if (cursor != null) {
|
|
111 |
layout.setMapCursor(cursor);
|
|
112 |
} else {
|
|
113 |
layout.setMapCursor(Layout.icrux);
|
|
114 |
}
|
|
115 |
}
|
|
116 |
}
|
|
117 |
}
|
|
108 |
if (cursor != null) {
|
|
109 |
layout.setMapCursor(cursor);
|
|
110 |
} else {
|
|
111 |
layout.setMapCursor(Layout.icrux);
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
}
|
|
118 | 116 |
|
119 |
/**
|
|
120 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
|
121 |
*/
|
|
122 |
public void mouseClicked(MouseEvent E) {
|
|
123 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
124 |
if (layout.getTool() == Layout.SELECT) {
|
|
125 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
117 |
/**
|
|
118 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
|
119 |
*/
|
|
120 |
public void mouseClicked(MouseEvent E) {
|
|
121 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
122 |
if (layout.getTool() == Layout.SELECT) {
|
|
123 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
126 | 124 |
|
127 |
int i = layout.getFFrames().size() - 1;
|
|
128 |
boolean isSelect = false;
|
|
125 |
int i = layout.getFFrames().size() - 1;
|
|
126 |
boolean isSelect = false;
|
|
129 | 127 |
|
130 |
if (layout.getFFrames().size() > 0) {
|
|
131 |
ArrayList listSelect = new ArrayList();
|
|
128 |
if (layout.getFFrames().size() > 0) {
|
|
129 |
ArrayList listSelect = new ArrayList();
|
|
132 | 130 |
|
133 |
for (int j = 0; j < layout.getFFrames().size(); j++) {
|
|
134 |
if (((IFFrame) layout.getFFrames().get(j)).getContains(
|
|
135 |
m_pointSelected) != FFrame.NOSELECT) {
|
|
136 |
listSelect.add((IFFrame) layout.getFFrames().get(j));
|
|
137 |
}
|
|
138 |
}
|
|
131 |
for (int j = 0; j < layout.getFFrames().size(); j++) {
|
|
132 |
if (((IFFrame) layout.getFFrames().get(j)).getContains(
|
|
133 |
m_pointSelected) != FFrame.NOSELECT) {
|
|
134 |
listSelect.add((IFFrame) layout.getFFrames().get(j));
|
|
135 |
}
|
|
136 |
}
|
|
139 | 137 |
|
140 |
if (listSelect.size() > 0) {
|
|
141 |
for (int k = 0; k < listSelect.size(); k++) {
|
|
142 |
if (((IFFrame) listSelect.get(k)).getSelected() != FFrame.NOSELECT) {
|
|
143 |
index = listSelect.size() - k;
|
|
138 |
if (listSelect.size() > 0) {
|
|
139 |
for (int k = 0; k < listSelect.size(); k++) {
|
|
140 |
if (((IFFrame) listSelect.get(k)).getSelected() != FFrame.NOSELECT) {
|
|
141 |
index = listSelect.size() - k;
|
|
144 | 142 |
|
145 |
break;
|
|
146 |
}
|
|
147 |
}
|
|
143 |
break;
|
|
144 |
}
|
|
145 |
}
|
|
148 | 146 |
|
149 |
if (!FLayoutUtilities.isEqualList(listSelect, lastSelect) ||
|
|
150 |
(index > (listSelect.size() - 1))) {
|
|
151 |
index = 0;
|
|
152 |
}
|
|
147 |
if (!FLayoutUtilities.isEqualList(listSelect, lastSelect) ||
|
|
148 |
(index > (listSelect.size() - 1))) {
|
|
149 |
index = 0;
|
|
150 |
}
|
|
153 | 151 |
|
154 |
for (int j = 0; j < layout.getFFrames().size(); j++) {
|
|
155 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(j);
|
|
152 |
for (int j = 0; j < layout.getFFrames().size(); j++) {
|
|
153 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(j);
|
|
156 | 154 |
|
157 |
if (!E.isShiftDown()) {
|
|
158 |
fframe.setSelected(false);
|
|
159 |
} else {
|
|
160 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
161 |
if (fframe.getContains(m_pointSelected) != FFrame.NOSELECT) {
|
|
162 |
fframe.setSelected(false);
|
|
163 |
}
|
|
164 |
}
|
|
165 |
}
|
|
166 |
}
|
|
155 |
if (!E.isShiftDown()) {
|
|
156 |
fframe.setSelected(false);
|
|
157 |
} else {
|
|
158 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
159 |
if (fframe.getContains(m_pointSelected) != FFrame.NOSELECT) {
|
|
160 |
fframe.setSelected(false);
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
}
|
|
167 | 165 |
|
168 |
((IFFrame) listSelect.get((listSelect.size() - 1 -
|
|
169 |
index))).setSelected(true);
|
|
170 |
index++;
|
|
171 |
lastSelect = listSelect;
|
|
172 |
}
|
|
166 |
((IFFrame) listSelect.get((listSelect.size() - 1 -
|
|
167 |
index))).setSelected(true);
|
|
168 |
index++;
|
|
169 |
lastSelect = listSelect;
|
|
170 |
}
|
|
173 | 171 |
|
174 |
layout.setStatus(Layout.SELECT);
|
|
175 |
layout.repaint();
|
|
172 |
layout.setStatus(Layout.SELECT);
|
|
173 |
layout.repaint();
|
|
176 | 174 |
|
177 |
if (E.getClickCount() > 1) {
|
|
178 |
FLayoutGraphics flg = new FLayoutGraphics(layout);
|
|
179 |
flg.openFFrameDialog();
|
|
180 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
181 |
layout.repaint();
|
|
175 |
if (E.getClickCount() > 1) {
|
|
176 |
FLayoutGraphics flg = new FLayoutGraphics(layout);
|
|
177 |
flg.openFFrameDialog();
|
|
178 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
179 |
layout.repaint();
|
|
182 | 180 |
|
183 |
//layout.setStatus(Layout.SELECT);
|
|
184 |
}
|
|
185 |
}
|
|
186 |
}
|
|
187 |
} else if (E.getButton() == MouseEvent.BUTTON2) {
|
|
188 |
}
|
|
189 |
}
|
|
181 |
//layout.setStatus(Layout.SELECT);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
}
|
|
185 |
} else if (E.getButton() == MouseEvent.BUTTON2) {
|
|
186 |
}
|
|
187 |
}
|
|
190 | 188 |
|
191 |
/**
|
|
192 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
|
193 |
*/
|
|
194 |
public void mouseEntered(MouseEvent arg0) {
|
|
195 |
/* TODO PluginServices.getMainFrame().getStatusBar().setMessage("0",
|
|
196 |
layout.getAtributes().getNameUnit());
|
|
197 |
*/ |
|
198 |
if (layout.getTool() == Layout.PAN) {
|
|
199 |
layout.setMapCursor(Layout.iLayoutpan);
|
|
200 |
} else if (layout.getTool() == Layout.ZOOM_MAS) {
|
|
201 |
layout.setMapCursor(Layout.iLayoutzoomin);
|
|
202 |
} else if (layout.getTool() == Layout.ZOOM_MENOS) {
|
|
203 |
layout.setMapCursor(Layout.iLayoutzoomout);
|
|
204 |
} else if (layout.getTool() == Layout.VIEW_PAN) {
|
|
205 |
layout.setMapCursor(Layout.ipan);
|
|
206 |
} else if (layout.getTool() == Layout.VIEW_ZOOMIN) {
|
|
207 |
layout.setMapCursor(Layout.izoomin);
|
|
208 |
} else if (layout.getTool() == Layout.VIEW_ZOOMOUT) {
|
|
209 |
layout.setMapCursor(Layout.izoomout);
|
|
210 |
}
|
|
211 |
}
|
|
189 |
/**
|
|
190 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
|
191 |
*/
|
|
192 |
public void mouseEntered(MouseEvent arg0) {
|
|
193 |
/* TODO PluginServices.getMainFrame().getStatusBar().setMessage("0",
|
|
194 |
layout.getAtributes().getNameUnit());
|
|
195 |
*/
|
|
196 |
if (layout.getTool() == Layout.PAN) {
|
|
197 |
layout.setMapCursor(Layout.iLayoutpan);
|
|
198 |
} else if (layout.getTool() == Layout.ZOOM_MAS) {
|
|
199 |
layout.setMapCursor(Layout.iLayoutzoomin);
|
|
200 |
} else if (layout.getTool() == Layout.ZOOM_MENOS) {
|
|
201 |
layout.setMapCursor(Layout.iLayoutzoomout);
|
|
202 |
} else if (layout.getTool() == Layout.VIEW_PAN) {
|
|
203 |
layout.setMapCursor(Layout.ipan);
|
|
204 |
} else if (layout.getTool() == Layout.VIEW_ZOOMIN) {
|
|
205 |
layout.setMapCursor(Layout.izoomin);
|
|
206 |
} else if (layout.getTool() == Layout.VIEW_ZOOMOUT) {
|
|
207 |
layout.setMapCursor(Layout.izoomout);
|
|
208 |
}
|
|
209 |
}
|
|
212 | 210 |
|
213 |
/**
|
|
214 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
|
215 |
*/
|
|
216 |
public void mouseExited(MouseEvent arg0) {
|
|
217 |
///TODO PluginServices.getMainFrame().getStatusBar().setMessage("0", "");
|
|
218 |
}
|
|
211 |
/**
|
|
212 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
|
213 |
*/
|
|
214 |
public void mouseExited(MouseEvent arg0) {
|
|
215 |
///TODO PluginServices.getMainFrame().getStatusBar().setMessage("0", "");
|
|
216 |
}
|
|
219 | 217 |
|
220 |
/**
|
|
221 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
|
222 |
*/
|
|
223 |
public void mousePressed(MouseEvent E) {
|
|
224 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
225 |
Point pScreen = new Point(E.getX(), E.getY());
|
|
226 |
layout.setPointAnt(pScreen);
|
|
227 |
layout.setFirstPoint(layout.getPointAnt());
|
|
218 |
/**
|
|
219 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
|
220 |
*/
|
|
221 |
public void mousePressed(MouseEvent E) {
|
|
222 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
223 |
Point pScreen = new Point(E.getX(), E.getY());
|
|
224 |
layout.setPointAnt(pScreen);
|
|
225 |
layout.setFirstPoint(layout.getPointAnt());
|
|
228 | 226 |
|
229 |
if ((layout.getTool() == Layout.ZOOM_MAS) ||
|
|
230 |
(layout.getTool() == Layout.VIEW_ZOOMIN)) {
|
|
231 |
layout.setStatus(Layout.ZOOM_MAS);
|
|
232 |
} else if ((layout.getTool() == Layout.RECTANGLEVIEW) ||
|
|
233 |
(layout.getTool() == Layout.RECTANGLEPICTURE) ||
|
|
234 |
(layout.getTool() == Layout.RECTANGLESCALEBAR) ||
|
|
235 |
(layout.getTool() == Layout.RECTANGLELEGEND) ||
|
|
236 |
(layout.getTool() == Layout.RECTANGLETEXT)) {
|
|
237 |
layout.setStatus(Layout.RECTANGLE);
|
|
238 |
} else if ((layout.getTool() == Layout.POINT) ||
|
|
239 |
(layout.getTool() == Layout.LINE) ||
|
|
240 |
(layout.getTool() == Layout.POLYLINE) ||
|
|
241 |
(layout.getTool() == Layout.RECTANGLESIMPLE) ||
|
|
242 |
(layout.getTool() == Layout.CIRCLE) ||
|
|
243 |
(layout.getTool() == Layout.POLYGON)) {
|
|
244 |
layout.setStatus(Layout.RECTANGLE);
|
|
245 |
} else if (layout.getTool() == Layout.PAN) {
|
|
246 |
layout.getRectOrigin().setLocation(layout.getRect().x,
|
|
247 |
layout.getRect().y);
|
|
248 |
layout.setStatus(Layout.PAN);
|
|
249 |
} else if (layout.getTool() == Layout.VIEW_PAN) {
|
|
250 |
/* layout.getRectOrigin().setLocation(layout.getRect().x,
|
|
251 |
layout.getRect().y);
|
|
252 |
*/
|
|
253 |
layout.setStatus(Layout.VIEW_PAN);
|
|
254 |
} else if (layout.getTool() == Layout.ZOOM_MENOS) {
|
|
255 |
layout.setCancelDrawing(true);
|
|
256 |
} else if ((layout.getTool() == Layout.ZOOM_MAS) ||
|
|
257 |
(layout.getTool() == Layout.PAN)) {
|
|
258 |
layout.setCancelDrawing(true);
|
|
259 |
} else if (layout.getTool() == Layout.SELECT) {
|
|
260 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
227 |
if ((layout.getTool() == Layout.ZOOM_MAS) ||
|
|
228 |
(layout.getTool() == Layout.VIEW_ZOOMIN)) {
|
|
229 |
layout.setStatus(Layout.ZOOM_MAS);
|
|
230 |
} else if ((layout.getTool() == Layout.RECTANGLEVIEW) ||
|
|
231 |
(layout.getTool() == Layout.RECTANGLEPICTURE) ||
|
|
232 |
(layout.getTool() == Layout.RECTANGLESCALEBAR) ||
|
|
233 |
(layout.getTool() == Layout.RECTANGLELEGEND) ||
|
|
234 |
(layout.getTool() == Layout.RECTANGLETEXT)) {
|
|
235 |
layout.setStatus(Layout.RECTANGLE);
|
|
236 |
} else if ((layout.getTool() == Layout.POINT) ||
|
|
237 |
(layout.getTool() == Layout.LINE) ||
|
|
238 |
(layout.getTool() == Layout.POLYLINE) ||
|
|
239 |
(layout.getTool() == Layout.RECTANGLESIMPLE) ||
|
|
240 |
(layout.getTool() == Layout.CIRCLE) ||
|
|
241 |
(layout.getTool() == Layout.POLYGON)) {
|
|
242 |
layout.setStatus(Layout.RECTANGLE);
|
|
243 |
} else if (layout.getTool() == Layout.PAN) {
|
|
244 |
layout.getRectOrigin().setLocation(layout.getRect().x,
|
|
245 |
layout.getRect().y);
|
|
246 |
layout.setStatus(Layout.PAN);
|
|
247 |
} else if (layout.getTool() == Layout.VIEW_PAN) {
|
|
248 |
/* layout.getRectOrigin().setLocation(layout.getRect().x,
|
|
249 |
layout.getRect().y);
|
|
250 |
*/
|
|
251 |
layout.setStatus(Layout.VIEW_PAN);
|
|
252 |
} else if (layout.getTool() == Layout.ZOOM_MENOS) {
|
|
253 |
layout.setCancelDrawing(true);
|
|
254 |
} else if ((layout.getTool() == Layout.ZOOM_MAS) ||
|
|
255 |
(layout.getTool() == Layout.PAN)) {
|
|
256 |
layout.setCancelDrawing(true);
|
|
257 |
} else if (layout.getTool() == Layout.SELECT) {
|
|
258 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
261 | 259 |
|
262 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
263 |
IFFrame fframe = ((IFFrame) layout.getFFrames().get(i));
|
|
260 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
261 |
IFFrame fframe = ((IFFrame) layout.getFFrames().get(i));
|
|
264 | 262 |
|
265 |
if (m_pointSelected != null) {
|
|
266 |
if (!E.isShiftDown()) {
|
|
267 |
if ((fframe.getSelected() != FFrame.NOSELECT)) {
|
|
268 |
fframe.setSelected(m_pointSelected);
|
|
269 |
}
|
|
270 |
}
|
|
271 |
}
|
|
263 |
if (m_pointSelected != null) {
|
|
264 |
if (!E.isShiftDown()) {
|
|
265 |
if ((fframe.getSelected() != FFrame.NOSELECT)) {
|
|
266 |
fframe.setSelected(m_pointSelected);
|
|
267 |
}
|
|
268 |
}
|
|
269 |
}
|
|
272 | 270 |
|
273 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
274 |
layout.setIsReSel(false);
|
|
275 |
}
|
|
276 |
}
|
|
271 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
272 |
layout.setIsReSel(false);
|
|
273 |
}
|
|
274 |
}
|
|
277 | 275 |
|
278 |
if ((layout.getLastPoint() != null) &&
|
|
279 |
(layout.getFirstPoint() != null)) {
|
|
280 |
layout.getLastPoint().setLocation(layout.getFirstPoint());
|
|
281 |
}
|
|
276 |
if ((layout.getLastPoint() != null) &&
|
|
277 |
(layout.getFirstPoint() != null)) {
|
|
278 |
layout.getLastPoint().setLocation(layout.getFirstPoint());
|
|
279 |
}
|
|
282 | 280 |
|
283 |
if (E.getClickCount() < 2) {
|
|
284 |
layout.setStatus(Layout.SELECT);
|
|
285 |
layout.repaint();
|
|
286 |
}
|
|
287 |
} else if (layout.getTool() == Layout.POINT) {
|
|
288 |
FFrameGraphics fframepoint = new FFrameGraphics();
|
|
289 |
fframepoint.setBoundBox(FLayoutUtilities.toSheetRect(
|
|
290 |
new Rectangle2D.Double(E.getX(), E.getY(), 20, 20),
|
|
291 |
layout.getAT()));
|
|
292 |
fframepoint.update(Layout.POINT, layout.getAT());
|
|
293 |
layout.addFFrame(fframepoint, true);
|
|
294 |
} else if (layout.getTool() == Layout.SET_TAG){
|
|
295 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
281 |
if (E.getClickCount() < 2) {
|
|
282 |
layout.setStatus(Layout.SELECT);
|
|
283 |
layout.repaint();
|
|
284 |
}
|
|
285 |
} else if (layout.getTool() == Layout.POINT) {
|
|
286 |
FFrameGraphics fframepoint = new FFrameGraphics();
|
|
287 |
fframepoint.setBoundBox(FLayoutUtilities.toSheetRect(
|
|
288 |
new Rectangle2D.Double(E.getX(), E.getY(), 20, 20),
|
|
289 |
layout.getAT()));
|
|
290 |
fframepoint.update(Layout.POINT, layout.getAT());
|
|
291 |
layout.addFFrame(fframepoint, true);
|
|
292 |
} else if (layout.getTool() == Layout.SET_TAG) {
|
|
293 |
m_pointSelected = new Point2D.Double(E.getX(), E.getY());
|
|
296 | 294 |
|
297 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
298 |
IFFrame fframe = ((IFFrame) layout.getFFrames().get(i));
|
|
295 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
296 |
IFFrame fframe = ((IFFrame) layout.getFFrames().get(i));
|
|
299 | 297 |
|
300 |
if (m_pointSelected != null) { |
|
301 |
if (fframe.contains(m_pointSelected)) { |
|
302 |
fframe.openTag(); |
|
303 |
} |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
} |
|
308 |
} else if (E.getButton() == MouseEvent.BUTTON3) { |
|
309 |
Popupmenu popupmenu = new Popupmenu(layout, E.getPoint()); |
|
310 |
} |
|
311 |
} |
|
298 |
if (m_pointSelected != null) { |
|
299 |
if (fframe.contains(m_pointSelected)) { |
|
300 |
fframe.openTag(); |
|
301 |
} |
|
302 |
} |
|
303 |
} |
|
304 |
} |
|
305 |
} else if (E.getButton() == MouseEvent.BUTTON3) { |
|
306 |
Popupmenu popupmenu = new Popupmenu(layout, E.getPoint()); |
|
307 |
} |
|
308 |
} |
|
312 | 309 |
|
313 |
/**
|
|
314 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent)
|
|
315 |
*/
|
|
316 |
public void mouseReleased(MouseEvent E) {
|
|
317 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
318 |
Point p1 = layout.getFirstPoint();
|
|
319 |
Point p2 = new Point(E.getX(), E.getY());
|
|
320 |
IFFrame fframe = null;
|
|
321 |
boolean isadd = false;
|
|
310 |
/**
|
|
311 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent)
|
|
312 |
*/
|
|
313 |
public void mouseReleased(MouseEvent E) {
|
|
314 |
if (E.getButton() == MouseEvent.BUTTON1) {
|
|
315 |
Point p1 = layout.getFirstPoint();
|
|
316 |
Point p2 = new Point(E.getX(), E.getY());
|
|
317 |
IFFrame fframe = null;
|
|
318 |
boolean isadd = false;
|
|
322 | 319 |
|
323 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
320 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
324 | 321 |
|
325 |
if (layout.getTool() == Layout.ZOOM_MAS) { |
|
326 |
zooms.setZoomIn(p1, p2); |
|
327 |
} else if ((layout.getTool() == Layout.ZOOM_MENOS) || |
|
328 |
(E.getButton() == MouseEvent.BUTTON3)) { |
|
329 |
zooms.setZoomOut(p2); |
|
330 |
} else if (layout.getTool() == Layout.SELECT) { |
|
331 |
events.setSelect(); |
|
332 |
} else if ((layout.getTool() == Layout.RECTANGLEVIEW) || |
|
333 |
(layout.getTool() == Layout.RECTANGLEPICTURE) || |
|
334 |
(layout.getTool() == Layout.RECTANGLESCALEBAR) || |
|
335 |
(layout.getTool() == Layout.RECTANGLELEGEND) || |
|
336 |
(layout.getTool() == Layout.RECTANGLETEXT) || |
|
337 |
(layout.getTool() == Layout.RECTANGLESIMPLE) || |
|
338 |
(layout.getTool() == Layout.LINE) || |
|
339 |
(layout.getTool() == Layout.POLYLINE) || |
|
340 |
(layout.getTool() == Layout.POLYGON) || |
|
341 |
(layout.getTool() == Layout.CIRCLE)) { |
|
342 |
events.setFFrame(); |
|
343 |
} else if (layout.getTool() == Layout.VIEW_ZOOMIN) { |
|
344 |
zooms.setViewZoomIn(p1, p2); |
|
345 |
} else if (layout.getTool() == Layout.VIEW_ZOOMOUT) { |
|
346 |
zooms.setViewZoomOut(p2); |
|
347 |
} else if (layout.getTool() == Layout.VIEW_PAN) { |
|
348 |
events.setViewPan(p1, p2); |
|
349 |
} |
|
322 |
if (layout.getTool() == Layout.ZOOM_MAS) { |
|
323 |
zooms.setZoomIn(p1, p2); |
|
324 |
} else if ((layout.getTool() == Layout.ZOOM_MENOS) || |
|
325 |
(E.getButton() == MouseEvent.BUTTON3)) { |
|
326 |
zooms.setZoomOut(p2); |
|
327 |
} else if (layout.getTool() == Layout.SELECT) { |
|
328 |
events.setSelect(); |
|
329 |
} else if ((layout.getTool() == Layout.RECTANGLEVIEW) || |
|
330 |
(layout.getTool() == Layout.RECTANGLEPICTURE) || |
|
331 |
(layout.getTool() == Layout.RECTANGLESCALEBAR) || |
|
332 |
(layout.getTool() == Layout.RECTANGLELEGEND) || |
|
333 |
(layout.getTool() == Layout.RECTANGLETEXT) || |
|
334 |
(layout.getTool() == Layout.RECTANGLESIMPLE) || |
|
335 |
(layout.getTool() == Layout.LINE) || |
|
336 |
(layout.getTool() == Layout.POLYLINE) || |
|
337 |
(layout.getTool() == Layout.POLYGON) || |
|
338 |
(layout.getTool() == Layout.CIRCLE) || |
|
339 |
(layout.getTool() == Layout.POINT)) { |
|
340 |
events.setFFrame(); |
|
341 |
} else if (layout.getTool() == Layout.VIEW_ZOOMIN) { |
|
342 |
zooms.setViewZoomIn(p1, p2); |
|
343 |
} else if (layout.getTool() == Layout.VIEW_ZOOMOUT) { |
|
344 |
zooms.setViewZoomOut(p2); |
|
345 |
} else if (layout.getTool() == Layout.VIEW_PAN) { |
|
346 |
events.setViewPan(p1, p2); |
|
347 |
} |
|
350 | 348 |
|
351 |
layout.setCancelDrawing(false);
|
|
352 |
} else if (E.getButton() == MouseEvent.BUTTON3) {
|
|
353 |
}
|
|
349 |
layout.setCancelDrawing(false);
|
|
350 |
} else if (E.getButton() == MouseEvent.BUTTON3) {
|
|
351 |
}
|
|
354 | 352 |
|
355 |
layout.repaint();
|
|
356 |
}
|
|
353 |
layout.repaint();
|
|
354 |
}
|
|
357 | 355 |
} |
Also available in: Unified diff