root / branches / v2_0_0_prep / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / CADToolAdapter.java @ 23842
History | View | Annotate | Download (49.1 KB)
1 |
package com.iver.cit.gvsig.gui.cad; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Cursor; |
5 |
import java.awt.FontMetrics; |
6 |
import java.awt.Graphics; |
7 |
import java.awt.Graphics2D; |
8 |
import java.awt.Image; |
9 |
import java.awt.Point; |
10 |
import java.awt.Toolkit; |
11 |
import java.awt.event.InputEvent; |
12 |
import java.awt.event.MouseEvent; |
13 |
import java.awt.event.MouseWheelEvent; |
14 |
import java.awt.geom.Point2D; |
15 |
import java.awt.geom.Rectangle2D; |
16 |
import java.awt.image.BufferedImage; |
17 |
import java.awt.image.MemoryImageSource; |
18 |
import java.util.ArrayList; |
19 |
import java.util.HashMap; |
20 |
import java.util.Iterator; |
21 |
import java.util.Stack; |
22 |
import java.util.prefs.Preferences; |
23 |
|
24 |
import org.cresques.cts.IProjection; |
25 |
import org.gvsig.fmap.data.exceptions.DataException; |
26 |
import org.gvsig.fmap.data.exceptions.ReadException; |
27 |
import org.gvsig.fmap.data.feature.CommandsRecord; |
28 |
import org.gvsig.fmap.data.feature.Feature; |
29 |
import org.gvsig.fmap.data.feature.FeatureSet; |
30 |
import org.gvsig.fmap.data.feature.FeatureStore; |
31 |
import org.gvsig.fmap.geom.Geometry; |
32 |
import org.gvsig.fmap.geom.primitive.DefaultEnvelope; |
33 |
import org.gvsig.fmap.geom.util.Converter; |
34 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
35 |
import org.gvsig.fmap.mapcontext.MapContext; |
36 |
import org.gvsig.fmap.mapcontext.ViewPort; |
37 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
38 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
39 |
import org.gvsig.fmap.mapcontext.rendering.symbols.FSymbol; |
40 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
41 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
42 |
import org.gvsig.fmap.mapcontrol.MapControl; |
43 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
44 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
45 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
46 |
|
47 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.andami.messages.NotificationManager; |
49 |
import com.iver.andami.ui.mdiFrame.MainFrame; |
50 |
import com.iver.andami.ui.mdiManager.IWindow; |
51 |
import com.iver.cit.gvsig.CADExtension; |
52 |
import com.iver.cit.gvsig.EditionManager; |
53 |
import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool; |
54 |
import com.iver.cit.gvsig.layers.ILayerEdited; |
55 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
56 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
57 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
58 |
import com.iver.utiles.console.JConsole; |
59 |
import com.vividsolutions.jts.geom.Envelope; |
60 |
|
61 |
/**
|
62 |
* <p>Allows user interact with different CAD tools, on a layer being edited.</p>
|
63 |
*
|
64 |
* <p>There are two ways of interacting:
|
65 |
* <ul>
|
66 |
* <li><b>With the mouse</b> : user selects any {@link CADTool CADTool} that produces mouse events as consequence
|
67 |
* of the actions working with the layer being edited.
|
68 |
* </li>
|
69 |
* <li><b>Writing commands in the edition console</b> : most of the {@link CADTool CADTool} mouse actions can also
|
70 |
* be called writing a command or a command's parameter in the associated edition console, and pressing the key <code>Enter</code>.
|
71 |
* If the command isn't valid, will notify it.
|
72 |
* </li>
|
73 |
* </ul>
|
74 |
* </p>
|
75 |
*
|
76 |
* <p>The edition has been implemented as a <i>finite machine</i>, with three kind of transitions between states according
|
77 |
* the parameters introduced:
|
78 |
* <ul>
|
79 |
* <li><i>First transition type: <b>Point</i></b>: if <code>text</code> matches with any pattern of
|
80 |
* parameters needed for any kind of point coordinates.<br>
|
81 |
* There are eight ways of introducing point 2D coordinates:
|
82 |
* <ul>
|
83 |
* <li><i>X,Y</i> : absolute cardinal 2D coordinate from the center <i>(0,0)</i> of the CCS <i>Current Coordinate System</i>.</li>
|
84 |
* <li><i>@X,Y</i> : relative cardinal 2D distances from the last point added of the CCS. If it's the first point of the geometry,
|
85 |
* works like <i>X,Y</i>.</li>
|
86 |
* <li><i>length< angle</i> : absolute polar 2D coordinate from the center <i>(0,0)</i> of the CCS <i>Current Coordinate System</i>, using
|
87 |
* <i>angle</i> from the <i>X</i> axis of CCS, and <i>length</i> far away.</li>
|
88 |
* <li><i>@length< angle</i> : relative polar 2D coordinate from the last point added of the CCS <i>Current Coordinate System</i>, using
|
89 |
* <i>angle</i> from the <i>X</i> axis of CCS, and <i>length</i> far away. If it's the first point of the geometry,
|
90 |
* works like <i>length< angle</i>.</li>
|
91 |
* <li><i>*X,Y</i> : like <i>X,Y</i> but using UCS <i>Universal Coordinate System</i> as reference.</li>
|
92 |
* <li><i>@*X,Y</i> : like <i>@X,Y</i> but using UCS <i>Universal Coordinate System</i> as reference.
|
93 |
* If it's the first point of the geometry, works like <i>*X,Y</i>.</li>
|
94 |
* <li><i>*length< angle</i> : like <i>length< angle</i> but using UCS <i>Universal Coordinate System</i> as reference.</li>
|
95 |
* <li><i>@*length< angle</i> : like <i>@length< angle</i> but using UCS <i>Universal Coordinate System</i> as reference.
|
96 |
* If it's the first point of the geometry, works like <i>*length< angle</i>.</li>
|
97 |
* </ul>
|
98 |
* </li>
|
99 |
* <li><i>Second transition type: <b>Value</i></b>: if recognizes it as a single number.</li>
|
100 |
* <li><i>Third transition type: <b>Option</i></b>: by default, if can't classify the information as a single number
|
101 |
* neither as a point. This information will be an <code>String</code> and dealt as an option of the current
|
102 |
* tool state. Ultimately, if isn't valid, <code>text</code> will be rewritten in the console notifying the user
|
103 |
* that isn't correct.</li>
|
104 |
* </ul>
|
105 |
* </p>
|
106 |
*
|
107 |
* @see Behavior
|
108 |
* @see MapControl
|
109 |
*/
|
110 |
public class CADToolAdapter extends Behavior { |
111 |
|
112 |
/**
|
113 |
* Stores the CAD tools to edit the layers of the associated <code>MapControl</code>.
|
114 |
*
|
115 |
* @see #addCADTool(String, CADTool)
|
116 |
* @see #getCadTool()
|
117 |
* @see #getCADTool(String)
|
118 |
*/
|
119 |
private static HashMap namesCadTools = new HashMap(); |
120 |
|
121 |
/**
|
122 |
* Reference to the object used to manage the edition of the layers of the associated <code>MapControl</code>.
|
123 |
*
|
124 |
* @see EditionManager
|
125 |
* @see #getEditionManager()
|
126 |
*/
|
127 |
private EditionManager editionManager = new EditionManager(); |
128 |
|
129 |
/**
|
130 |
* Identifies that the data are absolute coordinates of the new point from the (0, 0) position.
|
131 |
*/
|
132 |
public static final int ABSOLUTE = 0; |
133 |
|
134 |
/**
|
135 |
* Equivalent to {@link CADToolAdapter#ABSOLUTE CADToolAdapter#ABSOLUTE}.
|
136 |
*/
|
137 |
public static final int RELATIVE_SCP = 1; |
138 |
|
139 |
/**
|
140 |
* Identifies that the data are relative distances of the new point from the previous introduced.
|
141 |
*/
|
142 |
public static final int RELATIVE_SCU = 2; |
143 |
|
144 |
/**
|
145 |
* Identifies that the data are relative polar distances (longitude of the line and angle given in degrees)
|
146 |
* of the new point from the previous introduced.
|
147 |
*/
|
148 |
public static final int POLAR_SCP = 3; |
149 |
|
150 |
/**
|
151 |
* Identifies that the data are relative polar distances (longitude of the line and angle given in radians)
|
152 |
* of the new point from the previous introduced.
|
153 |
*/
|
154 |
public static final int POLAR_SCU = 4; |
155 |
|
156 |
/**
|
157 |
* Stores the 2D map coordinates of the last point added.
|
158 |
*/
|
159 |
private double[] previousPoint = null; |
160 |
|
161 |
/**
|
162 |
* <i>Stack with CAD tools.</i>
|
163 |
*
|
164 |
* <i>For each CAD tool we use, the last item added in this stack will
|
165 |
* display a different icon according to the current operation and its status.</i>
|
166 |
*/
|
167 |
private Stack cadToolStack = new Stack(); |
168 |
|
169 |
/**
|
170 |
* X coordinate of the last dragging or moving mouse event.
|
171 |
*/
|
172 |
private int lastX; |
173 |
|
174 |
/**
|
175 |
* Y coordinate of the last dragging or moving mouse event.
|
176 |
*/
|
177 |
private int lastY; |
178 |
|
179 |
/**
|
180 |
* Unused attribute.
|
181 |
*/
|
182 |
private ISymbol symbol = SymbologyFactory.createDefaultSymbolByShapeType(Geometry.TYPES.POINT, Color.RED); |
183 |
|
184 |
/**
|
185 |
* Represents the cursor's point selected in <i>map coordinates</i>.
|
186 |
*
|
187 |
* @see MapControl#toMapPoint
|
188 |
*/
|
189 |
private Point2D mapAdjustedPoint; |
190 |
|
191 |
/**
|
192 |
* Kind of geometry drawn to identify the kind of control point selected by the cursor's mouse.
|
193 |
*/
|
194 |
// private ISnapper usedSnap = null;
|
195 |
|
196 |
/**
|
197 |
* Determines if has displayed at the edition console, the question for the operations that can do
|
198 |
* the user with the current CAD tool, in its current state.
|
199 |
*/
|
200 |
private boolean questionAsked = false; |
201 |
|
202 |
/**
|
203 |
* Represents the cursor's point selected in <i>screen coordinates</i>.
|
204 |
*
|
205 |
* @see ViewPort#fromMapPoint(Point2D)
|
206 |
*/
|
207 |
private Point2D adjustedPoint; |
208 |
|
209 |
/**
|
210 |
* Determines if the snap tools are enabled or disabled.
|
211 |
*
|
212 |
* @see #isRefentEnabled()
|
213 |
* @see #setRefentEnabled(boolean)
|
214 |
*/
|
215 |
// private boolean bRefent = true;
|
216 |
|
217 |
/**
|
218 |
* <p>Determines if the position of the snap of the mouse's cursor on the <code>MapControl</code>
|
219 |
* is within the area around a control point of a geometry.</p>
|
220 |
*
|
221 |
* <p>The area is calculated as a circle centered at the control point and with radius the pixels tolerance
|
222 |
* defined in the preferences.</p>
|
223 |
*/
|
224 |
// private boolean bForceCoord = false;
|
225 |
|
226 |
/**
|
227 |
* Optional grid that could be applied on the <code>MapControl</code>'s view port.
|
228 |
*
|
229 |
* @see #getGrid()
|
230 |
* @see #setAdjustGrid(boolean)
|
231 |
*/
|
232 |
// private CADGrid cadgrid = new CADGrid();
|
233 |
|
234 |
/**
|
235 |
* Determines is is enabled or not the <i>Orto</i> mode.
|
236 |
*/
|
237 |
private boolean bOrtoMode; |
238 |
|
239 |
/**
|
240 |
* A light yellow color for the tool tip text box associated to the point indicated by the mouse's cursor.
|
241 |
*/
|
242 |
private Color theTipColor = new Color(255, 255, 155); |
243 |
|
244 |
/**
|
245 |
* Last question asked to the user in the CAD console.
|
246 |
*/
|
247 |
private Object lastQuestion; |
248 |
|
249 |
/**
|
250 |
* Maximum tolerance in the approximation of a curved line by a polyline.
|
251 |
*
|
252 |
* @see #initializeFlatness()
|
253 |
*/
|
254 |
private static boolean flatnessInitialized=false; |
255 |
|
256 |
/**
|
257 |
* Edition preferences.
|
258 |
*/
|
259 |
private static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
260 |
|
261 |
/**
|
262 |
* Listener to display the coordinates in the current application's status bar.
|
263 |
*/
|
264 |
private StatusBarListener sbl=null; |
265 |
|
266 |
/*
|
267 |
* (non-Javadoc)
|
268 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setMapControl(com.iver.cit.gvsig.fmap.MapControl)
|
269 |
*/
|
270 |
public void setMapControl(MapControl mc) { |
271 |
super.setMapControl(mc);
|
272 |
sbl=new StatusBarListener(getMapControl());
|
273 |
} |
274 |
private static final Image imageCursor=new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB); |
275 |
static {
|
276 |
Graphics g=imageCursor.getGraphics();
|
277 |
int size1 = 15; |
278 |
int size2 = 3; |
279 |
int x=16; |
280 |
int y=16; |
281 |
g.setColor(Color.MAGENTA);
|
282 |
g.drawLine((int) (x - size1), (int) (y), |
283 |
(int) (x + size1), (int) (y)); |
284 |
g.drawLine((int) (x), (int) (y - size1), |
285 |
(int) (x), (int) (y + size1)); |
286 |
// g.setColor(Color.MAGENTA);
|
287 |
g.drawRect((int) (x - 6), |
288 |
(int) (y - 6), 12, 12); |
289 |
g.drawRect((int) (x - 3), |
290 |
(int) (y - 3), 6, 6); |
291 |
|
292 |
// // getMapControl().setToolTipText(null);
|
293 |
// if (adjustedPoint != null) {
|
294 |
// if (bForceCoord) {
|
295 |
// /* g.setColor(Color.ORANGE);
|
296 |
// g.drawRect((int) (adjustedPoint.getX() - 6),
|
297 |
// (int) (adjustedPoint.getY() - 6), 12, 12);
|
298 |
// g.drawRect((int) (adjustedPoint.getX() - 3),
|
299 |
// (int) (adjustedPoint.getY() - 3), 6, 6);
|
300 |
// g.setColor(Color.MAGENTA);
|
301 |
// g.drawRect((int) (adjustedPoint.getX() - 4),
|
302 |
// (int) (adjustedPoint.getY() - 4), 8, 8); */
|
303 |
// if (usedSnap != null)
|
304 |
// {
|
305 |
// usedSnap.draw(g, adjustedPoint);
|
306 |
//
|
307 |
// Graphics2D g2 = (Graphics2D) g;
|
308 |
// FontMetrics metrics = g2.getFontMetrics();
|
309 |
// int w = metrics.stringWidth(usedSnap.getToolTipText()) + 5;
|
310 |
// int h = metrics.getMaxAscent() + 5;
|
311 |
// int x = (int)p.getX()+9;
|
312 |
// int y = (int)p.getY()- 7;
|
313 |
//
|
314 |
// g2.setColor(theTipColor );
|
315 |
// g2.fillRect(x, y-h, w, h);
|
316 |
// g2.setColor(Color.BLACK);
|
317 |
// g2.drawRect(x, y-h, w, h);
|
318 |
// g2.drawString(usedSnap.getToolTipText(), x+3, y-3);
|
319 |
//
|
320 |
//
|
321 |
// // getMapControl().setToolTipText(usedSnap.getToolTipText());
|
322 |
// }
|
323 |
//
|
324 |
// bForceCoord = false;
|
325 |
// } else {
|
326 |
// g.drawRect((int) (p.getX() - size2), (int) (p.getY() - size2),
|
327 |
// (int) (size2 * 2), (int) (size2 * 2));
|
328 |
// }
|
329 |
// }
|
330 |
|
331 |
|
332 |
} |
333 |
|
334 |
/**
|
335 |
* <p>Draws the selected geometries to edit. And, if the <i>snapping</i> is enabled,
|
336 |
* draws also its effect over them.</p>
|
337 |
*
|
338 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
|
339 |
*/
|
340 |
public void paintComponent(Graphics g) { |
341 |
super.paintComponent(g);
|
342 |
if (CADExtension.getCADToolAdapter()!=this) |
343 |
return;
|
344 |
|
345 |
if (adjustedPoint != null) { |
346 |
Point2D p = null; |
347 |
if (mapAdjustedPoint != null) { |
348 |
p = mapAdjustedPoint; |
349 |
} else {
|
350 |
p = getMapControl().getViewPort().toMapPoint(adjustedPoint); |
351 |
} |
352 |
|
353 |
((CADTool) cadToolStack.peek()) |
354 |
.drawOperation(g, p.getX(), p.getY()); |
355 |
} |
356 |
// drawCursor(g);
|
357 |
// getGrid().drawGrid(g);
|
358 |
} |
359 |
|
360 |
/**
|
361 |
* <p>Responds two kind of mouse click events:
|
362 |
* <ul>
|
363 |
* <li><b><i>One click of the third mouse's button</i></b>: displays a popup with edition options.</li>
|
364 |
* <li><b><i>Two clicks of the first mouse's button</i></b>: ends the last cad tool setting as end transition
|
365 |
* point the event's one.</li>
|
366 |
* </ul>
|
367 |
* </p>
|
368 |
*
|
369 |
*
|
370 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseClicked(java.awt.event.MouseEvent)
|
371 |
* @see CADExtension#showPopup(MouseEvent)
|
372 |
*/
|
373 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
374 |
if (e.getButton() == MouseEvent.BUTTON3) { |
375 |
CADExtension.showPopup(e); |
376 |
}else if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount()==2){ |
377 |
questionAsked = true;
|
378 |
if (!cadToolStack.isEmpty()) {
|
379 |
CADTool ct = (CADTool) cadToolStack.peek(); |
380 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
381 |
Point2D p;
|
382 |
|
383 |
if (mapAdjustedPoint != null) { |
384 |
p = mapAdjustedPoint; |
385 |
} else {
|
386 |
p = vp.toMapPoint(adjustedPoint); |
387 |
} |
388 |
ct.endTransition(p.getX(), p.getY(), e); |
389 |
previousPoint = new double[]{p.getX(),p.getY()}; |
390 |
} |
391 |
} |
392 |
} |
393 |
|
394 |
/*
|
395 |
* (non-Javadoc)
|
396 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseEntered(java.awt.event.MouseEvent)
|
397 |
*/
|
398 |
public void mouseEntered(MouseEvent e) throws BehaviorException { |
399 |
clearMouseImage(); |
400 |
} |
401 |
|
402 |
/*
|
403 |
* (non-Javadoc)
|
404 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseExited(java.awt.event.MouseEvent)
|
405 |
*/
|
406 |
public void mouseExited(MouseEvent e) throws BehaviorException { |
407 |
} |
408 |
|
409 |
/**
|
410 |
* Selects the vertex of a geometry at the point selected on the <code>MapControl</code>
|
411 |
* by pressing the first mouse's button.
|
412 |
*
|
413 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
|
414 |
*/
|
415 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
416 |
if (e.getButton() == MouseEvent.BUTTON1) { |
417 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
418 |
Point2D p;
|
419 |
|
420 |
if (mapAdjustedPoint != null) { |
421 |
p = mapAdjustedPoint; |
422 |
} else {
|
423 |
p = vp.toMapPoint(adjustedPoint); |
424 |
} |
425 |
transition(new double[] { p.getX(), p.getY() }, e, ABSOLUTE); |
426 |
} |
427 |
} |
428 |
|
429 |
// /**
|
430 |
// * <p>Adjusts the <code>point</code> to the grid if its enabled, and
|
431 |
// * sets <code>mapHandlerAdjustedPoint</code> with that new value.</p>
|
432 |
// *
|
433 |
// * <p>The value returned is the distance between those points: the original and
|
434 |
// * the adjusted one.</p>
|
435 |
// *
|
436 |
// * @param point point to adjust
|
437 |
// * @param mapHandlerAdjustedPoint <code>point</code> adjusted
|
438 |
// *
|
439 |
// * @return distance from <code>point</code> to the adjusted one. If there is no
|
440 |
// * adjustment, returns <code>Double.MAX_VALUE</code>.
|
441 |
// */
|
442 |
// private double adjustToHandler(Point2D point,
|
443 |
// Point2D mapHandlerAdjustedPoint) {
|
444 |
//
|
445 |
// if (!isRefentEnabled())
|
446 |
// return Double.MAX_VALUE;
|
447 |
//
|
448 |
// ILayerEdited aux = CADExtension.getEditionManager().getActiveLayerEdited();
|
449 |
// if (!(aux instanceof VectorialLayerEdited))
|
450 |
// return Double.MAX_VALUE;
|
451 |
// VectorialLayerEdited vle = (VectorialLayerEdited) aux;
|
452 |
//
|
453 |
// ArrayList snappers = vle.getSnappers();
|
454 |
// ArrayList layersToSnap = vle.getLayersToSnap();
|
455 |
//
|
456 |
//
|
457 |
// ViewPort vp = getMapControl().getViewPort();
|
458 |
//
|
459 |
// snappers=SnapConfigPage.getActivesSnappers();
|
460 |
//
|
461 |
// double mapTolerance = vp.toMapDistance(SelectionCADTool.tolerance);
|
462 |
// double minDist = mapTolerance;
|
463 |
//// double rw = getMapControl().getViewPort().toMapDistance(5);
|
464 |
// Point2D mapPoint = point;
|
465 |
// double middleTol=mapTolerance * 0.5;
|
466 |
// org.gvsig.fmap.geom.primitive.Envelope r = new DefaultEnvelope(mapPoint.getX() - middleTol,
|
467 |
// mapPoint.getY() - middleTol,
|
468 |
// mapPoint.getX() + middleTol,
|
469 |
// mapPoint.getY() + middleTol);
|
470 |
//
|
471 |
// Envelope e = Converter.convertEnvelopeToJTS(r);
|
472 |
//
|
473 |
// usedSnap = null;
|
474 |
// Point2D lastPoint = null;
|
475 |
// if (previousPoint != null)
|
476 |
// {
|
477 |
// lastPoint = new Point2D.Double(previousPoint[0], previousPoint[1]);
|
478 |
// }
|
479 |
// for (int j = 0; j < layersToSnap.size(); j++)
|
480 |
// {
|
481 |
// FLyrVect lyrVect = (FLyrVect) layersToSnap.get(j);
|
482 |
// SpatialCache cache = lyrVect.getSpatialCache();
|
483 |
// if (lyrVect.isVisible())
|
484 |
// {
|
485 |
// // La lista de snappers est? siempre ordenada por prioridad. Los de mayor
|
486 |
// // prioridad est?n primero.
|
487 |
// for (int i = 0; i < snappers.size(); i++)
|
488 |
// {
|
489 |
// ISnapper theSnapper = (ISnapper) snappers.get(i);
|
490 |
//
|
491 |
// if (usedSnap != null)
|
492 |
// {
|
493 |
// // Si ya tenemos un snap y es de alta prioridad, cogemos ese. (A no ser que en otra capa encontremos un snapper mejor)
|
494 |
// if (theSnapper.getPriority() < usedSnap.getPriority())
|
495 |
// break;
|
496 |
// }
|
497 |
// SnappingVisitor snapVisitor = null;
|
498 |
// Point2D theSnappedPoint = null;
|
499 |
//
|
500 |
// if (theSnapper instanceof ISnapperVectorial)
|
501 |
// {
|
502 |
// if (theSnapper instanceof ISnapperGeometriesVectorial) {
|
503 |
// snapVisitor=new GeometriesSnappingVisitor((ISnapperGeometriesVectorial) theSnapper,point,mapTolerance,lastPoint);
|
504 |
// }else {
|
505 |
// snapVisitor = new SnappingVisitor((ISnapperVectorial) theSnapper, point, mapTolerance, lastPoint);
|
506 |
// }
|
507 |
// // System.out.println("Cache size = " + cache.size());
|
508 |
// cache.query(e, snapVisitor);
|
509 |
// theSnappedPoint = snapVisitor.getSnapPoint();
|
510 |
//
|
511 |
// }
|
512 |
// if (theSnapper instanceof ISnapperRaster)
|
513 |
// {
|
514 |
// ISnapperRaster snapRaster = (ISnapperRaster) theSnapper;
|
515 |
// theSnappedPoint = snapRaster.getSnapPoint(getMapControl(), point, mapTolerance, lastPoint);
|
516 |
// }
|
517 |
//
|
518 |
//
|
519 |
// if (theSnappedPoint != null) {
|
520 |
// double distAux = theSnappedPoint.distance(point);
|
521 |
// if (minDist > distAux)
|
522 |
// {
|
523 |
// minDist = distAux;
|
524 |
// usedSnap = theSnapper;
|
525 |
// mapHandlerAdjustedPoint.setLocation(theSnappedPoint);
|
526 |
// }
|
527 |
// }
|
528 |
// }
|
529 |
// } // visible
|
530 |
// }
|
531 |
// if (usedSnap != null)
|
532 |
// return minDist;
|
533 |
// return Double.MAX_VALUE;
|
534 |
//
|
535 |
// }
|
536 |
|
537 |
/*
|
538 |
* (non-Javadoc)
|
539 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
|
540 |
*/
|
541 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
542 |
getMapControl().repaint(); |
543 |
} |
544 |
|
545 |
/*
|
546 |
* (non-Javadoc)
|
547 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
|
548 |
*/
|
549 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
550 |
lastX = e.getX(); |
551 |
lastY = e.getY(); |
552 |
adjustedPoint=e.getPoint(); |
553 |
// calculateSnapPoint(e.getPoint());
|
554 |
} |
555 |
|
556 |
/*
|
557 |
* (non-Javadoc)
|
558 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
|
559 |
*/
|
560 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
561 |
|
562 |
lastX = e.getX(); |
563 |
lastY = e.getY(); |
564 |
adjustedPoint=e.getPoint(); |
565 |
// calculateSnapPoint(e.getPoint());
|
566 |
|
567 |
showCoords(e.getPoint()); |
568 |
|
569 |
getMapControl().repaint(); |
570 |
} |
571 |
|
572 |
/**
|
573 |
* Displays the current coordinates of the mouse's cursor on the associated <code>MapControl</code>
|
574 |
* object, at the status bar of the application's main frame.
|
575 |
*
|
576 |
* @param pPix current 2D mouse's cursor coordinates on the <code>MapControl</code>
|
577 |
*/
|
578 |
private void showCoords(Point2D pPix) |
579 |
{ |
580 |
String[] axisText = new String[2]; |
581 |
axisText[0] = "X = "; |
582 |
axisText[1] = "Y = "; |
583 |
// NumberFormat nf = NumberFormat.getInstance();
|
584 |
MapControl mapControl = getMapControl(); |
585 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
586 |
IProjection iProj = vp.getProjection(); |
587 |
|
588 |
// if (iProj.getAbrev().equals("EPSG:4326") || iProj.getAbrev().equals("EPSG:4230")) {
|
589 |
// axisText[0] = "Lon = ";
|
590 |
// axisText[1] = "Lat = ";
|
591 |
// nf.setMaximumFractionDigits(8);
|
592 |
// } else {
|
593 |
// axisText[0] = "X = ";
|
594 |
// axisText[1] = "Y = ";
|
595 |
// nf.setMaximumFractionDigits(2);
|
596 |
// }
|
597 |
Point2D p;
|
598 |
if (mapAdjustedPoint == null) |
599 |
{ |
600 |
p = vp.toMapPoint(pPix); |
601 |
} |
602 |
else
|
603 |
{ |
604 |
p = mapAdjustedPoint; |
605 |
} |
606 |
sbl.setFractionDigits(p); |
607 |
axisText = sbl.setCoorDisplayText(axisText); |
608 |
MainFrame mF = PluginServices.getMainFrame(); |
609 |
|
610 |
if (mF != null) |
611 |
{ |
612 |
mF.getStatusBar().setMessage("units",
|
613 |
PluginServices.getText(this, MapContext.getDistanceNames()[vp.getDistanceUnits()]));
|
614 |
mF.getStatusBar().setControlValue("scale",String.valueOf(mapControl.getMapContext().getScaleView())); |
615 |
mF.getStatusBar().setMessage("projection", iProj.getAbrev());
|
616 |
|
617 |
String[] coords=sbl.getCoords(p); |
618 |
mF.getStatusBar().setMessage("x",
|
619 |
axisText[0] + coords[0]); |
620 |
mF.getStatusBar().setMessage("y",
|
621 |
axisText[1] + coords[1]); |
622 |
} |
623 |
} |
624 |
|
625 |
/**
|
626 |
* Hides the mouse's cursor.
|
627 |
*/
|
628 |
private void clearMouseImage() { |
629 |
int[] pixels = new int[16 * 16]; |
630 |
Image image = Toolkit.getDefaultToolkit().createImage( |
631 |
new MemoryImageSource(16, 16, pixels, 0, 16)); |
632 |
Cursor transparentCursor = Toolkit.getDefaultToolkit() |
633 |
.createCustomCursor(image, new Point(0, 0), "invisiblecursor"); |
634 |
|
635 |
getMapControl().setCursor(transparentCursor); |
636 |
} |
637 |
|
638 |
/**
|
639 |
* <p>Draws a 31x31 pixels cross round the mouse's cursor with an small geometry centered:
|
640 |
* <ul>
|
641 |
* <li><i>an square centered</i>: if isn't over a <i>control point</i>.
|
642 |
* <li><i>an small geometry centered according to the kind of control point</i>: if it's over a control
|
643 |
* point. In this case, the small geometry is drawn by a {@link ISnapper ISnapper} type object.<br>
|
644 |
* On the other hand, a light-yellowed background tool tip text with the type of <i>control point</i> will
|
645 |
* be displayed.</li>
|
646 |
* </p>
|
647 |
*
|
648 |
* @param g <code>MapControl</code>'s graphics where the data will be drawn
|
649 |
*/
|
650 |
// private void drawCursor(Graphics g) {
|
651 |
// g.setColor(Color.black);
|
652 |
// Point2D p = adjustedPoint;
|
653 |
//
|
654 |
// if (p == null) {
|
655 |
// getGrid().setViewPort(getMapControl().getViewPort());
|
656 |
//
|
657 |
// return;
|
658 |
// }
|
659 |
//
|
660 |
// int size1 = 15;
|
661 |
// int size2 = 3;
|
662 |
// g.drawLine((int) (p.getX() - size1), (int) (p.getY()),
|
663 |
// (int) (p.getX() + size1), (int) (p.getY()));
|
664 |
// g.drawLine((int) (p.getX()), (int) (p.getY() - size1),
|
665 |
// (int) (p.getX()), (int) (p.getY() + size1));
|
666 |
//
|
667 |
// // getMapControl().setToolTipText(null);
|
668 |
// if (adjustedPoint != null) {
|
669 |
// if (bForceCoord) {
|
670 |
// /* g.setColor(Color.ORANGE);
|
671 |
// g.drawRect((int) (adjustedPoint.getX() - 6),
|
672 |
// (int) (adjustedPoint.getY() - 6), 12, 12);
|
673 |
// g.drawRect((int) (adjustedPoint.getX() - 3),
|
674 |
// (int) (adjustedPoint.getY() - 3), 6, 6);
|
675 |
// g.setColor(Color.MAGENTA);
|
676 |
// g.drawRect((int) (adjustedPoint.getX() - 4),
|
677 |
// (int) (adjustedPoint.getY() - 4), 8, 8); */
|
678 |
// if (usedSnap != null)
|
679 |
// {
|
680 |
// usedSnap.draw(g, adjustedPoint);
|
681 |
//
|
682 |
// Graphics2D g2 = (Graphics2D) g;
|
683 |
// FontMetrics metrics = g2.getFontMetrics();
|
684 |
// int w = metrics.stringWidth(usedSnap.getToolTipText()) + 5;
|
685 |
// int h = metrics.getMaxAscent() + 5;
|
686 |
// int x = (int)p.getX()+9;
|
687 |
// int y = (int)p.getY()- 7;
|
688 |
//
|
689 |
// g2.setColor(theTipColor );
|
690 |
// g2.fillRect(x, y-h, w, h);
|
691 |
// g2.setColor(Color.BLACK);
|
692 |
// g2.drawRect(x, y-h, w, h);
|
693 |
// g2.drawString(usedSnap.getToolTipText(), x+3, y-3);
|
694 |
//
|
695 |
//
|
696 |
// // getMapControl().setToolTipText(usedSnap.getToolTipText());
|
697 |
// }
|
698 |
//
|
699 |
// bForceCoord = false;
|
700 |
// } else {
|
701 |
// g.drawRect((int) (p.getX() - size2), (int) (p.getY() - size2),
|
702 |
// (int) (size2 * 2), (int) (size2 * 2));
|
703 |
// }
|
704 |
// }
|
705 |
// }
|
706 |
|
707 |
/**
|
708 |
* <p>Tries to find the nearest geometry or grid control point by the position of the current snap tool.</p>
|
709 |
*
|
710 |
* <p>Prioritizes the grid control points than the geometries ones.</p>
|
711 |
*
|
712 |
* <p>If finds any near, stores the <i>map</i> and <i>pixel</i> coordinates for the snap, and enables
|
713 |
* the <code>bForceCoord</code> attribute for the next draw of the mouse's cursor.</p>
|
714 |
*
|
715 |
* @param point current mouse 2D position
|
716 |
*/
|
717 |
// private void calculateSnapPoint(Point point) {
|
718 |
// // Se comprueba el ajuste a rejilla
|
719 |
//
|
720 |
// Point2D gridAdjustedPoint = getMapControl().getViewPort().toMapPoint(
|
721 |
// point);
|
722 |
// double minDistance = Double.MAX_VALUE;
|
723 |
// CADTool ct = (CADTool) cadToolStack.peek();
|
724 |
// if (ct instanceof SelectionCADTool
|
725 |
// && ((SelectionCADTool) ct).getStatus().equals(
|
726 |
// "Selection.FirstPoint")) {
|
727 |
// mapAdjustedPoint = gridAdjustedPoint;
|
728 |
// adjustedPoint = (Point2D) point.clone();
|
729 |
// } else {
|
730 |
//
|
731 |
// minDistance = getGrid().adjustToGrid(gridAdjustedPoint);
|
732 |
// if (minDistance < Double.MAX_VALUE) {
|
733 |
// adjustedPoint = getMapControl().getViewPort().fromMapPoint(
|
734 |
// gridAdjustedPoint);
|
735 |
// mapAdjustedPoint = gridAdjustedPoint;
|
736 |
// } else {
|
737 |
// mapAdjustedPoint = null;
|
738 |
// }
|
739 |
// }
|
740 |
// Point2D handlerAdjustedPoint = null;
|
741 |
//
|
742 |
// // Se comprueba el ajuste a los handlers
|
743 |
// if (mapAdjustedPoint != null) {
|
744 |
// handlerAdjustedPoint = (Point2D) mapAdjustedPoint.clone(); // getMapControl().getViewPort().toMapPoint(point);
|
745 |
// } else {
|
746 |
// handlerAdjustedPoint = getMapControl().getViewPort().toMapPoint(
|
747 |
// point);
|
748 |
// }
|
749 |
//
|
750 |
// Point2D mapPoint = new Point2D.Double();
|
751 |
// double distance = adjustToHandler(handlerAdjustedPoint, mapPoint);
|
752 |
//
|
753 |
// if (distance < minDistance) {
|
754 |
// bForceCoord = true;
|
755 |
// adjustedPoint = getMapControl().getViewPort().fromMapPoint(mapPoint);
|
756 |
// mapAdjustedPoint = mapPoint;
|
757 |
// minDistance = distance;
|
758 |
// }
|
759 |
//
|
760 |
// // Si no hay ajuste
|
761 |
// if (minDistance == Double.MAX_VALUE) {
|
762 |
// adjustedPoint = point;
|
763 |
// mapAdjustedPoint = null;
|
764 |
// }
|
765 |
//
|
766 |
// }
|
767 |
|
768 |
/*
|
769 |
* (non-Javadoc)
|
770 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseWheelMoved(java.awt.event.MouseWheelEvent)
|
771 |
*/
|
772 |
public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException { |
773 |
} |
774 |
|
775 |
/**
|
776 |
* <p>Process the information written by the user about the next point coordinate, determining
|
777 |
* the kind of <i>transition</i> according the parameters written.</p>
|
778 |
*
|
779 |
* <p>After, invokes one of the three possible <i>transition</i> methods of the <i>finite machine</i> of
|
780 |
* edition:
|
781 |
* <ul>
|
782 |
* <li><i>First transition type: <b>Point</i></b>: if <code>text</code> matches with any pattern of
|
783 |
* parameters needed for any kind of point coordinates.<br>
|
784 |
* There are eight ways of introducing point 2D coordinates:
|
785 |
* <ul>
|
786 |
* <li><i>X,Y</i> : absolute cardinal 2D coordinate from the center <i>(0,0)</i> of the CCS <i>Current Coordinate System</i>.</li>
|
787 |
* <li><i>@X,Y</i> : relative cardinal 2D distances from the last point added of the CCS. If it's the first point of the geometry,
|
788 |
* works like <i>X,Y</i>.</li>
|
789 |
* <li><i>length< angle</i> : absolute polar 2D coordinate from the center <i>(0,0)</i> of the CCS <i>Current Coordinate System</i>, using
|
790 |
* <i>angle</i> from the <i>X</i> axis of CCS, and <i>length</i> far away.</li>
|
791 |
* <li><i>@length< angle</i> : relative polar 2D coordinate from the last point added of the CCS <i>Current Coordinate System</i>, using
|
792 |
* <i>angle</i> from the <i>X</i> axis of CCS, and <i>length</i> far away. If it's the first point of the geometry,
|
793 |
* works like <i>length< angle</i>.</li>
|
794 |
* <li><i>*X,Y</i> : like <i>X,Y</i> but using UCS <i>Universal Coordinate System</i> as reference.</li>
|
795 |
* <li><i>@*X,Y</i> : like <i>@X,Y</i> but using UCS <i>Universal Coordinate System</i> as reference.
|
796 |
* If it's the first point of the geometry, works like <i>*X,Y</i>.</li>
|
797 |
* <li><i>*length< angle</i> : like <i>length< angle</i> but using UCS <i>Universal Coordinate System</i> as reference.</li>
|
798 |
* <li><i>@*length< angle</i> : like <i>@length< angle</i> but using UCS <i>Universal Coordinate System</i> as reference.
|
799 |
* If it's the first point of the geometry, works like <i>*length< angle</i>.</li>
|
800 |
* </ul>
|
801 |
* </li>
|
802 |
* <li><i>Second transition type: <b>Value</i></b>: if recognizes it as a single number.</li>
|
803 |
* <li><i>Third transition type: <b>Option</i></b>: by default, if can't classify the information as a single number
|
804 |
* neither as a point. This information will be an <code>String</code> and dealt as an option of the current
|
805 |
* tool state. Ultimately, if isn't valid, <code>text</code> will be rewritten in the console notifying the user
|
806 |
* that isn't correct.</li>
|
807 |
* </ul>
|
808 |
* </p>
|
809 |
*
|
810 |
* @param text command written by user in the edition's console
|
811 |
*/
|
812 |
public void textEntered(String text) { |
813 |
if (text == null) { |
814 |
transition(PluginServices.getText(this,"cancel")); |
815 |
} else {
|
816 |
/*
|
817 |
* if ("".equals(text)) { transition("aceptar"); } else {
|
818 |
*/
|
819 |
text = text.trim(); |
820 |
int type = ABSOLUTE;
|
821 |
String[] numbers = new String[1]; |
822 |
numbers[0] = text;
|
823 |
if (text.indexOf(",") != -1) { |
824 |
|
825 |
numbers = text.split(",");
|
826 |
if (numbers[0].substring(0, 1).equals("@")) { |
827 |
numbers[0] = numbers[0].substring(1, numbers[0].length()); |
828 |
type = RELATIVE_SCU; |
829 |
if (numbers[0].substring(0, 1).equals("*")) { |
830 |
type = RELATIVE_SCP; |
831 |
numbers[0] = numbers[0].substring(1, numbers[0] |
832 |
.length()); |
833 |
} |
834 |
} |
835 |
} else if (text.indexOf("<") != -1) { |
836 |
type = POLAR_SCP; |
837 |
numbers = text.split("<");
|
838 |
if (numbers[0].substring(0, 1).equals("@")) { |
839 |
numbers[0] = numbers[0].substring(1, numbers[0].length()); |
840 |
type = POLAR_SCU; |
841 |
if (numbers[0].substring(0, 1).equals("*")) { |
842 |
type = POLAR_SCP; |
843 |
numbers[0] = numbers[0].substring(1, numbers[0] |
844 |
.length()); |
845 |
} |
846 |
} |
847 |
} |
848 |
|
849 |
double[] values = null; |
850 |
|
851 |
try {
|
852 |
if (numbers.length == 2) { |
853 |
// punto
|
854 |
values = new double[] { Double.parseDouble(numbers[0]), |
855 |
Double.parseDouble(numbers[1]) }; |
856 |
transition(values, null, type);
|
857 |
} else if (numbers.length == 1) { |
858 |
// valor
|
859 |
values = new double[] { Double.parseDouble(numbers[0]) }; |
860 |
transition(values[0]);
|
861 |
} |
862 |
} catch (NumberFormatException e) { |
863 |
transition(text); |
864 |
} catch (NullPointerException e) { |
865 |
transition(text); |
866 |
} |
867 |
// }
|
868 |
} |
869 |
getMapControl().repaint(); |
870 |
} |
871 |
|
872 |
/**
|
873 |
* If there are options related with the <code>CADTool</code> at the peek of the CAD tool stack,
|
874 |
* displays them as a popup.
|
875 |
*/
|
876 |
public void configureMenu() { |
877 |
String[] desc = ((CADTool) cadToolStack.peek()).getDescriptions(); |
878 |
// String[] labels = ((CADTool)
|
879 |
// cadToolStack.peek()).getCurrentTransitions();
|
880 |
CADExtension.clearMenu(); |
881 |
|
882 |
for (int i = 0; i < desc.length; i++) { |
883 |
if (desc[i] != null) { |
884 |
CADExtension |
885 |
.addMenuEntry(PluginServices.getText(this, desc[i]));// , |
886 |
// labels[i]);
|
887 |
} |
888 |
} |
889 |
|
890 |
} |
891 |
|
892 |
/**
|
893 |
* <p>One of the three kind of transaction methods of the <i>finite machine</i> of
|
894 |
* edition.</p>
|
895 |
*
|
896 |
* <p>This one deals <code>values</code> as two numbers that, according <code>type</code>
|
897 |
* calculate a new point 2D in the current layer edited in the associated <code>MapControl</code>.</p>
|
898 |
*
|
899 |
* <p>There are different ways of calculating the new point 2D coordinates, according the value of <code>type</code>, see
|
900 |
* {@link #textEntered(String) #textEntered(String)}.</p>
|
901 |
*
|
902 |
* <p>After applying the changes, updates the controls available for managing the current data.</p>
|
903 |
*
|
904 |
* @param values numbers needed to calculate the new point coordinates according <code>type</code>
|
905 |
* @param event event which generated this invocation (a <code>MouseEvent</code> or a <code>KeyEvent</code>)
|
906 |
* @param type kind of information that is <code>values</code>. According this parameter, will calculate the
|
907 |
* new point in a different way
|
908 |
*
|
909 |
* @see CADTool#transition(double, double, InputEvent)
|
910 |
* @see #transition(double)
|
911 |
* @see #transition(String)
|
912 |
*/
|
913 |
private void transition(double[] values, InputEvent event, int type) { |
914 |
questionAsked = true;
|
915 |
if (!cadToolStack.isEmpty()) {
|
916 |
CADTool ct = (CADTool) cadToolStack.peek(); |
917 |
|
918 |
switch (type) {
|
919 |
case ABSOLUTE:
|
920 |
ct.transition(values[0], values[1], event); |
921 |
previousPoint = values; |
922 |
break;
|
923 |
case RELATIVE_SCU:
|
924 |
// Comprobar que tenemos almacenado el punto anterior
|
925 |
// y crear nuevo con coordenadas relativas a ?l.
|
926 |
double[] auxSCU = values; |
927 |
if (previousPoint != null) { |
928 |
auxSCU[0] = previousPoint[0] + values[0]; |
929 |
auxSCU[1] = previousPoint[1] + values[1]; |
930 |
} |
931 |
ct.transition(auxSCU[0], auxSCU[1], event); |
932 |
|
933 |
previousPoint = auxSCU; |
934 |
break;
|
935 |
case RELATIVE_SCP:
|
936 |
// TODO de momento no implementado.
|
937 |
ct.transition(values[0], values[1], event); |
938 |
previousPoint = values; |
939 |
break;
|
940 |
case POLAR_SCU://Relativo |
941 |
// Comprobar que tenemos almacenado el punto anterior
|
942 |
// y crear nuevo con coordenadas relativas a ?l.
|
943 |
double[] auxPolarSCU = values; |
944 |
if (previousPoint != null) { |
945 |
Point2D point = UtilFunctions.getPoint(new Point2D.Double( |
946 |
previousPoint[0], previousPoint[1]), Math |
947 |
.toRadians(values[1]), values[0]); |
948 |
auxPolarSCU[0] = point.getX();
|
949 |
auxPolarSCU[1] = point.getY();
|
950 |
ct.transition(auxPolarSCU[0], auxPolarSCU[1], event); |
951 |
} else {
|
952 |
Point2D point = UtilFunctions.getPoint(new Point2D.Double( |
953 |
0, 0), Math.toRadians(values[1]), values[0]); |
954 |
auxPolarSCU[0] = point.getX();
|
955 |
auxPolarSCU[1] = point.getY();
|
956 |
ct.transition(auxPolarSCU[0], auxPolarSCU[1], event); |
957 |
} |
958 |
previousPoint = auxPolarSCU; |
959 |
break;
|
960 |
case POLAR_SCP://Absoluto |
961 |
double[] auxPolarSCP = values; |
962 |
if (previousPoint != null) { |
963 |
Point2D point = UtilFunctions.getPoint(new Point2D.Double( |
964 |
0, 0), Math |
965 |
.toRadians(values[1]), values[0]); |
966 |
auxPolarSCP[0] = point.getX();
|
967 |
auxPolarSCP[1] = point.getY();
|
968 |
ct.transition(auxPolarSCP[0], auxPolarSCP[1], event); |
969 |
} else {
|
970 |
Point2D point = UtilFunctions.getPoint(new Point2D.Double( |
971 |
0, 0), values[1], values[0]); |
972 |
auxPolarSCP[0] = point.getX();
|
973 |
auxPolarSCP[1] = point.getY();
|
974 |
ct.transition(auxPolarSCP[0], auxPolarSCP[1], event); |
975 |
} |
976 |
previousPoint = auxPolarSCP; |
977 |
break;
|
978 |
default:
|
979 |
break;
|
980 |
} |
981 |
askQuestion(); |
982 |
} |
983 |
configureMenu(); |
984 |
PluginServices.getMainFrame().enableControls(); |
985 |
} |
986 |
|
987 |
/**
|
988 |
* <p>One of the three kind of transaction methods of the <i>finite machine</i> of
|
989 |
* edition.</p>
|
990 |
*
|
991 |
* <p>This one deals <code>value</code> as a single number used as a parameter for the current
|
992 |
* tool state. Ultimately, if isn't valid, <code>number</code> will be rewritten in the
|
993 |
* console notifying the user that isn't correct.</p>
|
994 |
*
|
995 |
* <p>After applying the changes, updates the controls available for managing the current data.</p>
|
996 |
*
|
997 |
* @param value value for the current tool state
|
998 |
*
|
999 |
* @see CADTool#transition(double)
|
1000 |
* @see #transition(double[], InputEvent, int)
|
1001 |
* @see #transition(String)
|
1002 |
*/
|
1003 |
private void transition(double value) { |
1004 |
questionAsked = true;
|
1005 |
if (!cadToolStack.isEmpty()) {
|
1006 |
CADTool ct = (CADTool) cadToolStack.peek(); |
1007 |
ct.transition(value); |
1008 |
askQuestion(); |
1009 |
} |
1010 |
configureMenu(); |
1011 |
PluginServices.getMainFrame().enableControls(); |
1012 |
} |
1013 |
|
1014 |
/**
|
1015 |
* <p>One of the three kind of transaction methods of the <i>finite machine</i> of
|
1016 |
* edition.</p>
|
1017 |
*
|
1018 |
* <p>This one deals <code>option</code> as an option of the current
|
1019 |
* tool state. Ultimately, if isn't valid, <code>option</code> will be rewritten in the
|
1020 |
* console notifying the user that isn't correct.</p>
|
1021 |
*
|
1022 |
* @param option option for the current tool state
|
1023 |
*
|
1024 |
* @see CADTool#transition(String)
|
1025 |
* @see #transition(double[], InputEvent, int)
|
1026 |
* @see #transition(double)
|
1027 |
*/
|
1028 |
public void transition(String option) { |
1029 |
questionAsked = true;
|
1030 |
if (!cadToolStack.isEmpty()) {
|
1031 |
CADTool ct = (CADTool) cadToolStack.peek(); |
1032 |
try {
|
1033 |
ct.transition(option); |
1034 |
} catch (Exception e) { |
1035 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
1036 |
|
1037 |
if (window instanceof View) { |
1038 |
((View)window).getConsolePanel().addText(
|
1039 |
"\n" + PluginServices.getText(this, "incorrect_option") |
1040 |
+ " : " + option, JConsole.ERROR);
|
1041 |
} |
1042 |
} |
1043 |
askQuestion(); |
1044 |
} |
1045 |
configureMenu(); |
1046 |
PluginServices.getMainFrame().enableControls(); |
1047 |
} |
1048 |
|
1049 |
/**
|
1050 |
* Shows or hides a grid on the <code>ViewPort</code> of the associated <code>MapControl</code>.
|
1051 |
*
|
1052 |
* @param value <code>true</code> to make the grid visible; <code>false</code> to make it invisible
|
1053 |
*/
|
1054 |
// public void setGridVisibility(boolean value) {
|
1055 |
// getGrid().setShowGrid(value);
|
1056 |
// getGrid().setViewPort(getMapControl().getViewPort());
|
1057 |
// getMapControl().repaint();
|
1058 |
// }
|
1059 |
|
1060 |
// /**
|
1061 |
// * Sets the snap tools enabled or disabled.
|
1062 |
// *
|
1063 |
// * @param activated <code>true</code> to enable the snap tools; <code>false</code> to disable them
|
1064 |
// *
|
1065 |
// * @see #isRefentEnabled()
|
1066 |
// */
|
1067 |
// public void setRefentEnabled(boolean activated) {
|
1068 |
// bRefent = activated;
|
1069 |
// }
|
1070 |
//
|
1071 |
// /**
|
1072 |
// * Determines if snap tools are enabled or disabled.
|
1073 |
// *
|
1074 |
// * @return <code>true</code> to enable the snap tools; <code>false</code> to disable them
|
1075 |
// *
|
1076 |
// * @see #setRefentEnabled(boolean)
|
1077 |
// */
|
1078 |
// public boolean isRefentEnabled()
|
1079 |
// {
|
1080 |
// return bRefent;
|
1081 |
// }
|
1082 |
|
1083 |
/*
|
1084 |
* (non-Javadoc)
|
1085 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
|
1086 |
*/
|
1087 |
public ToolListener getListener() {
|
1088 |
return new ToolListener() { |
1089 |
/**
|
1090 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
1091 |
*/
|
1092 |
public Image getImageCursor() { |
1093 |
return imageCursor;
|
1094 |
} |
1095 |
|
1096 |
/**
|
1097 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
1098 |
*/
|
1099 |
public boolean cancelDrawing() { |
1100 |
return false; |
1101 |
} |
1102 |
}; |
1103 |
} |
1104 |
|
1105 |
/**
|
1106 |
* Returns the {@link CADTool CADTool} at the top of the stack without removing it from the CAD tool stack.
|
1107 |
*
|
1108 |
* @return the {@link CADTool CADTool} at the top of the stack
|
1109 |
*
|
1110 |
* @see #pushCadTool(CADTool)
|
1111 |
* @see #popCadTool()
|
1112 |
* @see #setCadTool(CADTool)
|
1113 |
*/
|
1114 |
public CADTool getCadTool() {
|
1115 |
return (CADTool) cadToolStack.peek();
|
1116 |
} |
1117 |
|
1118 |
/**
|
1119 |
* <p>Pushes a {@link CADTool CADTool} onto the top of the CAD tool stack, and sets it as current.</p>
|
1120 |
*
|
1121 |
* @param cadTool CAD tool to enable as current
|
1122 |
*
|
1123 |
* @see #getCadTool()
|
1124 |
* @see #popCadTool()
|
1125 |
* @see #setCadTool(CADTool)
|
1126 |
*/
|
1127 |
public void pushCadTool(CADTool cadTool) { |
1128 |
cadToolStack.push(cadTool); |
1129 |
cadTool.setCadToolAdapter(this);
|
1130 |
// cadTool.initializeStatus();
|
1131 |
// cadTool.setVectorialAdapter(vea);
|
1132 |
/*
|
1133 |
* int ret = cadTool.transition(null, editableFeatureSource, selection,
|
1134 |
* new double[0]);
|
1135 |
*
|
1136 |
* if ((ret & Automaton.AUTOMATON_FINISHED) ==
|
1137 |
* Automaton.AUTOMATON_FINISHED) { popCadTool();
|
1138 |
*
|
1139 |
* if (cadToolStack.isEmpty()) { pushCadTool(new
|
1140 |
* com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new
|
1141 |
* SelectionCadTool());
|
1142 |
* PluginServices.getMainFrame().setSelectedTool("selection"); }
|
1143 |
*
|
1144 |
* askQuestion();
|
1145 |
*
|
1146 |
* getMapControl().drawMap(false); }
|
1147 |
*/
|
1148 |
} |
1149 |
|
1150 |
/**
|
1151 |
* Removes the peek of the CAD tool stack.
|
1152 |
*
|
1153 |
* @see #pushCadTool(CADTool)
|
1154 |
* @see #getCadTool()
|
1155 |
* @see #setCadTool(CADTool)
|
1156 |
*/
|
1157 |
public void popCadTool() { |
1158 |
cadToolStack.pop(); |
1159 |
} |
1160 |
|
1161 |
/**
|
1162 |
* <p>Displays at the console associated to the current active view that's being edited, the question of the following
|
1163 |
* operation that user can do with the current <code>CADTool</code>, only if it hasn't just answered.</p>
|
1164 |
*
|
1165 |
* <p>The format of the question will be according the following pattern:<br>
|
1166 |
* "\n#"<i>{cadtool at CAD tool stack peek}</i>.getQuestion()">"
|
1167 |
* </p>
|
1168 |
*/
|
1169 |
public void askQuestion() { |
1170 |
CADTool cadtool = (CADTool) cadToolStack.peek(); |
1171 |
/*
|
1172 |
* if (cadtool..getStatus()==0){
|
1173 |
* PluginServices.getMainFrame().addTextToConsole("\n"
|
1174 |
* +cadtool.getName()); }
|
1175 |
*/
|
1176 |
if (PluginServices.getMDIManager().getActiveWindow() instanceof View) |
1177 |
{ |
1178 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
1179 |
String question=cadtool.getQuestion();
|
1180 |
if (lastQuestion==null || !(lastQuestion.equals(question)) || questionAsked) { |
1181 |
vista.getConsolePanel().addText( |
1182 |
"\n" + "#" + question + " > ", JConsole.MESSAGE); |
1183 |
// ***PluginServices.getMainFrame().addTextToConsole("\n" +
|
1184 |
// cadtool.getQuestion());
|
1185 |
questionAsked = false;
|
1186 |
} |
1187 |
lastQuestion=question; |
1188 |
} |
1189 |
|
1190 |
} |
1191 |
|
1192 |
/**
|
1193 |
* Empties the CAD tools stack and pushes <code>cadTool</code> in it.
|
1194 |
*
|
1195 |
* @param cadTool CAD tool to set at the peek of the stack
|
1196 |
*
|
1197 |
* @see #pushCadTool(CADTool)
|
1198 |
* @see #popCadTool()
|
1199 |
* @see #getCadTool()
|
1200 |
*/
|
1201 |
public void setCadTool(CADTool cadTool) { |
1202 |
cadToolStack.clear(); |
1203 |
pushCadTool(cadTool); |
1204 |
// askQuestion();
|
1205 |
} |
1206 |
|
1207 |
/**
|
1208 |
* <p>Removes all geometries selected in the associated <code>MapControl</code>.
|
1209 |
*/
|
1210 |
public void delete() { |
1211 |
ILayerEdited aux = CADExtension.getEditionManager().getActiveLayerEdited(); |
1212 |
if (!(aux instanceof VectorialLayerEdited)) |
1213 |
return;
|
1214 |
VectorialLayerEdited vle = (VectorialLayerEdited) aux; |
1215 |
FeatureStore featureStore=null;
|
1216 |
try {
|
1217 |
featureStore = ((FLyrVect)vle.getLayer()).getFeatureStore(); |
1218 |
} catch (ReadException e1) {
|
1219 |
// TODO Auto-generated catch block
|
1220 |
e1.printStackTrace(); |
1221 |
} |
1222 |
|
1223 |
CommandsRecord cr=featureStore.getCommandsRecord(); |
1224 |
cr.startComplex(); |
1225 |
try {
|
1226 |
FeatureSet selection = (FeatureSet)featureStore.getSelection(); |
1227 |
Iterator iterator=selection.iterator();
|
1228 |
while (iterator.hasNext()) {
|
1229 |
Feature feature = (Feature) iterator.next(); |
1230 |
featureStore.delete(feature); |
1231 |
} |
1232 |
// int[] indexesToDel = new int[selection.cardinality()];
|
1233 |
// int j = 0;
|
1234 |
// for (int i = selection.nextSetBit(0); i >= 0; i = selection
|
1235 |
// .nextSetBit(i + 1)) {
|
1236 |
// indexesToDel[j++] = i;
|
1237 |
// // /vea.removeRow(i);
|
1238 |
// }
|
1239 |
|
1240 |
// ArrayList selectedRow = vle.getSelectedRow();
|
1241 |
//
|
1242 |
// int[] indexesToDel = new int[selectedRow.size()];
|
1243 |
// for (int i = 0;i < selectedRow.size(); i++) {
|
1244 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i);
|
1245 |
// indexesToDel[i] = vea.getInversedIndex(edRow.getIndex());
|
1246 |
// }
|
1247 |
//
|
1248 |
// for (int i = indexesToDel.length - 1; i >= 0; i--) {
|
1249 |
// vea.removeRow(indexesToDel[i], PluginServices.getText(this,
|
1250 |
// "deleted_feature"),EditionEvent.GRAPHIC);
|
1251 |
// }
|
1252 |
System.out.println("clear Selection"); |
1253 |
selection.clear(); |
1254 |
vle.clearSelection(VectorialLayerEdited.NOTSAVEPREVIOUS); |
1255 |
} catch (ReadException e) {
|
1256 |
NotificationManager.addError(e.getMessage(),e); |
1257 |
} catch (DataException e) {
|
1258 |
NotificationManager.addError(e.getMessage(),e); |
1259 |
} finally {
|
1260 |
String description=PluginServices.getText(this,"remove_geometry"); |
1261 |
cr.endComplex(description); |
1262 |
} |
1263 |
|
1264 |
|
1265 |
/*
|
1266 |
* if (getCadTool() instanceof SelectionCADTool) { SelectionCADTool
|
1267 |
* selTool = (SelectionCADTool) getCadTool(); selTool.clearSelection(); }
|
1268 |
*/
|
1269 |
refreshEditedLayer(); |
1270 |
} |
1271 |
|
1272 |
/**
|
1273 |
* @see CADGrid#setAdjustGrid(boolean)
|
1274 |
*/
|
1275 |
// public void setAdjustGrid(boolean b) {
|
1276 |
// getGrid().setAdjustGrid(b);
|
1277 |
// }
|
1278 |
|
1279 |
/**
|
1280 |
* <p>Responds to actions of writing common key commands for all kind of CAD operations, enabling/disabling after
|
1281 |
* the controls to manage the available information according the tool selected:
|
1282 |
* <ul>
|
1283 |
* <li><i>eliminar</i>: removes the geometries that are now selected.</li>
|
1284 |
* <li><i>escape</i>: executes different actions according to the current CAD tool of the associated <code>MapControl</code>:
|
1285 |
* <ul>
|
1286 |
* <li>If the tool enabled is identified by <i>cadtooladapter</i>: empties the CAD tools stack, changing the current tool by
|
1287 |
* a {@link SelectionCADTool SelectionCADTool}, which is identified by <i>_selection</i> and allows select features of the
|
1288 |
* active vector layer of the associated <code>MapControl</code> instance. </li>
|
1289 |
* <li>Otherwise, that means current associated <code>MapControl</code> instance isn't identified by "<i>cadtooladapter</i>",
|
1290 |
* changes the enabled tool by the previous.</li>
|
1291 |
* </ul>
|
1292 |
* </li>
|
1293 |
* </ul>
|
1294 |
* </p>
|
1295 |
*
|
1296 |
* @param actionCommand identifier of the key action command executed by the user
|
1297 |
*
|
1298 |
* @see SelectionCADTool
|
1299 |
* @see MapControl#setPrevTool()
|
1300 |
*/
|
1301 |
public void keyPressed(String actionCommand) { |
1302 |
if (CADExtension.getEditionManager().getActiveLayerEdited()== null) { |
1303 |
return;
|
1304 |
} |
1305 |
if (actionCommand.equals("eliminar")) { |
1306 |
delete(); |
1307 |
} else if (actionCommand.equals("escape")) { |
1308 |
if (getMapControl().getCurrentTool().equals("cadtooladapter")) { |
1309 |
CADTool ct = (CADTool) cadToolStack.peek(); |
1310 |
ct.end(); |
1311 |
cadToolStack.clear(); |
1312 |
SelectionCADTool selCad = new SelectionCADTool();
|
1313 |
selCad.init(); |
1314 |
VectorialLayerEdited vle = (VectorialLayerEdited) CADExtension |
1315 |
.getEditionManager().getActiveLayerEdited(); |
1316 |
try {
|
1317 |
vle.clearSelection(VectorialLayerEdited.NOTSAVEPREVIOUS); |
1318 |
} catch (ReadException e) {
|
1319 |
NotificationManager.addError(e.getMessage(),e); |
1320 |
} |
1321 |
|
1322 |
pushCadTool(selCad); |
1323 |
// getVectorialAdapter().getSelection().clear();
|
1324 |
|
1325 |
refreshEditedLayer(); |
1326 |
|
1327 |
|
1328 |
PluginServices.getMainFrame().setSelectedTool("_selection");
|
1329 |
// askQuestion();
|
1330 |
} else {
|
1331 |
getMapControl().setPrevTool(); |
1332 |
} |
1333 |
} |
1334 |
|
1335 |
PluginServices.getMainFrame().enableControls(); |
1336 |
|
1337 |
} |
1338 |
|
1339 |
/**
|
1340 |
* <p>Applies a lightweight repaint of the active layer being edited.</p>
|
1341 |
*
|
1342 |
* <p>All layers under it won't be drawn, only the upper one and whose are over that layer in the TOC.</p>
|
1343 |
*
|
1344 |
* @see MapControl#rePaintDirtyLayers()
|
1345 |
*/
|
1346 |
public void refreshEditedLayer() |
1347 |
{ |
1348 |
ILayerEdited edLayer = CADExtension.getEditionManager().getActiveLayerEdited(); |
1349 |
if (edLayer != null) |
1350 |
{ |
1351 |
edLayer.getLayer().setDirty(true);
|
1352 |
getMapControl().rePaintDirtyLayers(); |
1353 |
} |
1354 |
|
1355 |
} |
1356 |
|
1357 |
/**
|
1358 |
* Gets the {@link CADGrid CADGrid} that can be drawn on the <code>ViewPort</code> of the associated <code>MapControl</code>.
|
1359 |
*
|
1360 |
* @return reference to the <i>grid</i> that can be applied on the <code>ViewPort</code>
|
1361 |
*
|
1362 |
* @see #setGridVisibility(boolean)
|
1363 |
*/
|
1364 |
// public CADGrid getGrid() {
|
1365 |
// return cadgrid;
|
1366 |
// }
|
1367 |
|
1368 |
/**
|
1369 |
* Determines if is enabled or not the <i>orto</i> mode.
|
1370 |
*
|
1371 |
* @return <code>true</code> if is enabled the <i>orto</i> mode; otherwise <code>false</code>
|
1372 |
*
|
1373 |
* @see #setOrtoMode(boolean)
|
1374 |
*/
|
1375 |
public boolean isOrtoMode() { |
1376 |
return bOrtoMode;
|
1377 |
} |
1378 |
|
1379 |
/**
|
1380 |
* Enables / disables the <i>orto</i> mode.
|
1381 |
*
|
1382 |
* @param b the desired value
|
1383 |
*
|
1384 |
* @see #isOrtoMode()
|
1385 |
*/
|
1386 |
public void setOrtoMode(boolean b) { |
1387 |
bOrtoMode = b; |
1388 |
} |
1389 |
|
1390 |
/**
|
1391 |
* Associates and stores the specified name with the specified {@link CADTool CADTool}.
|
1392 |
*
|
1393 |
* @param name name of the tool
|
1394 |
* @param c CAD tool to interactuate editing the layers
|
1395 |
*
|
1396 |
* @see #getCADTools()
|
1397 |
* @see #getCADTool(String)
|
1398 |
*/
|
1399 |
public static void addCADTool(String name, CADTool c) { |
1400 |
namesCadTools.put(name, c); |
1401 |
|
1402 |
} |
1403 |
|
1404 |
/**
|
1405 |
* Gets all CAD tools available to edit layers with this tool listener.
|
1406 |
*
|
1407 |
* @return CAD tools available to edit layers with this tool listener
|
1408 |
*
|
1409 |
* @see #addCADTool(String, CADTool)
|
1410 |
* @see #getCADTool(String)
|
1411 |
*/
|
1412 |
public static CADTool[] getCADTools() { |
1413 |
return (CADTool[]) CADToolAdapter.namesCadTools.values().toArray(new CADTool[0]); |
1414 |
} |
1415 |
|
1416 |
/**
|
1417 |
* Returns the {@link CADTool CADTool} to which the specified name is mapped.
|
1418 |
*
|
1419 |
* @param text name of the tool
|
1420 |
* @return the CAD tool whose associated name is to be returned
|
1421 |
*
|
1422 |
* @see #addCADTool(String, CADTool)
|
1423 |
* @see #getCADTools()
|
1424 |
*/
|
1425 |
public CADTool getCADTool(String text) { |
1426 |
CADTool ct = (CADTool) namesCadTools.get(text); |
1427 |
return ct;
|
1428 |
} |
1429 |
|
1430 |
/**
|
1431 |
* Gets the object used to manage the edition of the layers of the associated <code>MapControl</code>.
|
1432 |
*
|
1433 |
* @see EditionManager
|
1434 |
*
|
1435 |
* @return object used to manage the edition of the layers
|
1436 |
*/
|
1437 |
public EditionManager getEditionManager() {
|
1438 |
return editionManager;
|
1439 |
} |
1440 |
|
1441 |
/**
|
1442 |
* <p>Initializes the <i>flatness</i> with the defined in preferences.</p>
|
1443 |
*
|
1444 |
* <p>The <i>flatness</i> is the maximum tolerance used to approximate curved lines in a <i>shape</i> by polylines.</p>
|
1445 |
* <p>The shapes doesn't support primitive like arcs neither other curved lines to draw their geometries, then for drawing any
|
1446 |
* kind of this geometries the curved lines are drawn approximately by a polyline. And for doing more realistic that curves,
|
1447 |
* is used the <i>flatness</i> parameter, that indicates that the difference between each arc and the straight segment that
|
1448 |
* approximates it must be in the worse case, like the <i>flatness</i>.</p>
|
1449 |
*
|
1450 |
* @see FConverter#FLATNESS
|
1451 |
*/
|
1452 |
public void initializeFlatness() { |
1453 |
if (!flatnessInitialized){
|
1454 |
flatnessInitialized=true;
|
1455 |
Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
1456 |
double flatness = prefs.getDouble("flatness",Converter.FLATNESS); |
1457 |
Converter.FLATNESS=flatness; |
1458 |
} |
1459 |
} |
1460 |
|
1461 |
/**
|
1462 |
* <p>Updates the grid on the <code>ViewPort</code> of the associated <code>MapControl</code>
|
1463 |
* object according the values in the {@link com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences}.</p>
|
1464 |
*
|
1465 |
* <p>The preferences are:
|
1466 |
* <ul>
|
1467 |
* <li>Show/hide the grid.</li>
|
1468 |
* <li>Adjust or not the grid.</li>
|
1469 |
* <li>Horizontal ( X ) line separation.</li>
|
1470 |
* <li>Vertical ( Y ) line separation.</li>
|
1471 |
* </ul>
|
1472 |
* </p>
|
1473 |
*/
|
1474 |
// public void initializeGrid(){
|
1475 |
// boolean showGrid = prefs.getBoolean("grid.showgrid",getGrid().isShowGrid());
|
1476 |
// boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",getGrid().isAdjustGrid());
|
1477 |
//
|
1478 |
// double dx = prefs.getDouble("grid.distancex",getGrid().getGridSizeX());
|
1479 |
// double dy = prefs.getDouble("grid.distancey",getGrid().getGridSizeY());
|
1480 |
//
|
1481 |
// setGridVisibility(showGrid);
|
1482 |
// setAdjustGrid(adjustGrid);
|
1483 |
// getGrid().setGridSizeX(dx);
|
1484 |
// getGrid().setGridSizeY(dy);
|
1485 |
// }
|
1486 |
|
1487 |
/**
|
1488 |
* <p>Returns the type of the shape that's the current active and vector layer being edited.</p>
|
1489 |
*
|
1490 |
* @see FLyrVect#getShapeType()
|
1491 |
*
|
1492 |
* @return type of the shape that's the current active and vector layer being edited
|
1493 |
*/
|
1494 |
public int getActiveLayerType() { |
1495 |
int type=Geometry.TYPES.GEOMETRY;
|
1496 |
try {
|
1497 |
type=((FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer()).getShapeType(); |
1498 |
} catch (ReadException e) {
|
1499 |
NotificationManager.addError(e); |
1500 |
} |
1501 |
return type;
|
1502 |
} |
1503 |
|
1504 |
} |