svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / DefaultCADTool.java @ 23535
History | View | Annotate | Download (17.4 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.geom.Rectangle2D; |
50 |
import java.awt.image.BufferedImage; |
51 |
import java.util.ArrayList; |
52 |
import java.util.Iterator; |
53 |
|
54 |
import org.apache.log4j.Logger; |
55 |
import org.gvsig.fmap.data.DataException; |
56 |
import org.gvsig.fmap.data.ReadException; |
57 |
import org.gvsig.fmap.data.commands.CommandsRecord; |
58 |
import org.gvsig.fmap.data.feature.AbstractFeature; |
59 |
import org.gvsig.fmap.data.feature.Feature; |
60 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
61 |
import org.gvsig.fmap.data.feature.FeatureStore; |
62 |
import org.gvsig.fmap.geom.Geometry; |
63 |
import org.gvsig.fmap.geom.GeometryFactory; |
64 |
import org.gvsig.fmap.geom.GeometryManager; |
65 |
import org.gvsig.fmap.geom.handler.Handler; |
66 |
import org.gvsig.fmap.geom.operation.Draw; |
67 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
68 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
69 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
70 |
import org.gvsig.fmap.geom.primitive.DefaultEnvelope; |
71 |
import org.gvsig.fmap.geom.primitive.Envelope; |
72 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
73 |
import org.gvsig.fmap.mapcontext.ViewPort; |
74 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
75 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
76 |
import org.gvsig.fmap.mapcontext.rendering.symbols.FGraphicUtilities; |
77 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
78 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
79 |
|
80 |
import com.iver.andami.PluginServices; |
81 |
import com.iver.andami.messages.NotificationManager; |
82 |
import com.iver.cit.gvsig.CADExtension; |
83 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
84 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
85 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
86 |
import com.iver.utiles.console.JConsole; |
87 |
|
88 |
/**
|
89 |
* DOCUMENT ME!
|
90 |
*
|
91 |
* @author Vicente Caballero Navarro
|
92 |
*/
|
93 |
public abstract class DefaultCADTool implements CADTool { |
94 |
public static ISymbol selectionSymbol = SymbologyFactory. |
95 |
createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, new Color(255, 0,0, 100)); // Le ponemos una transparencia |
96 |
public static ISymbol axisReferencesSymbol = SymbologyFactory. |
97 |
createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, new Color(100, 100, 100, 100)); |
98 |
public static ISymbol geometrySelectSymbol = SymbologyFactory. |
99 |
createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.RED);
|
100 |
public static ISymbol handlerSymbol = SymbologyFactory. |
101 |
createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.ORANGE);
|
102 |
private static Logger logger = Logger.getLogger(DefaultCADTool.class |
103 |
.getName()); |
104 |
private CADToolAdapter cadToolAdapter;
|
105 |
|
106 |
private String question; |
107 |
|
108 |
private String[] currentdescriptions; |
109 |
|
110 |
private String tool = "selection"; |
111 |
|
112 |
private DefaultCADTool previousTool;
|
113 |
|
114 |
private ArrayList temporalCache = new ArrayList(); |
115 |
protected GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory();
|
116 |
public void addTemporalCache(Geometry geom) { |
117 |
temporalCache.add(geom); |
118 |
insertSpatialCache(geom); |
119 |
} |
120 |
public void clearTemporalCache() { |
121 |
Geometry[] geoms=(Geometry[])temporalCache.toArray(new Geometry[0]); |
122 |
for (int i=0;i<geoms.length;i++) { |
123 |
removeSpatialCache(geoms[i]); |
124 |
} |
125 |
temporalCache.clear(); |
126 |
} |
127 |
private void insertSpatialCache(Geometry geom) { |
128 |
VectorialLayerEdited vle = getVLE(); |
129 |
SpatialCache spatialCache=((FLyrVect)vle.getLayer()).getSpatialCache(); |
130 |
Envelope r=geom.getEnvelope(); |
131 |
if (geom.getType()==Geometry.TYPES.POINT) {
|
132 |
r = new DefaultEnvelope(r.getMinimum(0),r.getMinimum(1),r.getMinimum(0)+1,r.getMinimum(1)+1);//Rectangle2D.Double(r.getX(),r.getY(),1,1); |
133 |
} |
134 |
spatialCache.insert(r,geom); |
135 |
|
136 |
} |
137 |
private void removeSpatialCache(Geometry geom) { |
138 |
VectorialLayerEdited vle = getVLE(); |
139 |
SpatialCache spatialCache=((FLyrVect)vle.getLayer()).getSpatialCache(); |
140 |
Envelope r=geom.getEnvelope(); |
141 |
if (geom.getType()==Geometry.TYPES.POINT) {
|
142 |
r = new DefaultEnvelope(r.getMinimum(0),r.getMinimum(1),r.getMinimum(0)+1,r.getMinimum(1)+1);//Rectangle2D.Double(r.getX(),r.getY(),1,1); |
143 |
} |
144 |
spatialCache.remove(r,geom); |
145 |
|
146 |
} |
147 |
/**
|
148 |
* DOCUMENT ME!
|
149 |
*/
|
150 |
public void draw(Geometry geometry) { |
151 |
if (geometry != null) { |
152 |
BufferedImage img = getCadToolAdapter().getMapControl().getImage();
|
153 |
Graphics2D gImag = (Graphics2D) img.getGraphics(); |
154 |
ViewPort vp = getCadToolAdapter().getMapControl().getViewPort(); |
155 |
DrawOperationContext doc=new DrawOperationContext();
|
156 |
doc.setGraphics((Graphics2D)gImag);
|
157 |
doc.setViewPort(vp); |
158 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
159 |
try {
|
160 |
geometry.cloneGeometry().invokeOperation(Draw.CODE,doc); |
161 |
} catch (GeometryOperationNotSupportedException e) {
|
162 |
e.printStackTrace(); |
163 |
} catch (GeometryOperationException e) {
|
164 |
e.printStackTrace(); |
165 |
} |
166 |
// geometry.draw(gImag, vp, DefaultCADTool.selectionSymbol);
|
167 |
} |
168 |
} |
169 |
|
170 |
/**
|
171 |
* DOCUMENT ME!
|
172 |
*
|
173 |
* @param cta
|
174 |
* DOCUMENT ME!
|
175 |
*/
|
176 |
public void setCadToolAdapter(CADToolAdapter cta) { |
177 |
cadToolAdapter = cta; |
178 |
} |
179 |
|
180 |
/**
|
181 |
* DOCUMENT ME!
|
182 |
*
|
183 |
* @return DOCUMENT ME!
|
184 |
*/
|
185 |
public CADToolAdapter getCadToolAdapter() {
|
186 |
return cadToolAdapter;
|
187 |
} |
188 |
|
189 |
public VectorialLayerEdited getVLE() {
|
190 |
return (VectorialLayerEdited) CADExtension.getEditionManager()
|
191 |
.getActiveLayerEdited(); |
192 |
} |
193 |
|
194 |
/**
|
195 |
* DOCUMENT ME!
|
196 |
*
|
197 |
* @param g
|
198 |
* DOCUMENT ME!
|
199 |
* @param firstPoint
|
200 |
* DOCUMENT ME!
|
201 |
* @param endPoint
|
202 |
* DOCUMENT ME!
|
203 |
*/
|
204 |
public void drawLine(Graphics2D g, Point2D firstPoint, Point2D endPoint, ISymbol symbol) { |
205 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
206 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
207 |
elShape.lineTo(endPoint.getX(), endPoint.getY()); |
208 |
GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory(); |
209 |
DrawOperationContext doc=new DrawOperationContext();
|
210 |
doc.setGraphics(g); |
211 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
212 |
doc.setSymbol(symbol); |
213 |
try {
|
214 |
geomFactory.createPolyline2D(elShape).invokeOperation(Draw.CODE,doc); |
215 |
} catch (GeometryOperationNotSupportedException e) {
|
216 |
e.printStackTrace(); |
217 |
} catch (GeometryOperationException e) {
|
218 |
e.printStackTrace(); |
219 |
} |
220 |
// draw(g,
|
221 |
// getCadToolAdapter().getMapControl().getViewPort(),
|
222 |
// symbol);
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* DOCUMENT ME!
|
227 |
*
|
228 |
* @param geometry
|
229 |
* DOCUMENT ME!
|
230 |
*/
|
231 |
public void addGeometry(Geometry geometry) { |
232 |
VectorialLayerEdited vle=getVLE(); |
233 |
|
234 |
try {
|
235 |
FeatureStore featureStore = ((FLyrVect)vle.getLayer()).getFeatureStore(); |
236 |
// Deber?amos comprobar que lo que escribimos es correcto:
|
237 |
// Lo hacemos en el VectorialAdapter, justo antes de
|
238 |
// a?adir, borrar o modificar una feature
|
239 |
Feature feature=featureStore.createDefaultFeature(true);
|
240 |
// int numAttr = vea.getRecordset().getFieldCount();
|
241 |
// Value[] values = new Value[numAttr];
|
242 |
// for (int i = 0; i < numAttr; i++) {
|
243 |
// values[i] = ValueFactory.createNullValue();
|
244 |
// }
|
245 |
// String newFID = vea.getNewFID();
|
246 |
// DefaultFeature df = new DefaultFeature(geometry, values, newFID);
|
247 |
feature.editing(); |
248 |
feature.setGeometry(featureStore.getDefaultFeatureType().getDefaultGeometry(),geometry); |
249 |
featureStore.insert(feature); |
250 |
// feature = featureStore.getFeatureByID(feature.getID());
|
251 |
// int index = vea.addRow(df, getName(), EditionEvent.GRAPHIC);
|
252 |
// VectorialLayerEdited vle = getVLE();
|
253 |
clearSelection(); |
254 |
//ArrayList selectedRow = vle.getSelectedRow();
|
255 |
|
256 |
|
257 |
ViewPort vp = vle.getLayer().getMapContext().getViewPort(); |
258 |
BufferedImage selectionImage = new BufferedImage(vp |
259 |
.getImageWidth(), vp.getImageHeight(), |
260 |
BufferedImage.TYPE_INT_ARGB);
|
261 |
Graphics2D gs = selectionImage.createGraphics();
|
262 |
// int inversedIndex=vea.getInversedIndex(index);
|
263 |
FeatureCollection selection=(FeatureCollection)featureStore.getSelection(); |
264 |
// selection.add(feature);
|
265 |
// vle.addSelectionCache(new DefaultRowEdited(df,
|
266 |
// IRowEdited.STATUS_ADDED, inversedIndex ));
|
267 |
// vea.getSelection().set(inversedIndex);
|
268 |
// Geometry geom = (Geometry)feature.getDefaultGeometry();
|
269 |
DrawOperationContext doc=new DrawOperationContext();
|
270 |
doc.setGraphics(gs); |
271 |
doc.setViewPort(vp); |
272 |
doc.setSymbol(DefaultCADTool.selectionSymbol); |
273 |
geometry.cloneGeometry().invokeOperation(Draw.CODE,doc); |
274 |
// draw(gs, vp, DefaultCADTool.selectionSymbol);
|
275 |
vle.drawHandlers(geometry.cloneGeometry(), gs, vp); |
276 |
vle.setSelectionImage(selectionImage); |
277 |
insertSpatialCache(geometry); |
278 |
} catch (ReadException e) {
|
279 |
NotificationManager.addError(e.getMessage(),e); |
280 |
return;
|
281 |
} catch (GeometryOperationNotSupportedException e) {
|
282 |
NotificationManager.addError(e.getMessage(),e); |
283 |
return;
|
284 |
} catch (GeometryOperationException e) {
|
285 |
NotificationManager.addError(e.getMessage(),e); |
286 |
return;
|
287 |
} catch (DataException e) {
|
288 |
NotificationManager.addError(e.getMessage(),e); |
289 |
return;
|
290 |
} |
291 |
draw(geometry.cloneGeometry()); |
292 |
} |
293 |
|
294 |
|
295 |
|
296 |
/**
|
297 |
* DOCUMENT ME!
|
298 |
*
|
299 |
* @param geometry
|
300 |
* DOCUMENT ME!
|
301 |
*/
|
302 |
public void modifyFeature(Feature feature, Feature oldFeature) { |
303 |
try {
|
304 |
CommandsRecord cr=((FLyrVect)getVLE().getLayer()).getFeatureStore().getCommandsRecord(); |
305 |
cr.update(feature, oldFeature); |
306 |
} catch (ReadException e) {
|
307 |
NotificationManager.addError(e.getMessage(),e); |
308 |
} |
309 |
draw(((Geometry)feature.getDefaultGeometry()).cloneGeometry()); |
310 |
} |
311 |
|
312 |
/**
|
313 |
* DOCUMENT ME!
|
314 |
*
|
315 |
* @param geometry
|
316 |
* DOCUMENT ME!
|
317 |
* @param values
|
318 |
* DOCUMENT ME!
|
319 |
*/
|
320 |
public Feature addGeometry(Geometry geometry, Object[] values) { |
321 |
// int index = 0;
|
322 |
try {
|
323 |
FeatureStore featureStore = ((FLyrVect)getVLE().getLayer()).getFeatureStore(); |
324 |
Feature feature=featureStore.createDefaultFeature(true);
|
325 |
feature.editing(); |
326 |
feature.setGeometry(featureStore.getDefaultFeatureType().getDefaultGeometry(),geometry); |
327 |
for (int i = 0; i < values.length; i++) { |
328 |
feature.set(i,values[i]); |
329 |
} |
330 |
featureStore.insert(feature); |
331 |
return feature;
|
332 |
} catch (DataException e) {
|
333 |
// TODO Auto-generated catch block
|
334 |
e.printStackTrace(); |
335 |
} |
336 |
// try {
|
337 |
// String newFID = vea.getNewFID();
|
338 |
// DefaultFeature df = new DefaultFeature(geometry, values, newFID);
|
339 |
// index = vea.addRow(df, getName(), EditionEvent.GRAPHIC);
|
340 |
// insertSpatialCache(geometry);
|
341 |
// } catch (ValidateRowException e) {
|
342 |
// NotificationManager.addError(e);
|
343 |
// } catch (ReadException e) {
|
344 |
// NotificationManager.addError(e);
|
345 |
// }
|
346 |
// return vea.getInversedIndex(index);
|
347 |
return null; |
348 |
} |
349 |
|
350 |
/**
|
351 |
* Devuelve la cadena que corresponde al estado en el que nos encontramos.
|
352 |
*
|
353 |
* @return Cadena para mostrar por consola.
|
354 |
*/
|
355 |
public String getQuestion() { |
356 |
return question;
|
357 |
} |
358 |
|
359 |
/**
|
360 |
* Actualiza la cadena que corresponde al estado actual.
|
361 |
*
|
362 |
* @param s
|
363 |
* Cadena que aparecer? en consola.
|
364 |
*/
|
365 |
public void setQuestion(String s) { |
366 |
question = s; |
367 |
// ConsoleToken.addQuestion(s);
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* Provoca un repintado "soft" de la capa activa en edici?n. Las capas por
|
372 |
* debajo de ella no se dibujan de verdad, solo se dibuja la que est? en
|
373 |
* edici?n y las que est?n por encima de ella en el TOC.
|
374 |
*/
|
375 |
public void refresh() { |
376 |
// getCadToolAdapter().getMapControl().drawMap(false);
|
377 |
getVLE().getLayer().setDirty(true);
|
378 |
|
379 |
getCadToolAdapter().getMapControl().rePaintDirtyLayers(); |
380 |
} |
381 |
|
382 |
/*
|
383 |
* public void drawHandlers(Graphics g, FBitSet sel, AffineTransform at)
|
384 |
* throws DriverIOException { for (int i = sel.nextSetBit(0); i >= 0; i =
|
385 |
* sel.nextSetBit(i + 1)) { IGeometry ig =
|
386 |
* getCadToolAdapter().getVectorialAdapter() .getShape(i).cloneGeometry();
|
387 |
* if (ig == null) continue; Handler[] handlers =
|
388 |
* ig.getHandlers(IGeometry.SELECTHANDLER);
|
389 |
* FGraphicUtilities.DrawHandlers((Graphics2D) g, at, handlers); } }
|
390 |
*/
|
391 |
public void drawHandlers(Graphics g, ArrayList selectedRows, |
392 |
AffineTransform at) {
|
393 |
FeatureCollection selection=null;
|
394 |
try {
|
395 |
selection = (FeatureCollection)((FLyrVect)getVLE().getLayer()).getFeatureStore().getSelection(); |
396 |
} catch (ReadException e) {
|
397 |
// TODO Auto-generated catch block
|
398 |
e.printStackTrace(); |
399 |
} |
400 |
Iterator iterator=selection.iterator();
|
401 |
while (iterator.hasNext()) {
|
402 |
Feature feature = (Feature) iterator.next(); |
403 |
|
404 |
// }
|
405 |
// for (int i = 0; i < selectedRows.size(); i++) {
|
406 |
// IRowEdited edRow = (IRowEdited) selectedRows.get(i);
|
407 |
// IFeature feat = (IFeature) edRow.getLinkedRow();
|
408 |
// IFeature feat = (IFeature) selectedRows.get(i);
|
409 |
Geometry ig = ((Geometry)feature.getDefaultGeometry()).cloneGeometry(); |
410 |
if (ig == null) |
411 |
continue;
|
412 |
Handler[] handlers = ig.getHandlers(Geometry.SELECTHANDLER); |
413 |
FGraphicUtilities.DrawHandlers((Graphics2D) g, at, handlers,DefaultCADTool.handlerSymbol);
|
414 |
} |
415 |
} |
416 |
|
417 |
public void setDescription(String[] currentdescriptions) { |
418 |
this.currentdescriptions = currentdescriptions;
|
419 |
} |
420 |
|
421 |
public String[] getDescriptions() { |
422 |
return currentdescriptions;
|
423 |
} |
424 |
|
425 |
/*
|
426 |
* (non-Javadoc)
|
427 |
*
|
428 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#end()
|
429 |
*/
|
430 |
public void end() { |
431 |
CADExtension.setCADTool("_selection", true); |
432 |
PluginServices.getMainFrame().setSelectedTool("_selection");
|
433 |
CADTool cadtool=CADExtension.getCADTool(); |
434 |
cadtool.setPreviosTool(this);
|
435 |
} |
436 |
|
437 |
public void init() { |
438 |
// jaume, should not be necessary
|
439 |
// CADTool.drawingSymbol.setOutlined(true);
|
440 |
// CADTool.drawingSymbol.setOutlineColor(Color.GREEN);
|
441 |
|
442 |
} |
443 |
|
444 |
// protected ArrayList getSelectedRows() {
|
445 |
// VectorialLayerEdited vle = getVLE();
|
446 |
// ArrayList selectedRow = vle.getSelectedRow();
|
447 |
// return selectedRow;
|
448 |
// }
|
449 |
|
450 |
protected ArrayList getSelectedHandlers() { |
451 |
VectorialLayerEdited vle = getVLE(); |
452 |
ArrayList selectedHandlers = vle.getSelectedHandler();
|
453 |
return selectedHandlers;
|
454 |
} |
455 |
|
456 |
public void clearSelection() throws ReadException { |
457 |
VectorialLayerEdited vle = getVLE(); |
458 |
FeatureCollection selection=(FeatureCollection)((FLyrVect)vle.getLayer()).getFeatureStore().getSelection(); |
459 |
// ArrayList selectedRow = vle.getSelectedRow();
|
460 |
ArrayList selectedHandlers = vle.getSelectedHandler();
|
461 |
selection.clear(); |
462 |
selectedHandlers.clear(); |
463 |
// VectorialEditableAdapter vea = vle.getVEA();
|
464 |
// FBitSet selection = vea.getSelection();
|
465 |
// selection.clear();
|
466 |
vle.setSelectionImage(null);
|
467 |
vle.setHandlersImage(null);
|
468 |
|
469 |
} |
470 |
|
471 |
public String getNextTool() { |
472 |
return tool;
|
473 |
} |
474 |
|
475 |
public void setNextTool(String tool) { |
476 |
this.tool = tool;
|
477 |
} |
478 |
|
479 |
public boolean changeCommand(String name) throws CommandException { |
480 |
CADTool[] cadtools = CADExtension.getCADTools();
|
481 |
for (int i = 0; i < cadtools.length; i++) { |
482 |
CADTool ct = cadtools[i]; |
483 |
if (name.equalsIgnoreCase(ct.getName())
|
484 |
|| name.equalsIgnoreCase(ct.toString())) { |
485 |
int type = Geometry.TYPES.POINT;
|
486 |
try {
|
487 |
type = ((FLyrVect) getVLE().getLayer()).getShapeType(); |
488 |
} catch (ReadException e) {
|
489 |
throw new CommandException(e); |
490 |
} |
491 |
if (ct.isApplicable(type)) {
|
492 |
getCadToolAdapter().setCadTool(ct); |
493 |
ct.init(); |
494 |
View vista = (View) PluginServices.getMDIManager() |
495 |
.getActiveWindow(); |
496 |
vista.getConsolePanel().addText("\n" + ct.getName(),
|
497 |
JConsole.COMMAND); |
498 |
String question=ct.getQuestion();
|
499 |
vista.getConsolePanel().addText( |
500 |
"\n" + "#" + question + " > ", JConsole.MESSAGE); |
501 |
return true; |
502 |
} |
503 |
throw new CommandException(name); |
504 |
} |
505 |
} |
506 |
return false; |
507 |
} |
508 |
|
509 |
public boolean isApplicable(int shapeType) { |
510 |
return true; |
511 |
} |
512 |
|
513 |
public abstract String toString(); |
514 |
|
515 |
public void throwValueException(String s, double d) { |
516 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
517 |
vista.getConsolePanel().addText(s + " : " + d, JConsole.ERROR);
|
518 |
} |
519 |
|
520 |
public void throwOptionException(String s, String o) { |
521 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
522 |
vista.getConsolePanel().addText(s + " : " + o, JConsole.ERROR);
|
523 |
} |
524 |
|
525 |
public void throwPointException(String s, double x, double y) { |
526 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
527 |
vista.getConsolePanel().addText(s + " : " + " X = " + x + ", Y = " + y, |
528 |
JConsole.ERROR); |
529 |
} |
530 |
|
531 |
public void setPreviosTool(DefaultCADTool tool) { |
532 |
previousTool=tool; |
533 |
} |
534 |
public void restorePreviousTool() { |
535 |
CADExtension.setCADTool(previousTool.toString(), true);
|
536 |
PluginServices.getMainFrame().setSelectedTool(previousTool.toString()); |
537 |
} |
538 |
public void endTransition(double x, double y, MouseEvent e) { |
539 |
// TODO Auto-generated method stub
|
540 |
|
541 |
} |
542 |
|
543 |
} |