svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / gui / cad / DefaultCADTool.java @ 24500
History | View | Annotate | Download (18.3 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui.cad; |
42 |
|
43 |
import java.awt.Color; |
44 |
import java.awt.Graphics; |
45 |
import java.awt.Graphics2D; |
46 |
import java.awt.event.MouseEvent; |
47 |
import java.awt.geom.AffineTransform; |
48 |
import java.awt.geom.Point2D; |
49 |
import java.awt.image.BufferedImage; |
50 |
import java.util.ArrayList; |
51 |
import java.util.Iterator; |
52 |
|
53 |
import org.apache.log4j.Logger; |
54 |
import org.gvsig.fmap.dal.exception.DataException; |
55 |
import org.gvsig.fmap.dal.exception.ReadException; |
56 |
import org.gvsig.fmap.dal.feature.CommandsRecord; |
57 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
58 |
import org.gvsig.fmap.dal.feature.Feature; |
59 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
60 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
61 |
import org.gvsig.fmap.geom.Geometry; |
62 |
import org.gvsig.fmap.geom.GeometryFactory; |
63 |
import org.gvsig.fmap.geom.GeometryManager; |
64 |
import org.gvsig.fmap.geom.handler.Handler; |
65 |
import org.gvsig.fmap.geom.operation.Draw; |
66 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
67 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
68 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
69 |
import org.gvsig.fmap.geom.primitive.DefaultEnvelope; |
70 |
import org.gvsig.fmap.geom.primitive.Envelope; |
71 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
72 |
import org.gvsig.fmap.mapcontext.ViewPort; |
73 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
74 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
75 |
import org.gvsig.fmap.mapcontext.rendering.symbols.FGraphicUtilities; |
76 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
77 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
78 |
|
79 |
import com.iver.andami.PluginServices; |
80 |
import com.iver.andami.messages.NotificationManager; |
81 |
import com.iver.cit.gvsig.CADExtension; |
82 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
83 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
84 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
85 |
import com.iver.utiles.console.JConsole; |
86 |
|
87 |
/**
|
88 |
* DOCUMENT ME!
|
89 |
*
|
90 |
* @author Vicente Caballero Navarro
|
91 |
*/
|
92 |
public abstract class DefaultCADTool implements CADTool { |
93 |
public static ISymbol selectionSymbol = SymbologyFactory |
94 |
.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, new Color( |
95 |
255, 0, 0, 100)); // Le ponemos una transparencia |
96 |
public static ISymbol axisReferencesSymbol = SymbologyFactory |
97 |
.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, new Color( |
98 |
100, 100, 100, 100)); |
99 |
public static ISymbol geometrySelectSymbol = SymbologyFactory |
100 |
.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.RED);
|
101 |
public static ISymbol handlerSymbol = SymbologyFactory |
102 |
.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, |
103 |
Color.ORANGE);
|
104 |
private static Logger logger = Logger.getLogger(DefaultCADTool.class |
105 |
.getName()); |
106 |
private CADToolAdapter cadToolAdapter;
|
107 |
|
108 |
private String question; |
109 |
|
110 |
private String[] currentdescriptions; |
111 |
|
112 |
private String tool = "selection"; |
113 |
|
114 |
private DefaultCADTool previousTool;
|
115 |
|
116 |
private ArrayList temporalCache = new ArrayList(); |
117 |
protected GeometryFactory geomFactory = GeometryManager.getInstance()
|
118 |
.getGeometryFactory(); |
119 |
|
120 |
public void addTemporalCache(Geometry geom) { |
121 |
temporalCache.add(geom); |
122 |
insertSpatialCache(geom); |
123 |
} |
124 |
|
125 |
public void clearTemporalCache() { |
126 |
Geometry[] geoms = (Geometry[]) temporalCache.toArray(new Geometry[0]); |
127 |
for (int i = 0; i < geoms.length; i++) { |
128 |
removeSpatialCache(geoms[i]); |
129 |
} |
130 |
temporalCache.clear(); |
131 |
} |
132 |
|
133 |
private void insertSpatialCache(Geometry geom) { |
134 |
VectorialLayerEdited vle = getVLE(); |
135 |
SpatialCache spatialCache = ((FLyrVect) vle.getLayer()) |
136 |
.getSpatialCache(); |
137 |
Envelope r = geom.getEnvelope(); |
138 |
if (geom.getType() == Geometry.TYPES.POINT) {
|
139 |
r = new DefaultEnvelope(r.getMinimum(0), r.getMinimum(1), r |
140 |
.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1); |
141 |
} |
142 |
spatialCache.insert(r, geom); |
143 |
|
144 |
} |
145 |
|
146 |
private void removeSpatialCache(Geometry geom) { |
147 |
VectorialLayerEdited vle = getVLE(); |
148 |
SpatialCache spatialCache = ((FLyrVect) vle.getLayer()) |
149 |
.getSpatialCache(); |
150 |
Envelope r = geom.getEnvelope(); |
151 |
if (geom.getType() == Geometry.TYPES.POINT) {
|
152 |
r = new DefaultEnvelope(r.getMinimum(0), r.getMinimum(1), r |
153 |
.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1); |
154 |
} |
155 |
spatialCache.remove(r, geom); |
156 |
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* DOCUMENT ME!
|
161 |
*/
|
162 |
public void draw(Geometry geometry) { |
163 |
if (geometry != null) { |
164 |
BufferedImage img = getCadToolAdapter().getMapControl().getImage();
|
165 |
Graphics2D gImag = (Graphics2D) img.getGraphics(); |
166 |
ViewPort vp = getCadToolAdapter().getMapControl().getViewPort(); |
167 |
DrawOperationContext doc = new DrawOperationContext();
|
168 |
doc.setGraphics((Graphics2D) gImag);
|
169 |
doc.setViewPort(vp); |
170 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
171 |
try {
|
172 |
geometry.cloneGeometry().invokeOperation(Draw.CODE, doc); |
173 |
} catch (GeometryOperationNotSupportedException e) {
|
174 |
e.printStackTrace(); |
175 |
} catch (GeometryOperationException e) {
|
176 |
e.printStackTrace(); |
177 |
} |
178 |
// geometry.draw(gImag, vp, DefaultCADTool.selectionSymbol);
|
179 |
} |
180 |
} |
181 |
|
182 |
/**
|
183 |
* DOCUMENT ME!
|
184 |
*
|
185 |
* @param cta
|
186 |
* DOCUMENT ME!
|
187 |
*/
|
188 |
public void setCadToolAdapter(CADToolAdapter cta) { |
189 |
cadToolAdapter = cta; |
190 |
} |
191 |
|
192 |
/**
|
193 |
* DOCUMENT ME!
|
194 |
*
|
195 |
* @return DOCUMENT ME!
|
196 |
*/
|
197 |
public CADToolAdapter getCadToolAdapter() {
|
198 |
return cadToolAdapter;
|
199 |
} |
200 |
|
201 |
public VectorialLayerEdited getVLE() {
|
202 |
return (VectorialLayerEdited) CADExtension.getEditionManager()
|
203 |
.getActiveLayerEdited(); |
204 |
} |
205 |
|
206 |
/**
|
207 |
* DOCUMENT ME!
|
208 |
*
|
209 |
* @param g
|
210 |
* DOCUMENT ME!
|
211 |
* @param firstPoint
|
212 |
* DOCUMENT ME!
|
213 |
* @param endPoint
|
214 |
* DOCUMENT ME!
|
215 |
*/
|
216 |
public void drawLine(Graphics2D g, Point2D firstPoint, Point2D endPoint, |
217 |
ISymbol symbol) { |
218 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
219 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
220 |
elShape.lineTo(endPoint.getX(), endPoint.getY()); |
221 |
GeometryFactory geomFactory = GeometryManager.getInstance() |
222 |
.getGeometryFactory(); |
223 |
DrawOperationContext doc = new DrawOperationContext();
|
224 |
doc.setGraphics(g); |
225 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
226 |
doc.setSymbol(symbol); |
227 |
try {
|
228 |
geomFactory.createPolyline2D(elShape).invokeOperation(Draw.CODE, |
229 |
doc); |
230 |
} catch (GeometryOperationNotSupportedException e) {
|
231 |
e.printStackTrace(); |
232 |
} catch (GeometryOperationException e) {
|
233 |
e.printStackTrace(); |
234 |
} |
235 |
// draw(g,
|
236 |
// getCadToolAdapter().getMapControl().getViewPort(),
|
237 |
// symbol);
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* DOCUMENT ME!
|
242 |
*
|
243 |
* @param geometry
|
244 |
* DOCUMENT ME!
|
245 |
*/
|
246 |
public Feature insertGeometry(Geometry geometry, Feature feature) {
|
247 |
VectorialLayerEdited vle = getVLE(); |
248 |
|
249 |
try {
|
250 |
FeatureStore featureStore = ((FLyrVect) vle.getLayer()) |
251 |
.getFeatureStore(); |
252 |
EditableFeature eFeature = featureStore.createNewFeature( |
253 |
featureStore.getDefaultFeatureType(), feature); |
254 |
eFeature.setGeometry(featureStore.getDefaultFeatureType() |
255 |
.getDefaultGeometryAttributeName(), geometry); |
256 |
featureStore.insert(eFeature); |
257 |
drawToImage(featureStore, vle, geometry); |
258 |
draw(geometry.cloneGeometry()); |
259 |
return eFeature;
|
260 |
} catch (ReadException e) {
|
261 |
NotificationManager.addError(e.getMessage(), e); |
262 |
return null; |
263 |
} catch (GeometryOperationNotSupportedException e) {
|
264 |
NotificationManager.addError(e.getMessage(), e); |
265 |
return null; |
266 |
} catch (GeometryOperationException e) {
|
267 |
NotificationManager.addError(e.getMessage(), e); |
268 |
return null; |
269 |
} catch (DataException e) {
|
270 |
NotificationManager.addError(e.getMessage(), e); |
271 |
return null; |
272 |
} |
273 |
} |
274 |
public Feature insertGeometry(Geometry geometry) {
|
275 |
VectorialLayerEdited vle = getVLE(); |
276 |
|
277 |
try {
|
278 |
FeatureStore featureStore = ((FLyrVect) vle.getLayer()) |
279 |
.getFeatureStore(); |
280 |
EditableFeature eFeature = featureStore.createNewFeature(true);
|
281 |
eFeature.setGeometry(featureStore.getDefaultFeatureType() |
282 |
.getDefaultGeometryAttributeName(), geometry); |
283 |
featureStore.insert(eFeature); |
284 |
|
285 |
drawToImage(featureStore, vle, geometry); |
286 |
draw(geometry.cloneGeometry()); |
287 |
return eFeature;
|
288 |
} catch (ReadException e) {
|
289 |
NotificationManager.addError(e.getMessage(), e); |
290 |
return null; |
291 |
} catch (GeometryOperationNotSupportedException e) {
|
292 |
NotificationManager.addError(e.getMessage(), e); |
293 |
return null; |
294 |
} catch (GeometryOperationException e) {
|
295 |
NotificationManager.addError(e.getMessage(), e); |
296 |
return null; |
297 |
} catch (DataException e) {
|
298 |
NotificationManager.addError(e.getMessage(), e); |
299 |
return null; |
300 |
} |
301 |
|
302 |
} |
303 |
private void drawToImage(FeatureStore featureStore,VectorialLayerEdited vle, Geometry geometry) throws DataException, GeometryOperationNotSupportedException, GeometryOperationException { |
304 |
clearSelection(); |
305 |
ViewPort vp = vle.getLayer().getMapContext().getViewPort(); |
306 |
BufferedImage selectionImage = new BufferedImage( |
307 |
vp.getImageWidth(), vp.getImageHeight(), |
308 |
BufferedImage.TYPE_INT_ARGB);
|
309 |
Graphics2D gs = selectionImage.createGraphics();
|
310 |
// int inversedIndex=vea.getInversedIndex(index);
|
311 |
FeatureSet selection = (FeatureSet) featureStore.getSelection(); |
312 |
// selection.add(feature);
|
313 |
// vle.addSelectionCache(new DefaultRowEdited(df,
|
314 |
// IRowEdited.STATUS_ADDED, inversedIndex ));
|
315 |
// vea.getSelection().set(inversedIndex);
|
316 |
// Geometry geom = (Geometry)feature.getDefaultGeometry();
|
317 |
DrawOperationContext doc = new DrawOperationContext();
|
318 |
doc.setGraphics(gs); |
319 |
doc.setViewPort(vp); |
320 |
doc.setSymbol(DefaultCADTool.selectionSymbol); |
321 |
geometry.cloneGeometry().invokeOperation(Draw.CODE, doc); |
322 |
// draw(gs, vp, DefaultCADTool.selectionSymbol);
|
323 |
vle.drawHandlers(geometry.cloneGeometry(), gs, vp); |
324 |
vle.setSelectionImage(selectionImage); |
325 |
insertSpatialCache(geometry); |
326 |
|
327 |
} |
328 |
|
329 |
/**
|
330 |
* DOCUMENT ME!
|
331 |
*
|
332 |
* @param geometry
|
333 |
* DOCUMENT ME!
|
334 |
*/
|
335 |
// public void modifyFeature(Feature feature, Feature oldFeature) {
|
336 |
// try {
|
337 |
// CommandsRecord
|
338 |
// cr=((FLyrVect)getVLE().getLayer()).getFeatureStore().getCommandsRecord();
|
339 |
// cr.update(feature, oldFeature);
|
340 |
// } catch (ReadException e) {
|
341 |
// NotificationManager.addError(e.getMessage(),e);
|
342 |
// }
|
343 |
// draw(((Geometry)feature.getDefaultGeometry()).cloneGeometry());
|
344 |
// }
|
345 |
/**
|
346 |
* DOCUMENT ME!
|
347 |
*
|
348 |
* @param geometry
|
349 |
* DOCUMENT ME!
|
350 |
* @param values
|
351 |
* DOCUMENT ME!
|
352 |
*/
|
353 |
// public Feature addGeometry(Geometry geometry, Object[] values) {
|
354 |
// // int index = 0;
|
355 |
// try {
|
356 |
// FeatureStore featureStore = ((FLyrVect) getVLE().getLayer())
|
357 |
// .getFeatureStore();
|
358 |
// EditableFeature eFeature = featureStore.createNewFeature(true);
|
359 |
// eFeature.setGeometry(featureStore.getDefaultFeatureType()
|
360 |
// .getDefaultGeometryAttributeName(), geometry);
|
361 |
// for (int i = 0; i < values.length; i++) {
|
362 |
// eFeature.set(i, values[i]);
|
363 |
// }
|
364 |
// featureStore.insert(eFeature);
|
365 |
// return eFeature;
|
366 |
// } catch (DataException e) {
|
367 |
// // TODO Auto-generated catch block
|
368 |
// e.printStackTrace();
|
369 |
// }
|
370 |
// // try {
|
371 |
// // String newFID = vea.getNewFID();
|
372 |
// // DefaultFeature df = new DefaultFeature(geometry, values, newFID);
|
373 |
// // index = vea.addRow(df, getName(), EditionEvent.GRAPHIC);
|
374 |
// // insertSpatialCache(geometry);
|
375 |
// // } catch (ValidateRowException e) {
|
376 |
// // NotificationManager.addError(e);
|
377 |
// // } catch (ReadException e) {
|
378 |
// // NotificationManager.addError(e);
|
379 |
// // }
|
380 |
// // return vea.getInversedIndex(index);
|
381 |
// return null;
|
382 |
// }
|
383 |
|
384 |
/**
|
385 |
* Devuelve la cadena que corresponde al estado en el que nos encontramos.
|
386 |
*
|
387 |
* @return Cadena para mostrar por consola.
|
388 |
*/
|
389 |
public String getQuestion() { |
390 |
return question;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* Actualiza la cadena que corresponde al estado actual.
|
395 |
*
|
396 |
* @param s
|
397 |
* Cadena que aparecer? en consola.
|
398 |
*/
|
399 |
public void setQuestion(String s) { |
400 |
question = s; |
401 |
// ConsoleToken.addQuestion(s);
|
402 |
} |
403 |
|
404 |
/**
|
405 |
* Provoca un repintado "soft" de la capa activa en edici?n. Las capas por
|
406 |
* debajo de ella no se dibujan de verdad, solo se dibuja la que est? en
|
407 |
* edici?n y las que est?n por encima de ella en el TOC.
|
408 |
*/
|
409 |
public void refresh() { |
410 |
// getCadToolAdapter().getMapControl().drawMap(false);
|
411 |
getVLE().getLayer().setDirty(true);
|
412 |
|
413 |
getCadToolAdapter().getMapControl().rePaintDirtyLayers(); |
414 |
} |
415 |
|
416 |
/*
|
417 |
* public void drawHandlers(Graphics g, FBitSet sel, AffineTransform at)
|
418 |
* throws DriverIOException { for (int i = sel.nextSetBit(0); i >= 0; i =
|
419 |
* sel.nextSetBit(i + 1)) { IGeometry ig =
|
420 |
* getCadToolAdapter().getVectorialAdapter() .getShape(i).cloneGeometry();
|
421 |
* if (ig == null) continue; Handler[] handlers =
|
422 |
* ig.getHandlers(IGeometry.SELECTHANDLER);
|
423 |
* FGraphicUtilities.DrawHandlers((Graphics2D) g, at, handlers); } }
|
424 |
*/
|
425 |
public void drawHandlers(Graphics g, ArrayList selectedRows, |
426 |
AffineTransform at) {
|
427 |
FeatureSet selection = null;
|
428 |
try {
|
429 |
selection = (FeatureSet) ((FLyrVect) getVLE().getLayer()) |
430 |
.getFeatureStore().getSelection(); |
431 |
|
432 |
Iterator iterator = selection.iterator();
|
433 |
while (iterator.hasNext()) {
|
434 |
Feature feature = (Feature) iterator.next(); |
435 |
|
436 |
// }
|
437 |
// for (int i = 0; i < selectedRows.size(); i++) {
|
438 |
// IRowEdited edRow = (IRowEdited) selectedRows.get(i);
|
439 |
// IFeature feat = (IFeature) edRow.getLinkedRow();
|
440 |
// IFeature feat = (IFeature) selectedRows.get(i);
|
441 |
Geometry ig = ((Geometry) feature.getDefaultGeometry()) |
442 |
.cloneGeometry(); |
443 |
if (ig == null) |
444 |
continue;
|
445 |
Handler[] handlers = ig.getHandlers(Geometry.SELECTHANDLER); |
446 |
FGraphicUtilities.DrawHandlers((Graphics2D) g, at, handlers,
|
447 |
DefaultCADTool.handlerSymbol); |
448 |
} |
449 |
} catch (ReadException e) {
|
450 |
// TODO Auto-generated catch block
|
451 |
e.printStackTrace(); |
452 |
} catch (DataException e) {
|
453 |
// TODO Auto-generated catch block
|
454 |
e.printStackTrace(); |
455 |
} |
456 |
} |
457 |
|
458 |
public void setDescription(String[] currentdescriptions) { |
459 |
this.currentdescriptions = currentdescriptions;
|
460 |
} |
461 |
|
462 |
public String[] getDescriptions() { |
463 |
return currentdescriptions;
|
464 |
} |
465 |
|
466 |
/*
|
467 |
* (non-Javadoc)
|
468 |
*
|
469 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#end()
|
470 |
*/
|
471 |
public void end() { |
472 |
CADExtension.setCADTool("_selection", true); |
473 |
PluginServices.getMainFrame().setSelectedTool("_selection");
|
474 |
CADTool cadtool = CADExtension.getCADTool(); |
475 |
cadtool.setPreviosTool(this);
|
476 |
} |
477 |
|
478 |
public void init() { |
479 |
// jaume, should not be necessary
|
480 |
// CADTool.drawingSymbol.setOutlined(true);
|
481 |
// CADTool.drawingSymbol.setOutlineColor(Color.GREEN);
|
482 |
|
483 |
} |
484 |
|
485 |
// protected ArrayList getSelectedRows() {
|
486 |
// VectorialLayerEdited vle = getVLE();
|
487 |
// ArrayList selectedRow = vle.getSelectedRow();
|
488 |
// return selectedRow;
|
489 |
// }
|
490 |
|
491 |
protected ArrayList getSelectedHandlers() { |
492 |
VectorialLayerEdited vle = getVLE(); |
493 |
ArrayList selectedHandlers = vle.getSelectedHandler();
|
494 |
return selectedHandlers;
|
495 |
} |
496 |
|
497 |
public void clearSelection() throws DataException { |
498 |
VectorialLayerEdited vle = getVLE(); |
499 |
FeatureSet selection = null;
|
500 |
selection = (FeatureSet) ((FLyrVect) vle.getLayer()) |
501 |
.getFeatureStore().getSelection(); |
502 |
// ArrayList selectedRow = vle.getSelectedRow();
|
503 |
ArrayList selectedHandlers = vle.getSelectedHandler();
|
504 |
selection.dispose(); |
505 |
selectedHandlers.clear(); |
506 |
// VectorialEditableAdapter vea = vle.getVEA();
|
507 |
// FBitSet selection = vea.getSelection();
|
508 |
// selection.clear();
|
509 |
vle.setSelectionImage(null);
|
510 |
vle.setHandlersImage(null);
|
511 |
|
512 |
} |
513 |
|
514 |
public String getNextTool() { |
515 |
return tool;
|
516 |
} |
517 |
|
518 |
public void setNextTool(String tool) { |
519 |
this.tool = tool;
|
520 |
} |
521 |
|
522 |
public boolean changeCommand(String name) throws CommandException { |
523 |
CADTool[] cadtools = CADExtension.getCADTools();
|
524 |
for (int i = 0; i < cadtools.length; i++) { |
525 |
CADTool ct = cadtools[i]; |
526 |
if (name.equalsIgnoreCase(ct.getName())
|
527 |
|| name.equalsIgnoreCase(ct.toString())) { |
528 |
int type = Geometry.TYPES.POINT;
|
529 |
try {
|
530 |
type = ((FLyrVect) getVLE().getLayer()).getShapeType(); |
531 |
} catch (ReadException e) {
|
532 |
throw new CommandException(e); |
533 |
} |
534 |
if (ct.isApplicable(type)) {
|
535 |
getCadToolAdapter().setCadTool(ct); |
536 |
ct.init(); |
537 |
View vista = (View) PluginServices.getMDIManager() |
538 |
.getActiveWindow(); |
539 |
vista.getConsolePanel().addText("\n" + ct.getName(),
|
540 |
JConsole.COMMAND); |
541 |
String question = ct.getQuestion();
|
542 |
vista.getConsolePanel().addText( |
543 |
"\n" + "#" + question + " > ", JConsole.MESSAGE); |
544 |
return true; |
545 |
} |
546 |
throw new CommandException(name); |
547 |
} |
548 |
} |
549 |
return false; |
550 |
} |
551 |
|
552 |
public boolean isApplicable(int shapeType) { |
553 |
return true; |
554 |
} |
555 |
|
556 |
public abstract String toString(); |
557 |
|
558 |
public void throwValueException(String s, double d) { |
559 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
560 |
vista.getConsolePanel().addText(s + " : " + d, JConsole.ERROR);
|
561 |
} |
562 |
|
563 |
public void throwOptionException(String s, String o) { |
564 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
565 |
vista.getConsolePanel().addText(s + " : " + o, JConsole.ERROR);
|
566 |
} |
567 |
|
568 |
public void throwPointException(String s, double x, double y) { |
569 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
570 |
vista.getConsolePanel().addText(s + " : " + " X = " + x + ", Y = " + y, |
571 |
JConsole.ERROR); |
572 |
} |
573 |
|
574 |
public void setPreviosTool(DefaultCADTool tool) { |
575 |
previousTool = tool; |
576 |
} |
577 |
|
578 |
public void restorePreviousTool() { |
579 |
CADExtension.setCADTool(previousTool.toString(), true);
|
580 |
PluginServices.getMainFrame().setSelectedTool(previousTool.toString()); |
581 |
} |
582 |
|
583 |
public void endTransition(double x, double y, MouseEvent e) { |
584 |
// TODO Auto-generated method stub
|
585 |
|
586 |
} |
587 |
|
588 |
} |