root / tags / v2_0_0_Build_2047 / extensions / extEditing / src / org / gvsig / editing / layers / VectorialLayerEdited.java @ 38269
History | View | Annotate | Download (17.1 KB)
1 | 29685 | jpiera | package org.gvsig.editing.layers; |
---|---|---|---|
2 | 4144 | fjp | |
3 | 4637 | caballero | import java.awt.Image; |
4 | 4366 | caballero | import java.awt.geom.Point2D; |
5 | import java.util.ArrayList; |
||
6 | 26912 | vcaballero | import java.util.ConcurrentModificationException; |
7 | 5018 | caballero | import java.util.EmptyStackException; |
8 | 4366 | caballero | |
9 | 38243 | jldominguez | import javax.swing.JOptionPane; |
10 | |||
11 | 35761 | jpiera | import org.slf4j.Logger; |
12 | import org.slf4j.LoggerFactory; |
||
13 | |||
14 | 29685 | jpiera | import org.gvsig.andami.PluginServices; |
15 | import org.gvsig.andami.messages.NotificationManager; |
||
16 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
17 | 38243 | jldominguez | import org.gvsig.app.ApplicationLocator; |
18 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
19 | 29685 | jpiera | import org.gvsig.editing.CADExtension; |
20 | import org.gvsig.editing.EditionChangeManager; |
||
21 | import org.gvsig.editing.StartEditing; |
||
22 | import org.gvsig.editing.ViewCommandStackExtension; |
||
23 | import org.gvsig.editing.gui.cad.CADTool; |
||
24 | import org.gvsig.editing.gui.cad.tools.SelectionCADTool; |
||
25 | import org.gvsig.editing.gui.cad.tools.select.SelectRowPanel; |
||
26 | 24500 | jmvivo | import org.gvsig.fmap.dal.exception.DataException; |
27 | import org.gvsig.fmap.dal.exception.ReadException; |
||
28 | 24490 | jmvivo | import org.gvsig.fmap.dal.feature.Feature; |
29 | 27268 | vcaballero | import org.gvsig.fmap.dal.feature.FeatureQuery; |
30 | 24490 | jmvivo | import org.gvsig.fmap.dal.feature.FeatureSelection; |
31 | import org.gvsig.fmap.dal.feature.FeatureSet; |
||
32 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
33 | 36005 | jpiera | import org.gvsig.fmap.geom.Geometry; |
34 | 27268 | vcaballero | import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
35 | import org.gvsig.fmap.geom.Geometry.TYPES; |
||
36 | 35761 | jpiera | import org.gvsig.fmap.geom.GeometryLocator; |
37 | import org.gvsig.fmap.geom.GeometryManager; |
||
38 | 27398 | jpiera | import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
39 | import org.gvsig.fmap.geom.exception.CreateGeometryException; |
||
40 | 21668 | vcaballero | import org.gvsig.fmap.geom.handler.Handler; |
41 | import org.gvsig.fmap.geom.operation.GeometryOperationException; |
||
42 | import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
||
43 | 27268 | vcaballero | import org.gvsig.fmap.geom.primitive.Circle; |
44 | 23086 | vcaballero | import org.gvsig.fmap.geom.primitive.Envelope; |
45 | 27268 | vcaballero | import org.gvsig.fmap.geom.primitive.Point; |
46 | 21668 | vcaballero | import org.gvsig.fmap.mapcontext.ViewPort; |
47 | import org.gvsig.fmap.mapcontext.layers.CancelationException; |
||
48 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
49 | import org.gvsig.fmap.mapcontext.layers.LayerDrawEvent; |
||
50 | import org.gvsig.fmap.mapcontext.layers.LayerDrawingListener; |
||
51 | import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
||
52 | 35941 | jpiera | import org.gvsig.fmap.mapcontext.layers.vectorial.ContainsGeometryEvaluator; |
53 | 21668 | vcaballero | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
54 | 27268 | vcaballero | import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsGeometryEvaluator; |
55 | import org.gvsig.fmap.mapcontext.layers.vectorial.OutGeometryEvaluator; |
||
56 | 21668 | vcaballero | import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
57 | 36005 | jpiera | import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
58 | 23657 | vcaballero | import org.gvsig.fmap.mapcontrol.MapControl; |
59 | 36005 | jpiera | import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
60 | 30335 | jpiera | import org.gvsig.fmap.mapcontrol.MapControlLocator; |
61 | import org.gvsig.fmap.mapcontrol.MapControlManager; |
||
62 | 35761 | jpiera | import org.gvsig.tools.dispose.DisposableIterator; |
63 | 31284 | cordinyana | import org.gvsig.tools.dispose.DisposeUtils; |
64 | 27268 | vcaballero | import org.gvsig.tools.evaluator.Evaluator; |
65 | 23066 | jmvivo | import org.gvsig.tools.observer.Observable; |
66 | import org.gvsig.tools.observer.Observer; |
||
67 | 12739 | caballero | |
68 | 23646 | vcaballero | public class VectorialLayerEdited extends DefaultLayerEdited implements |
69 | 30335 | jpiera | LayerDrawingListener, Observer {
|
70 | 27398 | jpiera | private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
71 | 36005 | jpiera | private static final Logger LOG = LoggerFactory.getLogger(VectorialLayerEdited.class); |
72 | private static final MapControlManager MAP_CONTROL_MANAGER = MapControlLocator.getMapControlManager(); |
||
73 | 4366 | caballero | private ArrayList selectedHandler = new ArrayList(); |
74 | 4708 | caballero | private Point2D lastPoint; |
75 | private Point2D firstPoint; |
||
76 | 23646 | vcaballero | private CADTool cadtool = null; |
77 | 5906 | caballero | |
78 | 11558 | jaume | private ILegend legend;
|
79 | 21668 | vcaballero | private Image imageSelection; |
80 | private Image imageHandlers; |
||
81 | 26876 | vcaballero | private EditionChangeManager echm=null; |
82 | 30335 | jpiera | private MapControl mapControl = null; |
83 | 4366 | caballero | |
84 | 30335 | jpiera | public VectorialLayerEdited(FLayer lyr, MapControl mapControl) {
|
85 | 4147 | fjp | super(lyr);
|
86 | 30335 | jpiera | this.mapControl = mapControl;
|
87 | 6881 | cesar | lyr.getMapContext().addLayerDrawingListener(this);
|
88 | 29685 | jpiera | // Por defecto, siempre hacemos snapping sobre la capa en edici?n.
|
89 | 23646 | vcaballero | lyr.getMapContext().getLayersToSnap().add(lyr); |
90 | 30335 | jpiera | ((FLyrVect) lyr).getFeatureStore().addObserver(this);
|
91 | 4144 | fjp | } |
92 | 4366 | caballero | |
93 | public ArrayList getSelectedHandler() { |
||
94 | return selectedHandler;
|
||
95 | } |
||
96 | |||
97 | 27268 | vcaballero | public void clearSelection() throws DataException { |
98 | 27525 | jmvivo | if (getFeatureStore() == null) { |
99 | 23086 | vcaballero | return;
|
100 | 27525 | jmvivo | } |
101 | 26436 | vcaballero | FeatureSelection selection = getFeatureStore().getFeatureSelection(); |
102 | 4366 | caballero | selectedHandler.clear(); |
103 | 25563 | vcaballero | selection.deselectAll(); |
104 | 4366 | caballero | } |
105 | 23646 | vcaballero | |
106 | public void selectWithPoint(double x, double y, boolean multipleSelection) { |
||
107 | 31284 | cordinyana | FeatureSet set = null;
|
108 | 21668 | vcaballero | try {
|
109 | 23646 | vcaballero | firstPoint = new Point2D.Double(x, y); |
110 | FeatureStore featureStore = getFeatureStore(); |
||
111 | 29685 | jpiera | // Se comprueba si se pincha en una gemometr?a
|
112 | 36005 | jpiera | ViewPort viewPort = getLayer().getMapContext().getViewPort(); |
113 | double tol = viewPort.toMapDistance(MAP_CONTROL_MANAGER.getTolerance());
|
||
114 | 10626 | caballero | |
115 | 27268 | vcaballero | GeometryManager manager = GeometryLocator.getGeometryManager(); |
116 | Point center = (org.gvsig.fmap.geom.primitive.Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
|
||
117 | center.setX(x); |
||
118 | center.setY(y); |
||
119 | 27398 | jpiera | Circle circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
120 | 27268 | vcaballero | circle.setPoints(center, tol); |
121 | 4637 | caballero | |
122 | 36005 | jpiera | FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
123 | featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}); |
||
124 | Evaluator evaluator = new IntersectsGeometryEvaluator(circle, viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
||
125 | featureQuery.setFilter(evaluator); |
||
126 | set = featureStore.getFeatureSet(featureQuery); |
||
127 | 28561 | vcaballero | if (!multipleSelection && set.getSize()>1){ |
128 | 36005 | jpiera | SelectRowPanel selectionPanel = new SelectRowPanel(set, this); |
129 | 28561 | vcaballero | PluginServices.getMDIManager().addCentredWindow(selectionPanel); |
130 | } |
||
131 | 36762 | cordinyana | else {
|
132 | selectGeometries(featureStore, set, viewPort, multipleSelection); |
||
133 | } |
||
134 | 21668 | vcaballero | } catch (ReadException e) {
|
135 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
136 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
137 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
138 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
139 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
140 | 24263 | vcaballero | } catch (DataException e) {
|
141 | NotificationManager.addError(e.getMessage(), e); |
||
142 | 27398 | jpiera | } catch (CreateGeometryException e) {
|
143 | 27268 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
144 | 31284 | cordinyana | } finally {
|
145 | set.dispose(); |
||
146 | 14586 | vcaballero | } |
147 | 4637 | caballero | } |
148 | 21668 | vcaballero | |
149 | 23646 | vcaballero | public void selectWithSecondPoint(double x, double y) { |
150 | 31284 | cordinyana | FeatureSet set = null;
|
151 | 10626 | caballero | try {
|
152 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
153 | lastPoint = new Point2D.Double(x, y); |
||
154 | 36005 | jpiera | ViewPort viewPort = getLayer().getMapContext().getViewPort(); |
155 | 23646 | vcaballero | double x1;
|
156 | double y1;
|
||
157 | double w1;
|
||
158 | double h1;
|
||
159 | 4637 | caballero | |
160 | 23646 | vcaballero | if (firstPoint.getX() < lastPoint.getX()) {
|
161 | x1 = firstPoint.getX(); |
||
162 | w1 = lastPoint.getX() - firstPoint.getX(); |
||
163 | } else {
|
||
164 | x1 = lastPoint.getX(); |
||
165 | w1 = firstPoint.getX() - lastPoint.getX(); |
||
166 | } |
||
167 | 4637 | caballero | |
168 | 23646 | vcaballero | if (firstPoint.getY() < lastPoint.getY()) {
|
169 | y1 = firstPoint.getY(); |
||
170 | h1 = lastPoint.getY() - firstPoint.getY(); |
||
171 | } else {
|
||
172 | y1 = lastPoint.getY(); |
||
173 | h1 = firstPoint.getY() - lastPoint.getY(); |
||
174 | } |
||
175 | 4637 | caballero | |
176 | 27398 | jpiera | Envelope envelope = geomManager.createEnvelope(x1, y1, x1 + w1, y1 + h1, SUBTYPES.GEOM2D); |
177 | 23646 | vcaballero | |
178 | 36005 | jpiera | FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
179 | featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}); |
||
180 | 27268 | vcaballero | Evaluator evaluator=null;
|
181 | if (firstPoint.getX() < lastPoint.getX()) {
|
||
182 | 36005 | jpiera | evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
183 | 27268 | vcaballero | }else{
|
184 | 36005 | jpiera | evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
185 | 4637 | caballero | } |
186 | 36005 | jpiera | featureQuery.setFilter(evaluator); |
187 | set = featureStore.getFeatureSet(featureQuery); |
||
188 | selectGeometries(featureStore, set, viewPort, false);
|
||
189 | 21668 | vcaballero | } catch (ReadException e) {
|
190 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
191 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
192 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
193 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
194 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
195 | 24263 | vcaballero | } catch (DataException e) {
|
196 | NotificationManager.addError(e.getMessage(), e); |
||
197 | 27398 | jpiera | } catch (CreateEnvelopeException e) {
|
198 | NotificationManager.addError(e.getMessage(), e); |
||
199 | 31284 | cordinyana | } finally {
|
200 | DisposeUtils.dispose(set); |
||
201 | 14586 | vcaballero | } |
202 | 4637 | caballero | } |
203 | 21668 | vcaballero | |
204 | 35941 | jpiera | public void selectContainsSurface(org.gvsig.fmap.geom.Geometry polygon) { |
205 | 31284 | cordinyana | FeatureSet set = null;
|
206 | 10626 | caballero | try {
|
207 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
208 | 36005 | jpiera | ViewPort viewPort = getLayer().getMapContext().getViewPort(); |
209 | FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
||
210 | featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}); |
||
211 | Evaluator evaluator = new ContainsGeometryEvaluator(polygon, viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
||
212 | featureQuery.setFilter(evaluator); |
||
213 | set = featureStore.getFeatureSet(featureQuery); |
||
214 | selectGeometries(featureStore, set, viewPort, false);
|
||
215 | 21668 | vcaballero | } catch (ReadException e) {
|
216 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
217 | 26436 | vcaballero | } catch (DataException e) {
|
218 | NotificationManager.addError(e.getMessage(), e); |
||
219 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
220 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
221 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
222 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
223 | 31284 | cordinyana | } finally {
|
224 | DisposeUtils.dispose(set); |
||
225 | 14586 | vcaballero | } |
226 | 4708 | caballero | } |
227 | 36005 | jpiera | |
228 | 30788 | jpiera | private void selectGeometries(FeatureStore featureStore, FeatureSet set, ViewPort vp, boolean multipleSelection) throws DataException, GeometryOperationNotSupportedException, GeometryOperationException{ |
229 | 31284 | cordinyana | FeatureSelection featureSelection = null;
|
230 | if (multipleSelection) {
|
||
231 | featureSelection = (FeatureSelection) featureStore.getSelection(); |
||
232 | featureSelection.select(set); |
||
233 | } else {
|
||
234 | featureSelection = featureStore.createFeatureSelection(); |
||
235 | featureSelection.select(set); |
||
236 | featureStore.setSelection(featureSelection); |
||
237 | } |
||
238 | 36005 | jpiera | //Draw the geometries with the edition symbology
|
239 | |||
240 | 27268 | vcaballero | } |
241 | 30788 | jpiera | |
242 | 35941 | jpiera | public void selectIntersectsSurface(org.gvsig.fmap.geom.Geometry polygon) { |
243 | 31284 | cordinyana | FeatureSet set = null;
|
244 | 10626 | caballero | try {
|
245 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
246 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
247 | 36005 | jpiera | FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
248 | featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}); |
||
249 | 35941 | jpiera | Evaluator evaluator = new IntersectsGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
250 | 36005 | jpiera | featureQuery.setFilter(evaluator); |
251 | set = featureStore.getFeatureSet(featureQuery); |
||
252 | 30788 | jpiera | selectGeometries(featureStore,set,vp,false);
|
253 | 21668 | vcaballero | } catch (ReadException e) {
|
254 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
255 | 26436 | vcaballero | } catch (DataException e) {
|
256 | NotificationManager.addError(e.getMessage(), e); |
||
257 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
258 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
259 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
260 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
261 | 31284 | cordinyana | } finally {
|
262 | DisposeUtils.dispose(set); |
||
263 | 14586 | vcaballero | } |
264 | 4708 | caballero | } |
265 | |||
266 | 21668 | vcaballero | public void selectOutPolygon(org.gvsig.fmap.geom.Geometry polygon) { |
267 | 31284 | cordinyana | FeatureSet set = null;
|
268 | 10626 | caballero | try {
|
269 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
270 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
271 | 36005 | jpiera | FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
272 | featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}); |
||
273 | 27268 | vcaballero | Evaluator evaluator=new OutGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
274 | 36005 | jpiera | featureQuery.setFilter(evaluator); |
275 | set = featureStore.getFeatureSet(featureQuery); |
||
276 | 30788 | jpiera | selectGeometries(featureStore, set, vp, false);
|
277 | 4708 | caballero | |
278 | 21668 | vcaballero | } catch (ReadException e) {
|
279 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
280 | 26436 | vcaballero | } catch (DataException e) {
|
281 | NotificationManager.addError(e.getMessage(), e); |
||
282 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
283 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
284 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
285 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
286 | 31284 | cordinyana | } finally {
|
287 | DisposeUtils.dispose(set); |
||
288 | 14586 | vcaballero | } |
289 | 4708 | caballero | } |
290 | 21668 | vcaballero | |
291 | 23646 | vcaballero | public void selectAll() { |
292 | 31284 | cordinyana | FeatureSet set = null;
|
293 | 10626 | caballero | try {
|
294 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
295 | 36005 | jpiera | ViewPort viewPort = getLayer().getMapContext().getViewPort(); |
296 | 31284 | cordinyana | set = featureStore.getFeatureSet(); |
297 | 36005 | jpiera | selectGeometries(featureStore, set, viewPort, false);
|
298 | 21668 | vcaballero | } catch (ReadException e) {
|
299 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
300 | 22986 | vcaballero | } catch (DataException e) {
|
301 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
302 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
303 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
304 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
305 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
306 | 31284 | cordinyana | } finally {
|
307 | DisposeUtils.dispose(set); |
||
308 | 21668 | vcaballero | } |
309 | 4366 | caballero | } |
310 | 4637 | caballero | |
311 | 30788 | jpiera | public void drawHandlers(org.gvsig.fmap.geom.Geometry geom, |
312 | 23646 | vcaballero | ViewPort vp) { |
313 | 37494 | jpiera | Geometry drawnGeometry = geom; |
314 | //If the layer is reprojected, reproject the geometry to draw its handlers in the fine position
|
||
315 | if (getLayer().getCoordTrans() != null){ |
||
316 | drawnGeometry = drawnGeometry.cloneGeometry(); |
||
317 | drawnGeometry.reProject(getLayer().getCoordTrans()); |
||
318 | } |
||
319 | Handler[] handlers = drawnGeometry.getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
||
320 | 30335 | jpiera | mapControl.getMapControlDrawer().drawHandlers(handlers, vp.getAffineTransform(), |
321 | 36005 | jpiera | MAP_CONTROL_MANAGER.getHandlerSymbol()); |
322 | 4637 | caballero | } |
323 | 23646 | vcaballero | |
324 | public Image getSelectionImage() { |
||
325 | 21668 | vcaballero | return imageSelection;
|
326 | 4637 | caballero | } |
327 | 23646 | vcaballero | |
328 | public void setSelectionImage(Image image) { |
||
329 | imageSelection = image; |
||
330 | 21668 | vcaballero | } |
331 | 23646 | vcaballero | |
332 | 4637 | caballero | public Image getHandlersImage() { |
333 | 21668 | vcaballero | return imageHandlers;
|
334 | 4637 | caballero | } |
335 | 23646 | vcaballero | |
336 | public void setHandlersImage(Image image) { |
||
337 | imageHandlers = image; |
||
338 | 4637 | caballero | } |
339 | |||
340 | public void beforeLayerDraw(LayerDrawEvent e) throws CancelationException { |
||
341 | 30788 | jpiera | |
342 | } |
||
343 | |||
344 | public void afterLayerDraw(LayerDrawEvent e) throws CancelationException { |
||
345 | //Draw the selected geometries...
|
||
346 | 23646 | vcaballero | FeatureStore featureStore = null;
|
347 | 30788 | jpiera | DisposableIterator iterator = null;
|
348 | 23086 | vcaballero | try {
|
349 | featureStore = getFeatureStore(); |
||
350 | 30788 | jpiera | if (featureStore.isEditing()) {
|
351 | 36005 | jpiera | ViewPort viewPort = getLayer().getMapContext().getViewPort(); |
352 | iterator = featureStore.getFeatureSelection().fastIterator(); |
||
353 | MapControlDrawer mapControlDrawer = mapControl.getMapControlDrawer(); |
||
354 | 27525 | jmvivo | try {
|
355 | while (iterator.hasNext()) {
|
||
356 | Feature feature = (Feature) iterator.next(); |
||
357 | 36005 | jpiera | Geometry geometry = feature.getDefaultGeometry(); |
358 | mapControlDrawer.startDrawing(this);
|
||
359 | mapControlDrawer.setGraphics(e.getGraphics()); |
||
360 | drawHandlers(geometry.cloneGeometry(), viewPort); |
||
361 | mapControlDrawer.stopDrawing(this);
|
||
362 | 27525 | jmvivo | } |
363 | } catch (ConcurrentModificationException e1) { |
||
364 | // throw new CancelationException(e1);
|
||
365 | 30788 | jpiera | // A mitad de pintado se cambia la selecci?n y por tanto no
|
366 | 27525 | jmvivo | // se puede seguir recorriendo la anterior.
|
367 | return;
|
||
368 | } |
||
369 | 24263 | vcaballero | } |
370 | 30788 | jpiera | } catch (Exception e2) { |
371 | 38243 | jldominguez | LOG.info("afterLayerDraw error. ", e2);
|
372 | ApplicationLocator.getManager().message( |
||
373 | "_Unable_to_draw_geometry_handlers",
|
||
374 | JOptionPane.ERROR_MESSAGE);
|
||
375 | // LOG.error("Error drawing the selected geometry", e2);
|
||
376 | 30788 | jpiera | } finally {
|
377 | if (iterator != null) { |
||
378 | iterator.dispose(); |
||
379 | } |
||
380 | 4637 | caballero | } |
381 | } |
||
382 | |||
383 | 36005 | jpiera | public void beforeGraphicLayerDraw(LayerDrawEvent e) |
384 | 30335 | jpiera | throws CancelationException {
|
385 | 4637 | caballero | } |
386 | |||
387 | 23646 | vcaballero | public void afterLayerGraphicDraw(LayerDrawEvent e) |
388 | 30335 | jpiera | throws CancelationException {
|
389 | 4637 | caballero | } |
390 | 23646 | vcaballero | |
391 | 5018 | caballero | public void activationGained(LayerEvent e) { |
392 | 23646 | vcaballero | if (ViewCommandStackExtension.csd != null) { |
393 | 30335 | jpiera | ViewCommandStackExtension.csd.setModel(((FLyrVect) getLayer()) |
394 | .getFeatureStore()); |
||
395 | |||
396 | 5084 | caballero | } |
397 | 23646 | vcaballero | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
398 | 31496 | jjdelcerro | if (window instanceof DefaultViewPanel) { |
399 | DefaultViewPanel view = (DefaultViewPanel) window; |
||
400 | 23646 | vcaballero | if (e.getSource().isEditing()) {
|
401 | 10836 | caballero | view.showConsole(); |
402 | } |
||
403 | } |
||
404 | 23646 | vcaballero | if (cadtool != null) { |
405 | 5018 | caballero | CADExtension.getCADToolAdapter().setCadTool(cadtool); |
406 | PluginServices.getMainFrame().setSelectedTool(cadtool.toString()); |
||
407 | 23646 | vcaballero | StartEditing.startCommandsApplicable(null, (FLyrVect) getLayer());
|
408 | 5257 | caballero | CADExtension.initFocus(); |
409 | 5018 | caballero | } |
410 | 5227 | caballero | |
411 | 5018 | caballero | } |
412 | |||
413 | public void activationLost(LayerEvent e) { |
||
414 | 23646 | vcaballero | try {
|
415 | cadtool = CADExtension.getCADTool(); |
||
416 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
417 | 31496 | jjdelcerro | if (window instanceof DefaultViewPanel) { |
418 | DefaultViewPanel view = (DefaultViewPanel) window; |
||
419 | 10836 | caballero | view.hideConsole(); |
420 | } |
||
421 | 23646 | vcaballero | } catch (EmptyStackException e1) { |
422 | cadtool = new SelectionCADTool();
|
||
423 | 5018 | caballero | cadtool.init(); |
424 | } |
||
425 | |||
426 | } |
||
427 | 5261 | fjp | |
428 | 11558 | jaume | public void setLegend(ILegend legend) { |
429 | 23646 | vcaballero | this.legend = legend;
|
430 | 6312 | caballero | } |
431 | 23646 | vcaballero | |
432 | 11558 | jaume | public ILegend getLegend() {
|
433 | 6312 | caballero | return legend;
|
434 | } |
||
435 | 8940 | caballero | |
436 | 23646 | vcaballero | public FeatureStore getFeatureStore() throws ReadException { |
437 | return ((FLyrVect) getLayer()).getFeatureStore();
|
||
438 | 22986 | vcaballero | } |
439 | 9814 | caballero | |
440 | 24966 | vcaballero | public void update(Observable observable, Object notification) { |
441 | 26876 | vcaballero | echm.update(observable, notification); |
442 | 9814 | caballero | } |
443 | 26876 | vcaballero | |
444 | public EditionChangeManager getEditionChangeManager() {
|
||
445 | return echm;
|
||
446 | } |
||
447 | |||
448 | public void setEditionChangeManager(EditionChangeManager echm) { |
||
449 | this.echm = echm;
|
||
450 | } |
||
451 | 4144 | fjp | } |