Revision 3452 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisSwingServicesImpl.java
VCSGisSwingServicesImpl.java | ||
---|---|---|
6 | 6 |
package org.gvsig.vcsgis.app; |
7 | 7 |
|
8 | 8 |
import java.io.File; |
9 |
import java.util.ArrayList; |
|
9 | 10 |
import java.util.HashMap; |
10 | 11 |
import java.util.Iterator; |
11 | 12 |
import java.util.List; |
... | ... | |
154 | 155 |
|
155 | 156 |
@Override |
156 | 157 |
public void highlight(int mode, Geometry geom) { |
158 |
highlight(mode, geom, null); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void highlight(int mode, Geometry geom, FeatureStore store) { |
|
157 | 163 |
if (this.highlightedPointSymbols == null) { |
158 | 164 |
this.highlightedPointSymbols = new HashMap<>(); |
159 | 165 |
this.highlightedLineSymbols = new HashMap<>(); |
... | ... | |
201 | 207 |
} catch (Exception ex) { |
202 | 208 |
} |
203 | 209 |
} |
204 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
205 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
206 |
MapContext mapContext = viewdoc.getMapContext(); |
|
207 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
208 |
if ( geom!=null ) { |
|
209 |
ISymbol symbol = null; |
|
210 |
if( geom instanceof Point || geom instanceof MultiPoint) { |
|
211 |
symbol = this.highlightedPointSymbols.get(mode); |
|
212 |
} else if( geom instanceof Curve || geom instanceof MultiCurve ) { |
|
213 |
symbol = this.highlightedLineSymbols.get(mode); |
|
214 |
} else if( geom instanceof Surface || geom instanceof MultiSurface ) { |
|
215 |
symbol = this.highlightedPolygonSymbols.get(mode); |
|
216 |
} |
|
217 |
if (symbol != null) { |
|
218 |
int symbolid = gl.getSymbolId(symbol); |
|
219 |
if (symbolid < 0) { |
|
220 |
gl.addSymbol(symbol); |
|
221 |
symbolid = gl.getSymbolId(symbol); |
|
210 |
List<ViewDocument> viewList = null; |
|
211 |
if(store == null){ |
|
212 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
213 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
214 |
viewList = new ArrayList<>(); |
|
215 |
viewList.add(viewdoc); |
|
216 |
} else { |
|
217 |
viewList = getViewDocumentsHavingAStore(store); |
|
218 |
} |
|
219 |
for (ViewDocument viewDoc : viewList) { |
|
220 |
MapContext mapContext = viewDoc.getMapContext(); |
|
221 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
222 |
if (geom != null) { |
|
223 |
ISymbol symbol = null; |
|
224 |
if (geom instanceof Point || geom instanceof MultiPoint) { |
|
225 |
symbol = this.highlightedPointSymbols.get(mode); |
|
226 |
} else if (geom instanceof Curve || geom instanceof MultiCurve) { |
|
227 |
symbol = this.highlightedLineSymbols.get(mode); |
|
228 |
} else if (geom instanceof Surface || geom instanceof MultiSurface) { |
|
229 |
symbol = this.highlightedPolygonSymbols.get(mode); |
|
222 | 230 |
} |
223 |
gl.addGraphic("vcsgis-highlighted", geom, symbolid); |
|
231 |
if (symbol != null) { |
|
232 |
int symbolid = gl.getSymbolId(symbol); |
|
233 |
if (symbolid < 0) { |
|
234 |
gl.addSymbol(symbol); |
|
235 |
symbolid = gl.getSymbolId(symbol); |
|
236 |
} |
|
237 |
gl.addGraphic("vcsgis-highlighted", geom, symbolid); |
|
238 |
} |
|
224 | 239 |
} |
240 |
mapContext.invalidate(); |
|
225 | 241 |
} |
226 |
mapContext.invalidate(); |
|
227 | 242 |
} |
228 | 243 |
|
229 | 244 |
@Override |
... | ... | |
238 | 253 |
} |
239 | 254 |
|
240 | 255 |
@Override |
256 |
public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
257 |
if(geometry != null){ |
|
258 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
259 |
for (ViewDocument view : views) { |
|
260 |
if(view != null){ |
|
261 |
view.center(geometry.getEnvelope()); |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
@Override |
|
241 | 268 |
public void zoomActiveViewToGeometry(Geometry geometry) { |
242 | 269 |
if(geometry != null){ |
243 | 270 |
IView view = getActiveView(); |
... | ... | |
248 | 275 |
} |
249 | 276 |
} |
250 | 277 |
|
278 |
@Override |
|
279 |
public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
280 |
if(geometry != null){ |
|
281 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
282 |
for (ViewDocument view : views) { |
|
283 |
if(view != null){ |
|
284 |
view.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
} |
|
289 |
|
|
251 | 290 |
private IView getActiveView() { |
252 | 291 |
ApplicationManager application = ApplicationLocator.getManager(); |
253 | 292 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
... | ... | |
257 | 296 |
@Override |
258 | 297 |
public void cleanHighligthed() { |
259 | 298 |
ApplicationManager application = ApplicationLocator.getManager(); |
299 |
ProjectManager projectManager = application.getProjectManager(); |
|
300 |
Project project = projectManager.getCurrentProject(); |
|
301 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
302 |
for (Document doc : views) { |
|
303 |
ViewDocument viewdoc = (ViewDocument)doc; |
|
304 |
MapContext mapContext = viewdoc.getMapContext(); |
|
305 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
306 |
//FIXME: Refrescar el mapContext solo cuando se ha borrado el graphics |
|
307 |
if(gl.removeGraphics("vcsgis-highlighted")) { |
|
308 |
mapContext.invalidate(); |
|
309 |
} |
|
310 |
} |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
314 |
public void cleanActiveViewHighligthed() { |
|
315 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
260 | 316 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
261 | 317 |
if(viewdoc != null){ |
262 | 318 |
MapContext mapContext = viewdoc.getMapContext(); |
... | ... | |
302 | 358 |
} |
303 | 359 |
} |
304 | 360 |
|
361 |
|
|
362 |
public List<ViewDocument> getViewDocumentsHavingAStore(FeatureStore store){ |
|
363 |
if(store == null){ |
|
364 |
return null; |
|
365 |
} |
|
366 |
List<ViewDocument> viewList = new ArrayList<>(); |
|
367 |
|
|
368 |
String storeFullName = store.getFullName(); |
|
369 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
370 |
ProjectManager projectManager = application.getProjectManager(); |
|
371 |
Project project = projectManager.getCurrentProject(); |
|
372 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
373 |
for (Document doc : views) { |
|
374 |
ViewDocument view = (ViewDocument) doc; |
|
375 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
376 |
FLayer layer = it.next(); |
|
377 |
if (layer instanceof FLyrVect) { |
|
378 |
if (StringUtils.equals( |
|
379 |
((FLyrVect) layer).getFeatureStore().getFullName(), |
|
380 |
store.getFullName() |
|
381 |
)) { |
|
382 |
viewList.add(view); |
|
383 |
} |
|
384 |
break; |
|
385 |
} |
|
386 |
} |
|
387 |
} |
|
388 |
return viewList; |
|
389 |
} |
|
390 |
|
|
305 | 391 |
@Override |
306 | 392 |
public void addLayerToActiveView(FeatureStore store, String name) { |
307 | 393 |
if(store != null && StringUtils.isNotBlank(name)){ |
Also available in: Unified diff