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