root / trunk / extensions / extQuickInfo / src / org / gvsig / quickInfo / tools / QuickInfoListener.java @ 27817
History | View | Annotate | Download (39 KB)
1 |
package org.gvsig.quickInfo.tools; |
---|---|
2 |
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government
|
4 |
*
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
6 |
* of the Valencian Government (CIT)
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
21 |
* MA 02110-1301, USA.
|
22 |
*
|
23 |
*/
|
24 |
|
25 |
|
26 |
import java.awt.Cursor; |
27 |
import java.awt.Point; |
28 |
import java.awt.Shape; |
29 |
import java.awt.event.MouseAdapter; |
30 |
import java.awt.event.MouseEvent; |
31 |
import java.awt.geom.Point2D; |
32 |
import java.util.Enumeration; |
33 |
import java.util.HashMap; |
34 |
import java.util.Set; |
35 |
import java.util.Vector; |
36 |
|
37 |
import javax.swing.JTree; |
38 |
import javax.swing.ToolTipManager; |
39 |
import javax.swing.event.TreeModelEvent; |
40 |
import javax.swing.event.TreeModelListener; |
41 |
import javax.swing.tree.DefaultMutableTreeNode; |
42 |
import javax.swing.tree.TreeNode; |
43 |
import javax.swing.tree.TreePath; |
44 |
|
45 |
import org.gvsig.quickInfo.FormatDecimalNumber; |
46 |
import org.gvsig.quickInfo.GeometryIDInfo; |
47 |
import org.gvsig.quickInfo.QuickInfoFLayerSelected; |
48 |
import org.gvsig.quickInfo.utils.geometries.GeometryInfo; |
49 |
import org.gvsig.quickInfo.utils.geometries.GeometryUtilities; |
50 |
|
51 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
52 |
import com.hardcode.gdbms.engine.data.DataSource; |
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.andami.messages.NotificationManager; |
55 |
import com.iver.cit.gvsig.fmap.MapContext; |
56 |
import com.iver.cit.gvsig.fmap.MapControl; |
57 |
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D; |
58 |
import com.iver.cit.gvsig.fmap.core.FMultipoint3D; |
59 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
60 |
import com.iver.cit.gvsig.fmap.core.FPoint3D; |
61 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
62 |
import com.iver.cit.gvsig.fmap.core.FPolygon3D; |
63 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
64 |
import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
66 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
67 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
68 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
69 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
70 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
71 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
72 |
import com.iver.cit.gvsig.fmap.spatialindex.ISpatialIndex; |
73 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
74 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
75 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
76 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
77 |
import com.iver.cit.gvsig.project.documents.view.toc.TocItemBranch; |
78 |
|
79 |
/**
|
80 |
* <p>Tool listener that updates <code>MapControl</code>'s tool tip with the information selected that
|
81 |
* the cursor of the mouse points on <code>MapControl</code>.</p>
|
82 |
*
|
83 |
* <p>This tool only apply changes when a single point is indicated.</p>
|
84 |
*
|
85 |
* @author Vicente Caballero Navarro (vicente.caballero@iver.es)
|
86 |
* @author Jaume Dom?nguez Faus (jaume.dominguez@iver.es)
|
87 |
* @author C?sar Mart?nez Izquierdo (cesar.martinez@iver.es)
|
88 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
89 |
*/
|
90 |
public class QuickInfoListener implements PointListener { |
91 |
private MapControl mapControl;
|
92 |
private QuickInfoFLayerSelected infoSelected;
|
93 |
public static final int DEFAULT_PIXEL_TOLERANCE = 2; |
94 |
private int pixel_tolerance; |
95 |
private TreeModelListener treeModelListener; |
96 |
private MouseAdapter treeMouseAdapter; |
97 |
private int oldInitialDelay; |
98 |
private int oldReshowDelay; |
99 |
// private int oldDismissDelay;
|
100 |
private View view; |
101 |
public static final short DEFAULT_EVENTS_TO_IGNORE = 0; |
102 |
public static final short DEFAULT_EVENTS_TO_IGNORE_IN_EDITION_MODE = 2; |
103 |
private short eventsToIgnore = DEFAULT_EVENTS_TO_IGNORE; |
104 |
private short eventsToIgnoreInEditionMode = DEFAULT_EVENTS_TO_IGNORE_IN_EDITION_MODE; |
105 |
private short counter = 0; |
106 |
// private Double[] xs_ar, ys_ar;
|
107 |
// private Integer[] pls_n_points;
|
108 |
|
109 |
/**
|
110 |
* <p>Creates a new <code>QuickInfoListener</code>. Tool that gets the previously selected alfanumeric information
|
111 |
* of a feature identified by a point, and displays it formatted in a <code>MapControl</code>'s <i>tool tip text</i>.</p>
|
112 |
*
|
113 |
* @param mc a <code>MapControl</code> instance
|
114 |
* @param infoSelected the information to display
|
115 |
* @param pixel_tolerance pixel tolerance (should be greater in points)
|
116 |
*/
|
117 |
public QuickInfoListener(MapControl mc, QuickInfoFLayerSelected infoSelected, int pixel_tolerance) { |
118 |
this.mapControl = mc;
|
119 |
this.infoSelected = infoSelected;
|
120 |
this.pixel_tolerance = pixel_tolerance;
|
121 |
final QuickInfoFLayerSelected qil = infoSelected;
|
122 |
|
123 |
oldInitialDelay = ToolTipManager.sharedInstance().getInitialDelay();
|
124 |
ToolTipManager.sharedInstance().setInitialDelay(300); // By default is 750 |
125 |
|
126 |
oldReshowDelay = ToolTipManager.sharedInstance().getReshowDelay();
|
127 |
ToolTipManager.sharedInstance().setReshowDelay(200); // By default is 500 |
128 |
|
129 |
// oldDismissDelay = ToolTipManager.sharedInstance().getDismissDelay();
|
130 |
// ToolTipManager.sharedInstance().setInitialDelay(100000); // By default is 60000
|
131 |
|
132 |
view = (View)PluginServices.getMDIManager().getActiveWindow();
|
133 |
view.getTOC().getTree().getModel().addTreeModelListener(getTreeModelListener(view)); |
134 |
|
135 |
// Adds new listener to remove this tool when the visibility of the layer has changed to not visible
|
136 |
view.getTOC().getTree().addMouseListener(getTreeMouseAdapter(view, qil)); |
137 |
} |
138 |
|
139 |
/*
|
140 |
* (non-Javadoc)
|
141 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
142 |
*/
|
143 |
public void point(PointEvent event) throws BehaviorException { |
144 |
if (infoSelected.getLayer().isEditing()) {
|
145 |
if (counter < eventsToIgnoreInEditionMode) {
|
146 |
counter ++; |
147 |
return;
|
148 |
} |
149 |
else {
|
150 |
counter = 0;
|
151 |
} |
152 |
} |
153 |
else {
|
154 |
if (counter < eventsToIgnore) {
|
155 |
counter ++; |
156 |
return;
|
157 |
} |
158 |
else {
|
159 |
counter = 0;
|
160 |
} |
161 |
} |
162 |
|
163 |
if ((infoSelected.getLayer().isVisible()) && (infoSelected.getLayer() instanceof InfoByPoint)) { |
164 |
try {
|
165 |
mapControl.setToolTipText(null);
|
166 |
|
167 |
double tolerance = mapControl.getViewPort().toMapDistance(pixel_tolerance);
|
168 |
|
169 |
Point imagePoint = new Point((int) event.getPoint().getX(), (int) event.getPoint().getY()); |
170 |
|
171 |
Point2D pReal = null; |
172 |
|
173 |
// Get the point in the map
|
174 |
pReal = mapControl.getViewPort().toMapPoint(imagePoint); |
175 |
|
176 |
// Disable the spatial index to do the query by point
|
177 |
FLyrVect layer = (FLyrVect)infoSelected.getLayer(); |
178 |
|
179 |
ISpatialIndex iSI = layer.getISpatialIndex(); |
180 |
layer.setISpatialIndex(null);
|
181 |
FBitSet bs = layer.queryByPoint(pReal, tolerance); |
182 |
|
183 |
// Enable the spatial index after do the query by point
|
184 |
layer.setISpatialIndex(iSI); |
185 |
|
186 |
DataSource ds = ((AlphanumericData) layer).getRecordset();
|
187 |
|
188 |
infoSelected.clearValues(); |
189 |
|
190 |
// Layer Fields Values:
|
191 |
Set lFields = infoSelected.getLayerFields().keySet();
|
192 |
// Set cFields = infoSelected.getCalculatedLayerFields().keySet();
|
193 |
|
194 |
String nameDistanceUnits = ""; |
195 |
|
196 |
switch(mapControl.getViewPort().getDistanceUnits()) {
|
197 |
case 0: |
198 |
nameDistanceUnits = "km";
|
199 |
break;
|
200 |
case 1: |
201 |
nameDistanceUnits = "m";
|
202 |
break;
|
203 |
case 2: |
204 |
nameDistanceUnits = "cm";
|
205 |
break;
|
206 |
case 3: |
207 |
nameDistanceUnits = "mm";
|
208 |
break;
|
209 |
case 4: // Millas estatutarias internacionales: |
210 |
nameDistanceUnits = "mi";
|
211 |
break;
|
212 |
case 5: |
213 |
nameDistanceUnits = "Ya";
|
214 |
break;
|
215 |
case 6: |
216 |
nameDistanceUnits = "ft";
|
217 |
break;
|
218 |
case 7: |
219 |
nameDistanceUnits = "in";
|
220 |
break;
|
221 |
case 8: |
222 |
nameDistanceUnits = "?";
|
223 |
break;
|
224 |
} |
225 |
|
226 |
String nameAreaUnits = ""; |
227 |
|
228 |
switch(mapControl.getViewPort().getDistanceArea()) {
|
229 |
case 0: |
230 |
nameAreaUnits = "km\u00B2";
|
231 |
break;
|
232 |
case 1: |
233 |
nameAreaUnits = "m\u00B2";
|
234 |
break;
|
235 |
case 2: |
236 |
nameAreaUnits = "a";
|
237 |
break;
|
238 |
case 3: |
239 |
nameAreaUnits = "ha";
|
240 |
break;
|
241 |
case 4: |
242 |
nameAreaUnits = "hgV";
|
243 |
break;
|
244 |
case 5: |
245 |
nameAreaUnits = "hgC";
|
246 |
break;
|
247 |
case 6: |
248 |
nameAreaUnits = "dm\u00B2";
|
249 |
break;
|
250 |
case 7: |
251 |
nameAreaUnits = "cm\u00B2";
|
252 |
break;
|
253 |
case 8: |
254 |
nameAreaUnits = "mm\u00B2";
|
255 |
break;
|
256 |
case 9: |
257 |
nameAreaUnits = "in\u00B2";
|
258 |
break;
|
259 |
case 10: |
260 |
nameAreaUnits = "ft\u00B2";
|
261 |
break;
|
262 |
case 11: // Acre |
263 |
nameAreaUnits = "ac\u00B2";
|
264 |
break;
|
265 |
case 12: // Millas estatutarias internacionales: |
266 |
nameAreaUnits = "mi\u00B2";
|
267 |
break;
|
268 |
case 13: |
269 |
nameAreaUnits = "Ya\u00B2";
|
270 |
break;
|
271 |
} |
272 |
|
273 |
double relationDistanceUnitsToMeters = MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()];
|
274 |
double relationAreaUnitsToMeters2 = ((Double)MapContext.AREATRANS2METER.get(mapControl.getViewPort().getDistanceArea())).doubleValue(); |
275 |
relationAreaUnitsToMeters2 = relationAreaUnitsToMeters2 * relationAreaUnitsToMeters2; |
276 |
double area, perimeter;
|
277 |
|
278 |
Vector cFieldsToRestore = null; |
279 |
GeometryIDInfo gIDInfo = null;
|
280 |
GeometryInfo gInfo = null;
|
281 |
|
282 |
for (int j = bs.nextSetBit(0); j >= 0; j = bs.nextSetBit(j + 1)) { |
283 |
if (infoSelected.getLayerFields().size() > 0) { |
284 |
for (int k = 0; k < ds.getFieldCount(); k++) { |
285 |
if (lFields.contains(ds.getFieldName(k))) {
|
286 |
((Vector)infoSelected.getLayerFields().get(ds.getFieldName(k))).add(ds.getFieldValue(j,k).toString());
|
287 |
infoSelected.setAnyLayerFieldAdded(true);
|
288 |
} |
289 |
} |
290 |
} |
291 |
|
292 |
String geom_id = String.valueOf(j); |
293 |
|
294 |
if (!infoSelected.getGeometryIDs().contains(geom_id))
|
295 |
infoSelected.getGeometryIDs().add(gIDInfo = new GeometryIDInfo(geom_id));
|
296 |
|
297 |
// if ((infoSelected.getCalculatedLayerFields().size() > 0) && (addedValues) && (!infoSelected.getGeometryIDs().contains(geom_id))) {
|
298 |
if (infoSelected.getCalculatedLayerFields().size() > 0) { |
299 |
// infoSelected.getGeometryIDs().add(geom_id);
|
300 |
|
301 |
// Calculated Layer Fields Values:
|
302 |
try {
|
303 |
ReadableVectorial rv = ((FLyrVect)layer).getSource(); |
304 |
|
305 |
rv.start(); |
306 |
IGeometry geometry = (IGeometry) rv.getShape(j); |
307 |
rv.stop(); |
308 |
|
309 |
Shape shape = null; |
310 |
|
311 |
if (geometry != null) { |
312 |
shape = geometry.getInternalShape(); |
313 |
} |
314 |
|
315 |
// If there is no internal shape in the geometry -> unknown info about its fields
|
316 |
if (shape == null) { |
317 |
gIDInfo.setHasInfo(false);
|
318 |
continue;
|
319 |
} |
320 |
|
321 |
String key;
|
322 |
Vector values;
|
323 |
|
324 |
switch(layer.getShapeType()) {
|
325 |
case FShape.NULL:
|
326 |
break;
|
327 |
case FShape.POINT:
|
328 |
// Coordinates
|
329 |
key = PluginServices.getText(this, "Coordinates"); |
330 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
331 |
if (values != null) { |
332 |
if (shape instanceof FPoint2D) { |
333 |
FPoint2D point2D = (FPoint2D) shape; |
334 |
values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point2D.getX()) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point2D.getY())); |
335 |
// values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point2D.getX(), "?10", true) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point2D.getY(), "?10", true));
|
336 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
337 |
continue;
|
338 |
} |
339 |
|
340 |
if (shape instanceof FPoint3D) { |
341 |
FPoint3D point3D = (FPoint3D) shape; |
342 |
values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point3D.getX()) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point3D.getY()) + ", " + PluginServices.getText(this, "Z") + "=" + FormatDecimalNumber.formatDecimal(point3D.getZs()[0])); |
343 |
// values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point3D.getX(), "?10", true) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point3D.getY(), "?10", true) + ", " + PluginServices.getText(this, "Z") + "=" + FormatDecimalNumber.formatDecimal(point3D.getZs()[0], "?10", true));
|
344 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
345 |
continue;
|
346 |
} |
347 |
} |
348 |
break;
|
349 |
case FShape.LINE:
|
350 |
// Disabled:
|
351 |
// // First point coordinate
|
352 |
// key = PluginServices.getText(this, "First_point_coordinates");
|
353 |
// values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
354 |
// if (values != null) {
|
355 |
// if (shape == null) {
|
356 |
// values.add("");
|
357 |
// }
|
358 |
// else {
|
359 |
// GeneralPathX g;
|
360 |
// g.
|
361 |
//
|
362 |
// if (shape instanceof FPolyline2D) {
|
363 |
// FPolyline2D polyline2D = (FPolyline2D) shape;
|
364 |
// values.add(PluginServices.getText(this, "X") + "= " + polyline2D.getX() + ", " + PluginServices.getText(this, "Y") + "=" + point3D.getY() + ", " + PluginServices.getText(this, "Z") + "=" + point3D.getZs());
|
365 |
// }
|
366 |
//
|
367 |
// if (shape instanceof FPolyline3D) {
|
368 |
// FPolyline3D polyline3D = (FPolyline3D) shape;
|
369 |
// values.add(PluginServices.getText(this, "X") + "= " + point3D.getX() + ", " + PluginServices.getText(this, "Y") + "=" + point3D.getY() + ", " + PluginServices.getText(this, "Z") + "=" + point3D.getZs());
|
370 |
// }
|
371 |
// }
|
372 |
// }
|
373 |
//
|
374 |
// // Second point coordinate
|
375 |
// if (cFields.contains(PluginServices.getText(this, "Second_point_coordinates"))) {
|
376 |
// if (shape == null) {
|
377 |
// values.add("");
|
378 |
// }
|
379 |
// else {
|
380 |
// if (shape instanceof F??2D) {
|
381 |
// FPoint2D point2D = (FPoint2D) shape;
|
382 |
// System.out.println("Second_point_coordinates: " + point2D.getX() + ", " + point2D.getY());
|
383 |
// }
|
384 |
//
|
385 |
// if (shape instanceof F??3D) {
|
386 |
// FPoint3D point3D = (FPoint3D) shape;
|
387 |
// System.out.println("Second_point_coordinates: " + point3D.getX() + ", " + point3D.getY());
|
388 |
// }
|
389 |
// }
|
390 |
// }
|
391 |
//
|
392 |
// Length
|
393 |
key = PluginServices.getText(this, "Length"); |
394 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
395 |
if (values != null) { |
396 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
397 |
|
398 |
try {
|
399 |
perimeter = GeometryUtilities.getLength(infoSelected.getLayer(), shape, gInfo); |
400 |
|
401 |
values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters) + " " + nameDistanceUnits);
|
402 |
// values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
403 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
404 |
} |
405 |
catch (Exception e) { |
406 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_perimeter_of_geometry"), e); |
407 |
mapControl.setToolTipText(null);
|
408 |
return;
|
409 |
} |
410 |
|
411 |
// values.add(FormatDecimalNumber.formatDecimal(FConverter.java2d_to_jts((FShape) shape).getLength() / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
412 |
// infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
413 |
//
|
414 |
// xs_ar = ys_ar = null;
|
415 |
// pls_n_points = null;
|
416 |
|
417 |
gInfo = null;
|
418 |
} |
419 |
break;
|
420 |
case FShape.POLYGON:
|
421 |
// Area
|
422 |
key = PluginServices.getText(this, "Area"); |
423 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
424 |
if (values != null) { |
425 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
426 |
|
427 |
try {
|
428 |
area = GeometryUtilities.getArea(infoSelected.getLayer(), shape, gInfo); |
429 |
|
430 |
values.add(FormatDecimalNumber.formatDecimal(area / relationAreaUnitsToMeters2) + " " + nameAreaUnits);
|
431 |
// values.add(FormatDecimalNumber.formatDecimal(area / relationAreaUnitsToMeters2, "?10", true) + " " + nameAreaUnits);
|
432 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
433 |
} |
434 |
catch (Exception e) { |
435 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_area_of_geometry"), e); |
436 |
mapControl.setToolTipText(null);
|
437 |
return;
|
438 |
} |
439 |
} |
440 |
|
441 |
// Perimeter
|
442 |
key = PluginServices.getText(this, "Perimeter"); |
443 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
444 |
if (values != null) { |
445 |
if (gInfo != null) |
446 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
447 |
|
448 |
try {
|
449 |
perimeter = GeometryUtilities.getLength(infoSelected.getLayer(), shape, gInfo); |
450 |
|
451 |
values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters) + " " + nameDistanceUnits);
|
452 |
// values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
453 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
454 |
} |
455 |
catch (Exception e) { |
456 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_perimeter_of_geometry"), e); |
457 |
mapControl.setToolTipText(null);
|
458 |
return;
|
459 |
} |
460 |
} |
461 |
|
462 |
gInfo = null;
|
463 |
break;
|
464 |
case FShape.TEXT:
|
465 |
break;
|
466 |
case FShape.MULTI: // Can have points, lines and polygons |
467 |
// POINTS:
|
468 |
if ((shape instanceof FPoint2D) || (shape instanceof FPoint3D)) { |
469 |
// Points -> Coordinates
|
470 |
key = PluginServices.getText(this, "Coordinates"); |
471 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
472 |
if (values != null) { |
473 |
if (shape instanceof FPoint2D) { |
474 |
FPoint2D point2D = (FPoint2D) shape; |
475 |
values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point2D.getX()) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point2D.getY())); |
476 |
// values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point2D.getX(), "?10", true) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point2D.getY(), "?10", true));
|
477 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
478 |
} |
479 |
else if (shape instanceof FPoint3D) { |
480 |
FPoint3D point3D = (FPoint3D) shape; |
481 |
values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point3D.getX()) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point3D.getY()) + ", " + PluginServices.getText(this, "Z") + "=" + FormatDecimalNumber.formatDecimal(point3D.getZs()[0])); |
482 |
// values.add(PluginServices.getText(this, "X") + "= " + FormatDecimalNumber.formatDecimal(point3D.getX(), "?10", true) + ", " + PluginServices.getText(this, "Y") + "=" + FormatDecimalNumber.formatDecimal(point3D.getY(), "?10", true) + ", " + PluginServices.getText(this, "Z") + "=" + FormatDecimalNumber.formatDecimal(point3D.getZs()[0], "?10", true));
|
483 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
484 |
} |
485 |
} |
486 |
|
487 |
// Removes other selected calculated fields that are for other kind of geometries
|
488 |
HashMap map = infoSelected.getCalculatedLayerFields();
|
489 |
cFieldsToRestore = new Vector(); |
490 |
|
491 |
String text = PluginServices.getText(this, "Area"); |
492 |
cFieldsToRestore.add(text); |
493 |
map.remove(text); |
494 |
|
495 |
text = PluginServices.getText(this, "Perimeter"); |
496 |
cFieldsToRestore.add(text); |
497 |
map.remove(text); |
498 |
|
499 |
text = PluginServices.getText(this, "Length"); |
500 |
cFieldsToRestore.add(text); |
501 |
map.remove(text); |
502 |
|
503 |
text = PluginServices.getText(this, "Number_of_points"); |
504 |
cFieldsToRestore.add(text); |
505 |
map.remove(text); |
506 |
|
507 |
continue;
|
508 |
} |
509 |
else {
|
510 |
// POLIGONS:
|
511 |
if ((shape instanceof FPolygon2D) || (shape instanceof FPolygon3D)) { |
512 |
// Polygon -> Area
|
513 |
key = PluginServices.getText(this, "Area"); |
514 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
515 |
if (values != null) { |
516 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
517 |
|
518 |
try {
|
519 |
area = GeometryUtilities.getArea(infoSelected.getLayer(), shape, gInfo); |
520 |
|
521 |
values.add(FormatDecimalNumber.formatDecimal(area / relationAreaUnitsToMeters2) + " " + nameAreaUnits);
|
522 |
// values.add(FormatDecimalNumber.formatDecimal(area / relationAreaUnitsToMeters2, "?10", true) + " " + nameAreaUnits);
|
523 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
524 |
} |
525 |
catch (Exception e) { |
526 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_area_of_geometry"), e); |
527 |
mapControl.setToolTipText(null);
|
528 |
return;
|
529 |
} |
530 |
// values.add(FormatDecimalNumber.formatDecimal(FConverter.java2d_to_jts((FShape) shape).getArea() / relationAreaUnitsToMeters2, "?10", true) + " " + nameAreaUnits);
|
531 |
// infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
532 |
} |
533 |
|
534 |
// Polygon -> Perimeter
|
535 |
key = PluginServices.getText(this, "Perimeter"); |
536 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
537 |
if (values != null) { |
538 |
if (gInfo != null) |
539 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
540 |
|
541 |
try {
|
542 |
perimeter = GeometryUtilities.getLength(infoSelected.getLayer(), shape, gInfo); |
543 |
|
544 |
values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters) + " " + nameDistanceUnits);
|
545 |
// values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
546 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
547 |
} |
548 |
catch (Exception e) { |
549 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_perimeter_of_geometry"), e); |
550 |
mapControl.setToolTipText(null);
|
551 |
return;
|
552 |
} |
553 |
// if (shape == null) {
|
554 |
// values.add("");
|
555 |
// }
|
556 |
// else {
|
557 |
// values.add(FormatDecimalNumber.formatDecimal(FConverter.java2d_to_jts((FShape) shape).getLength() / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
558 |
// infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
559 |
// }
|
560 |
} |
561 |
|
562 |
// Removes other selected calculated fields that are for other kind of geometries
|
563 |
HashMap map = infoSelected.getCalculatedLayerFields();
|
564 |
cFieldsToRestore = new Vector(); |
565 |
|
566 |
String text = PluginServices.getText(this, "Coordinates"); |
567 |
cFieldsToRestore.add(text); |
568 |
map.remove(text); |
569 |
|
570 |
text = PluginServices.getText(this, "Length"); |
571 |
cFieldsToRestore.add(text); |
572 |
map.remove(text); |
573 |
|
574 |
text = PluginServices.getText(this, "Number_of_points"); |
575 |
cFieldsToRestore.add(text); |
576 |
map.remove(text); |
577 |
|
578 |
gInfo = null;
|
579 |
continue;
|
580 |
} |
581 |
else {
|
582 |
// LINES:
|
583 |
if ((shape instanceof FPolyline2D) || (shape instanceof FPolyline3D)) { |
584 |
// Lines -> Length
|
585 |
key = PluginServices.getText(this, "Length"); |
586 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
587 |
if (values != null) { |
588 |
gInfo = GeometryUtilities.getGeometryPoints(mapControl, geometry); |
589 |
|
590 |
try {
|
591 |
perimeter = GeometryUtilities.getLength(infoSelected.getLayer(), shape, gInfo); |
592 |
|
593 |
values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters) + " " + nameDistanceUnits);
|
594 |
// values.add(FormatDecimalNumber.formatDecimal(perimeter / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
595 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
596 |
} |
597 |
catch (Exception e) { |
598 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_calculating_perimeter_of_geometry"), e); |
599 |
mapControl.setToolTipText(null);
|
600 |
return;
|
601 |
} |
602 |
|
603 |
|
604 |
// values.add(FormatDecimalNumber.formatDecimal(FConverter.java2d_to_jts((FShape) shape).getLength() / relationDistanceUnitsToMeters, "?10", true) + " " + nameDistanceUnits);
|
605 |
// infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
606 |
} |
607 |
|
608 |
// Removes other selected calculated fields that are for other kind of geometries
|
609 |
HashMap map = infoSelected.getCalculatedLayerFields();
|
610 |
cFieldsToRestore = new Vector(); |
611 |
|
612 |
String text = PluginServices.getText(this, "Coordinates"); |
613 |
cFieldsToRestore.add(text); |
614 |
map.remove(text); |
615 |
|
616 |
text = PluginServices.getText(this, "Area"); |
617 |
cFieldsToRestore.add(text); |
618 |
map.remove(text); |
619 |
|
620 |
text = PluginServices.getText(this, "Perimeter"); |
621 |
cFieldsToRestore.add(text); |
622 |
map.remove(text); |
623 |
|
624 |
text = PluginServices.getText(this, "Number_of_points"); |
625 |
cFieldsToRestore.add(text); |
626 |
map.remove(text); |
627 |
|
628 |
gInfo = null;
|
629 |
continue;
|
630 |
} |
631 |
else {
|
632 |
// MULTIPOINTS:
|
633 |
if ((shape instanceof FMultiPoint2D) || (shape instanceof FMultipoint3D)) { |
634 |
// MultiPoint -> Number of points
|
635 |
key = PluginServices.getText(this, "Number_of_points"); |
636 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
637 |
if (values != null) { |
638 |
if (shape instanceof FMultiPoint2D) { |
639 |
values.add(Integer.toString(((FMultiPoint2D)shape).getNumPoints()));
|
640 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
641 |
continue;
|
642 |
} |
643 |
|
644 |
if (shape instanceof FMultipoint3D) { |
645 |
values.add(Integer.toString(((FMultipoint3D)shape).getNumPoints()));
|
646 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
647 |
continue;
|
648 |
} |
649 |
} |
650 |
|
651 |
// Removes other selected calculated fields that are for other kind of geometries
|
652 |
HashMap map = infoSelected.getCalculatedLayerFields();
|
653 |
cFieldsToRestore = new Vector(); |
654 |
|
655 |
String text = PluginServices.getText(this, "Coordinates"); |
656 |
cFieldsToRestore.add(text); |
657 |
map.remove(text); |
658 |
|
659 |
text = PluginServices.getText(this, "Area"); |
660 |
cFieldsToRestore.add(text); |
661 |
map.remove(text); |
662 |
|
663 |
text = PluginServices.getText(this, "Perimeter"); |
664 |
cFieldsToRestore.add(text); |
665 |
map.remove(text); |
666 |
|
667 |
text = PluginServices.getText(this, "Length"); |
668 |
cFieldsToRestore.add(text); |
669 |
map.remove(text); |
670 |
} |
671 |
// OTHERS
|
672 |
} |
673 |
} |
674 |
} |
675 |
break;
|
676 |
case FShape.MULTIPOINT:
|
677 |
// Number of points
|
678 |
key = PluginServices.getText(this, "Number_of_points"); |
679 |
values = ((Vector)infoSelected.getCalculatedLayerFields().get(key));
|
680 |
if (values != null) { |
681 |
if (shape instanceof FMultiPoint2D) { |
682 |
values.add(Integer.toString(((FMultiPoint2D)shape).getNumPoints()));
|
683 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
684 |
continue;
|
685 |
} |
686 |
|
687 |
if (shape instanceof FMultipoint3D) { |
688 |
values.add(Integer.toString(((FMultipoint3D)shape).getNumPoints()));
|
689 |
infoSelected.setAnyCalculatedLayerFieldsAdded(true);
|
690 |
continue;
|
691 |
} |
692 |
} |
693 |
|
694 |
break;
|
695 |
case FShape.CIRCLE:
|
696 |
// Disabled:
|
697 |
// // Coordinates of the centre
|
698 |
// if (cFields.contains(PluginServices.getText(this, "Coordinates_of_the_centre"))) {
|
699 |
// if (shape == null) {
|
700 |
// // AGREGAR ENTRADA con valor ""
|
701 |
//
|
702 |
// }
|
703 |
// else {
|
704 |
// if (shape instanceof F??2D) {
|
705 |
// FPoint2D point2D = (FPoint2D) shape;
|
706 |
// System.out.println("Coordinates_of_the_centre: " + point2D.getX() + ", " + point2D.getY());
|
707 |
// }
|
708 |
//
|
709 |
// if (shape instanceof F??3D) {
|
710 |
// FPoint3D point3D = (FPoint3D) shape;
|
711 |
// System.out.println("Coordinates_of_the_centre: " + point3D.getX() + ", " + point3D.getY());
|
712 |
// }
|
713 |
// }
|
714 |
// }
|
715 |
//
|
716 |
// // Radius
|
717 |
// if (cFields.contains(PluginServices.getText(this, "Radius"))) {
|
718 |
// if (shape == null) {
|
719 |
// // AGREGAR ENTRADA con valor ""
|
720 |
//
|
721 |
// }
|
722 |
// else {
|
723 |
// if (shape instanceof F??2D) {
|
724 |
// FPoint2D point2D = (FPoint2D) shape;
|
725 |
// System.out.println("Radius: " + point2D.getX() + ", " + point2D.getY());
|
726 |
// }
|
727 |
//
|
728 |
// if (shape instanceof F??3D) {
|
729 |
// FPoint3D point3D = (FPoint3D) shape;
|
730 |
// System.out.println("Radius: " + point3D.getX() + ", " + point3D.getY());
|
731 |
// }
|
732 |
// }
|
733 |
// }
|
734 |
//
|
735 |
// // Circumference
|
736 |
// if (cFields.contains(PluginServices.getText(this, "Circumference"))) {
|
737 |
// if (shape == null) {
|
738 |
// // AGREGAR ENTRADA con valor ""
|
739 |
//
|
740 |
// }
|
741 |
// else {
|
742 |
// if (shape instanceof F??2D) {
|
743 |
// FPoint2D point2D = (FPoint2D) shape;
|
744 |
// System.out.println("Circumference: " + point2D.getX() + ", " + point2D.getY());
|
745 |
// }
|
746 |
//
|
747 |
// if (shape instanceof F??3D) {
|
748 |
// FPoint3D point3D = (FPoint3D) shape;
|
749 |
// System.out.println("Circumference: " + point3D.getX() + ", " + point3D.getY());
|
750 |
// }
|
751 |
// }
|
752 |
// }
|
753 |
break;
|
754 |
case FShape.ARC:
|
755 |
break;
|
756 |
case FShape.ELLIPSE:
|
757 |
break;
|
758 |
case FShape.Z:
|
759 |
break;
|
760 |
default : // UNDEFINED |
761 |
} |
762 |
} |
763 |
catch (ReadDriverException dioe) {
|
764 |
NotificationManager.showMessageError(PluginServices.getText(null, "Failed_getting_geometries"), dioe); |
765 |
} |
766 |
} |
767 |
} |
768 |
|
769 |
// Sets the new tool tip text to the current active view's MapControl
|
770 |
mapControl.setToolTipText(infoSelected.getToolTipText()); |
771 |
|
772 |
if (cFieldsToRestore != null) { |
773 |
HashMap map = infoSelected.getCalculatedLayerFields();
|
774 |
|
775 |
for (int i = 0; i < cFieldsToRestore.size(); i++) { |
776 |
map.put(cFieldsToRestore.elementAt(i), new Vector()); |
777 |
} |
778 |
|
779 |
cFieldsToRestore = null;
|
780 |
} |
781 |
} catch (Exception e) { |
782 |
throw new BehaviorException("Fallo al consultar " + infoSelected.getLayer().getName()); |
783 |
} |
784 |
} |
785 |
} |
786 |
|
787 |
/*
|
788 |
* (non-Javadoc)
|
789 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
790 |
*/
|
791 |
public void pointDoubleClick(PointEvent event) throws BehaviorException { |
792 |
// Nothing
|
793 |
} |
794 |
|
795 |
/*
|
796 |
* (non-Javadoc)
|
797 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
798 |
*/
|
799 |
public boolean cancelDrawing() { |
800 |
return false; |
801 |
} |
802 |
|
803 |
/*
|
804 |
* (non-Javadoc)
|
805 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
806 |
*/
|
807 |
public Cursor getCursor() { |
808 |
// Uses the cursor of the previous selected tool. Or any that can be selected in the future.
|
809 |
return null; |
810 |
} |
811 |
|
812 |
/**
|
813 |
* <p>Creates a new <code>TreeModelListener</code> to remove this tool when the layer node is removed from
|
814 |
* the TOC of <code>view</code>.</p>
|
815 |
*
|
816 |
* @param vista the view
|
817 |
* @return javax.swing.event.TreeModelListener
|
818 |
*/
|
819 |
private TreeModelListener getTreeModelListener(final View view) { |
820 |
if (treeModelListener == null) { |
821 |
treeModelListener = new TreeModelListener() { |
822 |
/*
|
823 |
* (non-Javadoc)
|
824 |
* @see javax.swing.event.TreeModelListener#treeNodesChanged(javax.swing.event.TreeModelEvent)
|
825 |
*/
|
826 |
public void treeNodesChanged(TreeModelEvent e) { |
827 |
} |
828 |
|
829 |
/*
|
830 |
* (non-Javadoc)
|
831 |
* @see javax.swing.event.TreeModelListener#treeNodesInserted(javax.swing.event.TreeModelEvent)
|
832 |
*/
|
833 |
public void treeNodesInserted(TreeModelEvent e) { |
834 |
} |
835 |
|
836 |
/*
|
837 |
* (non-Javadoc)
|
838 |
* @see javax.swing.event.TreeModelListener#treeNodesRemoved(javax.swing.event.TreeModelEvent)
|
839 |
*/
|
840 |
public void treeNodesRemoved(TreeModelEvent e) { |
841 |
} |
842 |
|
843 |
/*
|
844 |
* (non-Javadoc)
|
845 |
* @see javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent)
|
846 |
*/
|
847 |
public void treeStructureChanged(TreeModelEvent e) { |
848 |
if (!findLayer(view.getTOC().getTree())) {
|
849 |
view.getTOC().getTree().removeMouseListener(treeMouseAdapter); |
850 |
view.getTOC().getTree().getModel().removeTreeModelListener(treeModelListener); |
851 |
mapControl.removeCombinedTool(); |
852 |
mapControl.setToolTipText(null);
|
853 |
ToolTipManager.sharedInstance().setInitialDelay(oldInitialDelay);
|
854 |
ToolTipManager.sharedInstance().setReshowDelay(oldReshowDelay);
|
855 |
// ToolTipManager.sharedInstance().setDismissDelay(oldDismissDelay);
|
856 |
} |
857 |
} |
858 |
}; |
859 |
} |
860 |
|
861 |
return treeModelListener;
|
862 |
} |
863 |
|
864 |
/**
|
865 |
* <p>Creates a new <code>MouseAdapter</code> to remove this tool when the layer changes its visibility
|
866 |
* to <i>invisible</i> in the TOC of the <code>view</code>.</p>
|
867 |
*
|
868 |
* @param view the view
|
869 |
* @param qil data stored to display by this tool
|
870 |
* @return java.awt.event.MouseAdapter
|
871 |
*/
|
872 |
private MouseAdapter getTreeMouseAdapter(final View view, final QuickInfoFLayerSelected qil) { |
873 |
if (treeMouseAdapter == null) { |
874 |
treeMouseAdapter = new MouseAdapter() { |
875 |
/*
|
876 |
* (non-Javadoc)
|
877 |
* @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
|
878 |
*/
|
879 |
public void mousePressed(MouseEvent e) { |
880 |
TreePath tp = ((JTree)e.getSource()).getPathForLocation(e.getX(), e.getY()); |
881 |
|
882 |
if (tp != null) { |
883 |
DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent(); |
884 |
|
885 |
if (dmtn != null) { |
886 |
TocItemBranch tib = (TocItemBranch)dmtn.getUserObject(); |
887 |
|
888 |
if (tib != null) { |
889 |
|
890 |
if ((tib.getLayer() != null) && (tib.getLayer().equals(qil.getLayer())) && (! tib.getLayer().isVisible())) { |
891 |
view.getTOC().getTree().removeMouseListener(treeMouseAdapter); |
892 |
view.getTOC().getTree().getModel().removeTreeModelListener(treeModelListener); |
893 |
mapControl.removeCombinedTool(); |
894 |
mapControl.setToolTipText(null);
|
895 |
ToolTipManager.sharedInstance().setInitialDelay(oldInitialDelay);
|
896 |
ToolTipManager.sharedInstance().setReshowDelay(oldReshowDelay);
|
897 |
// ToolTipManager.sharedInstance().setDismissDelay(oldDismissDelay);
|
898 |
} |
899 |
} |
900 |
} |
901 |
} |
902 |
} |
903 |
}; |
904 |
} |
905 |
|
906 |
return treeMouseAdapter;
|
907 |
} |
908 |
|
909 |
/**
|
910 |
* <p>Gets the pixel tolerance used by this tool.</p>
|
911 |
*
|
912 |
* @return the pixel tolerance used by this tool
|
913 |
*/
|
914 |
public int getPixelTolerance() { |
915 |
return pixel_tolerance;
|
916 |
} |
917 |
|
918 |
/**
|
919 |
* <p>Sets the pixel tolerance to be used by this tool.</p>
|
920 |
*
|
921 |
* @return the pixel tolerance to be used by this tool
|
922 |
*/
|
923 |
public void setPixelTolerance(int pixel_tolerance) { |
924 |
this.pixel_tolerance = pixel_tolerance;
|
925 |
} |
926 |
|
927 |
/**
|
928 |
* <p>Finds recursively if the layer is found and is visible in the tree.</p>
|
929 |
*
|
930 |
* @param tree the <code>JTree</code> where find
|
931 |
* @return <code>true</code> if the layer is found and is visible in the tree; otherwise <code>false</code>
|
932 |
*/
|
933 |
public boolean findLayer(JTree tree) { |
934 |
TreeNode root = (TreeNode)tree.getModel().getRoot(); |
935 |
return findLayerInAllNodes(root);
|
936 |
} |
937 |
|
938 |
/**
|
939 |
* <p>Finds recursively if the layer is found and is visible in the tree <code>node</code>.</p>
|
940 |
*
|
941 |
* @param tree the node where find
|
942 |
* @return <code>true</code> if the layer is found and is visible in the tree node; otherwise <code>false</code>
|
943 |
*/
|
944 |
public boolean findLayerInAllNodes(TreeNode node) { |
945 |
boolean b1 = false, b2 = false; |
946 |
|
947 |
if (node != null) { |
948 |
Object userObject = ((DefaultMutableTreeNode)node).getUserObject(); |
949 |
|
950 |
if (userObject instanceof TocItemBranch) { |
951 |
TocItemBranch tib = (TocItemBranch)userObject; |
952 |
|
953 |
if (tib != null) { |
954 |
if ((tib.getLayer() != null) && (tib.getLayer().equals(infoSelected.getLayer())) && (tib.getLayer().isVisible())) { |
955 |
b1 = true;
|
956 |
} |
957 |
} |
958 |
} |
959 |
|
960 |
if (node.getChildCount() >= 0) { |
961 |
for (Enumeration e = node.children(); e.hasMoreElements(); ) { |
962 |
TreeNode n = (TreeNode)e.nextElement(); |
963 |
b2 = b2 | findLayerInAllNodes(n); |
964 |
} |
965 |
} |
966 |
} |
967 |
|
968 |
return b1 | b2;
|
969 |
} |
970 |
|
971 |
/**
|
972 |
* <p>Gets the number of events that will ignore.</p>
|
973 |
*
|
974 |
* <p>This is very useful to accelerate the this tool when the layer is being edited.</p>
|
975 |
*
|
976 |
* @return the number of events that will ignore
|
977 |
*/
|
978 |
public short getNumberOfEventsToIgnore() { |
979 |
return eventsToIgnore;
|
980 |
} |
981 |
|
982 |
/**
|
983 |
* <p>Sets the number of events that will ignore.</p>
|
984 |
*
|
985 |
* <p>This is very useful to accelerate the this tool when the layer is being edited.</p>
|
986 |
*
|
987 |
* @param n the number of events that will ignore
|
988 |
*/
|
989 |
public void setNumberOfEventsToIgnore(short n) { |
990 |
eventsToIgnore = n; |
991 |
} |
992 |
|
993 |
/**
|
994 |
* <p>Gets the number of events that will ignore if the layer is being edited.</p>
|
995 |
*
|
996 |
* <p>This is very useful to accelerate the this tool when the layer is being edited.</p>
|
997 |
*
|
998 |
* @return the number of events that will ignore if the layer is being edited
|
999 |
*/
|
1000 |
public short getNumberOfEventsToIgnoreInEditionMode() { |
1001 |
return eventsToIgnoreInEditionMode;
|
1002 |
} |
1003 |
|
1004 |
/**
|
1005 |
* <p>Sets the number of events that will ignore if the layer is being edited.</p>
|
1006 |
*
|
1007 |
* <p>This is very useful to accelerate the this tool when the layer is being edited.</p>
|
1008 |
*
|
1009 |
* @param n the number of events that will ignore if the layer is being edited
|
1010 |
*/
|
1011 |
public void setNumberOfEventsToIgnoreInEditionMode(short n) { |
1012 |
eventsToIgnoreInEditionMode = n; |
1013 |
} |
1014 |
} |