root / tags / v1_1_Build_1009 / extensions / extCAD / src / com / iver / cit / gvsig / layers / VectorialLayerEdited.java @ 12649
History | View | Annotate | Download (17.6 KB)
1 |
package com.iver.cit.gvsig.layers; |
---|---|
2 |
|
3 |
import java.awt.Graphics2D; |
4 |
import java.awt.Image; |
5 |
import java.awt.geom.Point2D; |
6 |
import java.awt.geom.Rectangle2D; |
7 |
import java.awt.image.BufferedImage; |
8 |
import java.io.IOException; |
9 |
import java.util.ArrayList; |
10 |
import java.util.EmptyStackException; |
11 |
|
12 |
import com.iver.andami.PluginServices; |
13 |
import com.iver.andami.messages.NotificationManager; |
14 |
import com.iver.andami.ui.mdiManager.IWindow; |
15 |
import com.iver.cit.gvsig.CADExtension; |
16 |
import com.iver.cit.gvsig.StartEditing; |
17 |
import com.iver.cit.gvsig.ViewCommandStackExtension; |
18 |
import com.iver.cit.gvsig.fmap.DriverException; |
19 |
import com.iver.cit.gvsig.fmap.ViewPort; |
20 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
21 |
import com.iver.cit.gvsig.fmap.core.Handler; |
22 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
23 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
24 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
25 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
26 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
27 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
28 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
29 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
30 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
31 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
32 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
33 |
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation; |
34 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
35 |
import com.iver.cit.gvsig.fmap.layers.LayerDrawEvent; |
36 |
import com.iver.cit.gvsig.fmap.layers.LayerDrawingListener; |
37 |
import com.iver.cit.gvsig.fmap.layers.LayerEvent; |
38 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
39 |
import com.iver.cit.gvsig.gui.cad.CADTool; |
40 |
import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
41 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
42 |
import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool; |
43 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
44 |
import com.vividsolutions.jts.geom.Geometry; |
45 |
|
46 |
public class VectorialLayerEdited extends DefaultLayerEdited implements LayerDrawingListener{ |
47 |
private ArrayList selectedHandler = new ArrayList(); |
48 |
private ArrayList selectedRow = new ArrayList(); |
49 |
private Point2D lastPoint; |
50 |
private Point2D firstPoint; |
51 |
private CADTool cadtool=null; |
52 |
|
53 |
private ArrayList snappers = new ArrayList(); |
54 |
private ArrayList layersToSnap = new ArrayList(); |
55 |
private Legend legend;
|
56 |
|
57 |
public VectorialLayerEdited(FLayer lyr)
|
58 |
{ |
59 |
super(lyr);
|
60 |
lyr.getMapContext().addLayerDrawingListener(this);
|
61 |
// Por defecto, siempre hacemos snapping sobre la capa en edici?n.
|
62 |
layersToSnap.add(lyr); |
63 |
} |
64 |
|
65 |
public ArrayList getSelectedHandler() { |
66 |
return selectedHandler;
|
67 |
} |
68 |
|
69 |
public ArrayList getSelectedRow() { |
70 |
return selectedRow;
|
71 |
} |
72 |
|
73 |
public void clearSelection() { |
74 |
selectedHandler.clear(); |
75 |
selectedRow.clear(); |
76 |
if (getVEA() != null) |
77 |
{ |
78 |
FBitSet selection=getVEA().getSelection(); |
79 |
selection.clear(); |
80 |
} |
81 |
} |
82 |
/**
|
83 |
* @return Returns the selectedRow.
|
84 |
*/
|
85 |
public IFeature[] getSelectedRowsCache() { |
86 |
return (IFeature[]) selectedRow.toArray(new IFeature[0]); |
87 |
} |
88 |
public void selectWithPoint(double x, double y,boolean multipleSelection){ |
89 |
firstPoint = new Point2D.Double(x, y); |
90 |
VectorialEditableAdapter vea = getVEA(); |
91 |
FBitSet selection = vea.getSelection(); |
92 |
if (!multipleSelection) {
|
93 |
clearSelection(); |
94 |
} |
95 |
// Se comprueba si se pincha en una gemometr?a
|
96 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
97 |
double tam =vp.toMapDistance(SelectionCADTool.tolerance);
|
98 |
Rectangle2D rect = new Rectangle2D.Double(firstPoint.getX() - tam, |
99 |
firstPoint.getY() - tam, tam * 2, tam * 2); |
100 |
|
101 |
String strEPSG = vp.getProjection().getAbrev().substring(5); |
102 |
IRowEdited[] feats;
|
103 |
|
104 |
try {
|
105 |
feats = vea.getFeatures(rect, strEPSG); |
106 |
selection.clear(); |
107 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
108 |
Graphics2D gs = selectionImage.createGraphics();
|
109 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
110 |
Graphics2D gh = handlersImage.createGraphics();
|
111 |
for (int i = 0; i < feats.length; i++) { |
112 |
IFeature feat = (IFeature) feats[i].getLinkedRow(); |
113 |
IGeometry geom = feat.getGeometry(); |
114 |
|
115 |
if (geom.intersects(rect)) { // , 0.1)){ |
116 |
selection.set(feats[i].getIndex(), true);
|
117 |
selectedRow.add(feats[i]); |
118 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
119 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
120 |
} |
121 |
} |
122 |
vea.setSelectionImage(selectionImage); |
123 |
vea.setHandlersImage(handlersImage); |
124 |
} catch (DriverException e1) {
|
125 |
NotificationManager.addError(e1.getMessage(),e1); |
126 |
} |
127 |
|
128 |
} |
129 |
public void selectWithSecondPoint(double x, double y) { |
130 |
VectorialEditableAdapter vea = getVEA(); |
131 |
FBitSet selection = vea.getSelection(); |
132 |
lastPoint = new Point2D.Double(x, y); |
133 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
134 |
selection.clear(); |
135 |
selectedRow.clear(); |
136 |
|
137 |
double x1;
|
138 |
double y1;
|
139 |
double w1;
|
140 |
double h1;
|
141 |
|
142 |
if (firstPoint.getX() < lastPoint.getX()) {
|
143 |
x1 = firstPoint.getX(); |
144 |
w1 = lastPoint.getX() - firstPoint.getX(); |
145 |
} else {
|
146 |
x1 = lastPoint.getX(); |
147 |
w1 = firstPoint.getX() - lastPoint.getX(); |
148 |
} |
149 |
|
150 |
if (firstPoint.getY() < lastPoint.getY()) {
|
151 |
y1 = firstPoint.getY(); |
152 |
h1 = lastPoint.getY() - firstPoint.getY(); |
153 |
} else {
|
154 |
y1 = lastPoint.getY(); |
155 |
h1 = firstPoint.getY() - lastPoint.getY(); |
156 |
} |
157 |
|
158 |
Rectangle2D rect = new Rectangle2D.Double(x1, y1, w1, h1); |
159 |
|
160 |
String strEPSG = vp.getProjection().getAbrev().substring(5); |
161 |
IRowEdited[] feats;
|
162 |
try {
|
163 |
feats = vea.getFeatures(rect, strEPSG); |
164 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
165 |
Graphics2D gs = selectionImage.createGraphics();
|
166 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
167 |
Graphics2D gh = handlersImage.createGraphics();
|
168 |
for (int i = 0; i < feats.length; i++) { |
169 |
IGeometry geom = ((IFeature) feats[i].getLinkedRow()) |
170 |
.getGeometry(); |
171 |
|
172 |
if (firstPoint.getX() < lastPoint.getX()) {
|
173 |
if (rect.contains(geom.getBounds2D())) {
|
174 |
selectedRow.add(feats[i]); |
175 |
selection.set(feats[i].getIndex(), true);
|
176 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
177 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
178 |
} |
179 |
} else {
|
180 |
if (geom.intersects(rect)) { // , 0.1)){ |
181 |
selectedRow.add(feats[i]); |
182 |
selection.set(feats[i].getIndex(), true);
|
183 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
184 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
185 |
} |
186 |
} |
187 |
} |
188 |
vea.setSelectionImage(selectionImage); |
189 |
vea.setHandlersImage(handlersImage); |
190 |
} catch (DriverException e) {
|
191 |
NotificationManager.addError(e.getMessage(),e); |
192 |
} |
193 |
|
194 |
} |
195 |
public void selectInsidePolygon(IGeometry polygon) { |
196 |
VectorialEditableAdapter vea = getVEA(); |
197 |
FBitSet selection = vea.getSelection(); |
198 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
199 |
selection.clear(); |
200 |
selectedRow.clear(); |
201 |
Rectangle2D rect = polygon.getBounds2D();
|
202 |
|
203 |
String strEPSG = vp.getProjection().getAbrev().substring(5); |
204 |
IRowEdited[] feats;
|
205 |
try {
|
206 |
feats = vea.getFeatures(rect, strEPSG); |
207 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
208 |
Graphics2D gs = selectionImage.createGraphics();
|
209 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
210 |
Graphics2D gh = handlersImage.createGraphics();
|
211 |
for (int i = 0; i < feats.length; i++) { |
212 |
IGeometry geom = ((IFeature) feats[i].getLinkedRow()) |
213 |
.getGeometry(); |
214 |
if (contains(polygon,geom)) {
|
215 |
selectedRow.add(feats[i]); |
216 |
selection.set(feats[i].getIndex(), true);
|
217 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
218 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
219 |
} |
220 |
} |
221 |
vea.setSelectionImage(selectionImage); |
222 |
vea.setHandlersImage(handlersImage); |
223 |
} catch (DriverException e) {
|
224 |
NotificationManager.addError(e.getMessage(),e); |
225 |
} |
226 |
} |
227 |
|
228 |
public void selectCrossPolygon(IGeometry polygon) { |
229 |
VectorialEditableAdapter vea = getVEA(); |
230 |
FBitSet selection = vea.getSelection(); |
231 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
232 |
selection.clear(); |
233 |
selectedRow.clear(); |
234 |
Rectangle2D rect = polygon.getBounds2D();
|
235 |
|
236 |
String strEPSG = vp.getProjection().getAbrev().substring(5); |
237 |
IRowEdited[] feats;
|
238 |
try {
|
239 |
feats = vea.getFeatures(rect, strEPSG); |
240 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
241 |
Graphics2D gs = selectionImage.createGraphics();
|
242 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
243 |
Graphics2D gh = handlersImage.createGraphics();
|
244 |
for (int i = 0; i < feats.length; i++) { |
245 |
IGeometry geom = ((IFeature) feats[i].getLinkedRow()) |
246 |
.getGeometry(); |
247 |
if (contains(polygon,geom) || intersects(polygon,geom)) {
|
248 |
selectedRow.add(feats[i]); |
249 |
selection.set(feats[i].getIndex(), true);
|
250 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
251 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
252 |
} |
253 |
} |
254 |
vea.setSelectionImage(selectionImage); |
255 |
vea.setHandlersImage(handlersImage); |
256 |
} catch (DriverException e) {
|
257 |
NotificationManager.addError(e.getMessage(),e); |
258 |
} |
259 |
} |
260 |
|
261 |
public void selectOutPolygon(IGeometry polygon) { |
262 |
VectorialEditableAdapter vea = getVEA(); |
263 |
FBitSet selection = vea.getSelection(); |
264 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
265 |
selection.clear(); |
266 |
selectedRow.clear(); |
267 |
|
268 |
try {
|
269 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
270 |
Graphics2D gs = selectionImage.createGraphics();
|
271 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
272 |
Graphics2D gh = handlersImage.createGraphics();
|
273 |
for (int i = 0; i < vea.getRowCount(); i++) { |
274 |
IRowEdited rowEd=(IRowEdited)vea.getRow(i); |
275 |
IGeometry geom = ((IFeature)rowEd.getLinkedRow()) |
276 |
.getGeometry(); |
277 |
if (!contains(polygon,geom) && !intersects(polygon,geom)) {
|
278 |
selectedRow.add(rowEd); |
279 |
selection.set(rowEd.getIndex(), true);
|
280 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
281 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
282 |
} |
283 |
} |
284 |
vea.setSelectionImage(selectionImage); |
285 |
vea.setHandlersImage(handlersImage); |
286 |
} catch (DriverIOException e) {
|
287 |
NotificationManager.addError(e.getMessage(),e); |
288 |
} catch (IOException e) { |
289 |
NotificationManager.addError(e.getMessage(),e); |
290 |
} |
291 |
} |
292 |
public void selectAll() { |
293 |
VectorialEditableAdapter vea = getVEA(); |
294 |
FBitSet selection = vea.getSelection(); |
295 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
296 |
selection.clear(); |
297 |
selectedRow.clear(); |
298 |
try {
|
299 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
300 |
Graphics2D gs = selectionImage.createGraphics();
|
301 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
302 |
Graphics2D gh = handlersImage.createGraphics();
|
303 |
for (int i = 0; i < vea.getRowCount(); i++) { |
304 |
IRowEdited rowEd=(IRowEdited)vea.getRow(i); |
305 |
IGeometry geom = ((IFeature)rowEd.getLinkedRow()) |
306 |
.getGeometry(); |
307 |
selectedRow.add(rowEd); |
308 |
selection.set(rowEd.getIndex(), true);
|
309 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
310 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
311 |
} |
312 |
vea.setSelectionImage(selectionImage); |
313 |
vea.setHandlersImage(handlersImage); |
314 |
} catch (DriverIOException e) {
|
315 |
NotificationManager.addError(e.getMessage(),e); |
316 |
} catch (IOException e) { |
317 |
NotificationManager.addError(e.getMessage(),e); |
318 |
} |
319 |
} |
320 |
|
321 |
public void refreshSelectionCache(Point2D firstPoint,CADToolAdapter cta){ |
322 |
VectorialEditableAdapter vea = getVEA(); |
323 |
FBitSet selection = vea.getSelection(); |
324 |
double min = java.lang.Double.MAX_VALUE;
|
325 |
// Cogemos las entidades seleccionadas
|
326 |
clearSelection(); |
327 |
ViewPort vp=getLayer().getMapContext().getViewPort(); |
328 |
BufferedImage selectionImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
329 |
Graphics2D gs = selectionImage.createGraphics();
|
330 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
331 |
Graphics2D gh = handlersImage.createGraphics();
|
332 |
for (int i = selection.nextSetBit(0); i >= 0; i = selection |
333 |
.nextSetBit(i + 1)) {
|
334 |
Handler[] handlers = null; |
335 |
|
336 |
DefaultRowEdited dre = null;
|
337 |
try {
|
338 |
dre = (DefaultRowEdited)(vea.getRow(i)); |
339 |
IFeature feat=(DefaultFeature)dre.getLinkedRow(); |
340 |
IGeometry geom=feat.getGeometry(); |
341 |
handlers = geom.getHandlers(IGeometry.SELECTHANDLER); |
342 |
selectedRow.add(dre); |
343 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
344 |
drawHandlers(geom.cloneGeometry(),gh,vp); |
345 |
// y miramos los handlers de cada entidad seleccionada
|
346 |
min = cta.getMapControl().getViewPort() |
347 |
.toMapDistance(SelectionCADTool.tolerance); |
348 |
for (int j = 0; j < handlers.length; j++) { |
349 |
Point2D handlerPoint = handlers[j].getPoint();
|
350 |
double distance = firstPoint.distance(handlerPoint);
|
351 |
if (distance <= min) {
|
352 |
min = distance; |
353 |
selectedHandler.add(handlers[j]); |
354 |
} |
355 |
} |
356 |
} catch (DriverIOException e) {
|
357 |
NotificationManager.addError(e.getMessage(),e); |
358 |
} catch (IOException e) { |
359 |
NotificationManager.addError(e.getMessage(),e); |
360 |
} |
361 |
} |
362 |
vea.setSelectionImage(selectionImage); |
363 |
vea.setHandlersImage(handlersImage); |
364 |
} |
365 |
|
366 |
public void drawHandlers(IGeometry geom, Graphics2D gs, ViewPort vp) { |
367 |
if (!(getLayer() instanceof FLyrAnnotation)){ |
368 |
Handler[] handlers = geom.getHandlers(IGeometry.SELECTHANDLER); |
369 |
FGraphicUtilities.DrawHandlers(gs, vp.getAffineTransform(), handlers,DefaultCADTool.handlerSymbol); |
370 |
} |
371 |
} |
372 |
public Image getSelectionImage(){ |
373 |
return getVEA().getSelectionImage();
|
374 |
} |
375 |
public Image getHandlersImage() { |
376 |
return getVEA().getHandlersImage();
|
377 |
} |
378 |
public VectorialEditableAdapter getVEA(){
|
379 |
if (((FLyrVect)getLayer()).getSource() instanceof VectorialEditableAdapter) |
380 |
return (VectorialEditableAdapter)((FLyrVect)getLayer()).getSource();
|
381 |
else
|
382 |
return null; |
383 |
} |
384 |
|
385 |
public void beforeLayerDraw(LayerDrawEvent e) throws CancelationException { |
386 |
if (((FLyrVect) getLayer()).getSource() instanceof VectorialEditableAdapter) { |
387 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) ((FLyrVect) getLayer()) |
388 |
.getSource(); |
389 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
390 |
BufferedImage selectionImage = new BufferedImage( |
391 |
vp.getImageWidth(), vp.getImageHeight(), |
392 |
BufferedImage.TYPE_INT_ARGB);
|
393 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
394 |
vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
395 |
Graphics2D gs = selectionImage.createGraphics();
|
396 |
Graphics2D gh = handlersImage.createGraphics();
|
397 |
for (int i = 0; i < selectedRow.size(); i++) { |
398 |
IFeature feat = (IFeature) ((IRowEdited) selectedRow.get(i)) |
399 |
.getLinkedRow(); |
400 |
IGeometry geom = feat.getGeometry(); |
401 |
geom.cloneGeometry().draw(gs, vp, DefaultCADTool.selectionSymbol); |
402 |
drawHandlers(geom.cloneGeometry(), gh, vp); |
403 |
} |
404 |
vea.setSelectionImage(selectionImage); |
405 |
vea.setHandlersImage(handlersImage); |
406 |
} |
407 |
} |
408 |
|
409 |
public void afterLayerDraw(LayerDrawEvent e) throws CancelationException { |
410 |
} |
411 |
|
412 |
public void beforeGraphicLayerDraw(LayerDrawEvent e) throws CancelationException { |
413 |
} |
414 |
|
415 |
public void afterLayerGraphicDraw(LayerDrawEvent e) throws CancelationException { |
416 |
} |
417 |
private static boolean contains(IGeometry g1,IGeometry g2) { |
418 |
Geometry geometry1=g1.toJTSGeometry(); |
419 |
Geometry geometry2=g2.toJTSGeometry(); |
420 |
if (geometry1==null || geometry2==null)return false; |
421 |
return geometry1.contains(geometry2);
|
422 |
} |
423 |
private static boolean intersects(IGeometry g1,IGeometry g2) { |
424 |
Geometry geometry1=g1.toJTSGeometry(); |
425 |
Geometry geometry2=g2.toJTSGeometry(); |
426 |
if (geometry1==null || geometry2==null)return false; |
427 |
return geometry1.intersects(geometry2);
|
428 |
} |
429 |
|
430 |
public void activationGained(LayerEvent e) { |
431 |
if (ViewCommandStackExtension.csd!=null){ |
432 |
ViewCommandStackExtension.csd.setModel(((IEditableSource) ((FLyrVect)getLayer()).getSource()) |
433 |
.getCommandRecord()); |
434 |
} |
435 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
436 |
if (window instanceof View){ |
437 |
View view=(View)window; |
438 |
if (e.getSource().isEditing()){
|
439 |
view.showConsole(); |
440 |
} |
441 |
} |
442 |
if (cadtool!=null){ |
443 |
CADExtension.getCADToolAdapter().setCadTool(cadtool); |
444 |
PluginServices.getMainFrame().setSelectedTool(cadtool.toString()); |
445 |
StartEditing.startCommandsApplicable(null,(FLyrVect)getLayer());
|
446 |
CADExtension.initFocus(); |
447 |
} |
448 |
|
449 |
} |
450 |
|
451 |
public void activationLost(LayerEvent e) { |
452 |
try{
|
453 |
cadtool=CADExtension.getCADTool(); |
454 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
455 |
if (window instanceof View){ |
456 |
View view=(View)window; |
457 |
view.hideConsole(); |
458 |
} |
459 |
}catch (EmptyStackException e1) { |
460 |
cadtool=new SelectionCADTool();
|
461 |
cadtool.init(); |
462 |
} |
463 |
|
464 |
} |
465 |
|
466 |
public ArrayList getSnappers() { |
467 |
return snappers;
|
468 |
} |
469 |
|
470 |
public ArrayList getLayersToSnap() { |
471 |
return layersToSnap;
|
472 |
} |
473 |
|
474 |
public void setLayersToSnap(ArrayList layersToSnap) { |
475 |
this.layersToSnap = layersToSnap;
|
476 |
|
477 |
} |
478 |
|
479 |
public void setSelectionCache(ArrayList selectedRowAux) { |
480 |
clearSelection(); |
481 |
VectorialEditableAdapter vea=getVEA(); |
482 |
FBitSet selection=vea.getSelection(); |
483 |
selectedRow.addAll(selectedRowAux); |
484 |
for (int i = 0;i < selectedRow.size(); i++) { |
485 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
486 |
selection.set(edRow.getIndex()); |
487 |
} |
488 |
} |
489 |
|
490 |
public void setLegend(Legend legend) { |
491 |
this.legend=legend;
|
492 |
} |
493 |
public Legend getLegend() {
|
494 |
return legend;
|
495 |
} |
496 |
} |