Revision 43215 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java
FLyrVect.java | ||
---|---|---|
105 | 105 |
* Capa b?sica Vectorial. |
106 | 106 |
* |
107 | 107 |
*/ |
108 |
public class FLyrVect extends FLyrDefault implements VectorLayer, |
|
109 |
LegendContentsChangedListener, Observer { |
|
108 |
public class FLyrVect |
|
109 |
extends FLyrDefault |
|
110 |
implements VectorLayer, |
|
111 |
LegendContentsChangedListener, Observer { |
|
110 | 112 |
|
111 | 113 |
final static private org.slf4j.Logger logger |
112 |
= LoggerFactory.getLogger(FLyrVect.class);
|
|
114 |
= LoggerFactory.getLogger(FLyrVect.class); |
|
113 | 115 |
private final GeometryManager geomManager |
114 |
= GeometryLocator.getGeometryManager();
|
|
116 |
= GeometryLocator.getGeometryManager(); |
|
115 | 117 |
|
116 | 118 |
/** |
117 | 119 |
* Leyenda de la capa vectorial |
... | ... | |
136 | 138 |
super(); |
137 | 139 |
} |
138 | 140 |
|
141 |
@Override |
|
139 | 142 |
public String getTocImageIcon() { |
140 |
if (this.isAvailable()) { |
|
141 |
return MapContextLocator.getMapContextManager().getIconLayer(this.getDataStore()); |
|
142 |
} else { |
|
143 |
/* |
|
144 |
* data store can be be null, |
|
145 |
* for example, a layer not loaded from persistence |
|
146 |
*/ |
|
147 |
return "layer-icon-unavailable"; |
|
148 |
} |
|
149 |
|
|
143 |
return MapContextLocator.getMapContextManager().getIconLayer(this.getDataStore()); |
|
150 | 144 |
} |
151 | 145 |
|
152 | 146 |
/** |
153 |
* Devuelve el VectorialAdapater de la capa.
|
|
147 |
* Return the store associated to the layer.
|
|
154 | 148 |
* |
155 |
* @return VectorialAdapter.
|
|
149 |
* @return the store
|
|
156 | 150 |
*/ |
151 |
@Override |
|
157 | 152 |
public DataStore getDataStore() { |
158 |
// if (!this.isAvailable()) { |
|
159 |
// return null; |
|
160 |
// } |
|
161 | 153 |
return featureStore; |
162 | 154 |
} |
163 | 155 |
|
... | ... | |
180 | 172 |
* @throws LoadLayerException |
181 | 173 |
*/ |
182 | 174 |
protected void bindToDataStore(DataStore dataStore) throws LoadLayerException { |
183 |
if (this.featureStore != null && this.featureStore != dataStore) {
|
|
175 |
if( this.featureStore != null && this.featureStore != dataStore ) {
|
|
184 | 176 |
this.featureStore.deleteObserver(this); |
185 | 177 |
} |
186 | 178 |
|
187 | 179 |
featureStore = (FeatureStore) dataStore; |
188 | 180 |
|
189 | 181 |
MapContextManager mapContextManager |
190 |
= MapContextLocator.getMapContextManager();
|
|
182 |
= MapContextLocator.getMapContextManager(); |
|
191 | 183 |
|
192 | 184 |
//Set the legend |
193 | 185 |
IVectorLegend legend |
194 |
= (IVectorLegend) mapContextManager.getLegend(dataStore);
|
|
186 |
= (IVectorLegend) mapContextManager.getLegend(dataStore); |
|
195 | 187 |
|
196 |
if (legend == null) {
|
|
188 |
if( legend == null ) {
|
|
197 | 189 |
throw new LegendLayerException(this.getName()); |
198 | 190 |
} |
199 | 191 |
|
... | ... | |
201 | 193 |
|
202 | 194 |
//Set the labeling strategy |
203 | 195 |
ILabelingStrategy labeler |
204 |
= (ILabelingStrategy) mapContextManager.getLabelingStrategy(dataStore);
|
|
196 |
= (ILabelingStrategy) mapContextManager.getLabelingStrategy(dataStore); |
|
205 | 197 |
|
206 |
if (labeler != null) {
|
|
198 |
if( labeler != null ) {
|
|
207 | 199 |
labeler.setLayer(this); |
208 | 200 |
this.setLabelingStrategy(labeler); |
209 | 201 |
this.setIsLabeled(true); // TODO: ac? no s'hauria de detectar si t? |
... | ... | |
219 | 211 |
|
220 | 212 |
public Envelope getFullEnvelope() throws ReadException { |
221 | 213 |
Envelope rAux; |
214 |
if( getFeatureStore() == null ) { |
|
215 |
return null; |
|
216 |
} |
|
222 | 217 |
try { |
223 | 218 |
rAux = getFeatureStore().getEnvelope(); |
224 | 219 |
} catch (BaseException e) { |
... | ... | |
227 | 222 |
|
228 | 223 |
// Esto es para cuando se crea una capa nueva con el fullExtent de ancho |
229 | 224 |
// y alto 0. |
230 |
if (rAux == null || rAux.isEmpty() || rAux.getMaximum(0) - rAux.getMinimum(0) == 0
|
|
231 |
&& rAux.getMaximum(1) - rAux.getMinimum(1) == 0) {
|
|
225 |
if( rAux == null || rAux.isEmpty() || rAux.getMaximum(0) - rAux.getMinimum(0) == 0
|
|
226 |
&& rAux.getMaximum(1) - rAux.getMinimum(1) == 0 ) {
|
|
232 | 227 |
try { |
233 | 228 |
rAux |
234 |
= geomManager.createEnvelope(0, 0, 90, 90, SUBTYPES.GEOM2D);
|
|
229 |
= geomManager.createEnvelope(0, 0, 90, 90, SUBTYPES.GEOM2D); |
|
235 | 230 |
} catch (CreateEnvelopeException e) { |
236 | 231 |
logger.error("Error creating the envelope", e); |
237 | 232 |
e.printStackTrace(); |
... | ... | |
239 | 234 |
} |
240 | 235 |
// Si existe reproyecci?n, reproyectar el extent |
241 | 236 |
ICoordTrans ct = getCoordTrans(); |
242 |
if (ct != null) {
|
|
237 |
if( ct != null ) {
|
|
243 | 238 |
boolean originalEnvelopeIsEmpty = rAux.isEmpty(); |
244 | 239 |
rAux = rAux.convert(ct); |
245 |
if(!originalEnvelopeIsEmpty && rAux.isEmpty()){
|
|
240 |
if( !originalEnvelopeIsEmpty && rAux.isEmpty() ) {
|
|
246 | 241 |
try { |
247 | 242 |
this.setAvailable(false); |
248 | 243 |
throw new EnvelopeCantBeInitializedException(); |
249 |
} catch(EnvelopeCantBeInitializedException e){
|
|
244 |
} catch (EnvelopeCantBeInitializedException e) {
|
|
250 | 245 |
this.addError(e); |
251 | 246 |
} |
252 | 247 |
} |
... | ... | |
273 | 268 |
|
274 | 269 |
public void addBaseFilter(String filter) { |
275 | 270 |
try { |
276 |
this.addBaseFilter( DALLocator.getDataManager().createExpresion(filter));
|
|
271 |
this.addBaseFilter(DALLocator.getDataManager().createExpresion(filter)); |
|
277 | 272 |
} catch (InitializeException ex) { |
278 |
throw new RuntimeException("Can't create filter with '"+filter+"'", ex);
|
|
273 |
throw new RuntimeException("Can't create filter with '" + filter + "'", ex);
|
|
279 | 274 |
} |
280 | 275 |
} |
281 | 276 |
|
... | ... | |
292 | 287 |
* @throws ReadDriverException |
293 | 288 |
*/ |
294 | 289 |
public void draw(BufferedImage image, |
295 |
Graphics2D g,
|
|
296 |
ViewPort viewPort,
|
|
297 |
Cancellable cancel,
|
|
298 |
double scale) throws ReadException {
|
|
290 |
Graphics2D g, |
|
291 |
ViewPort viewPort, |
|
292 |
Cancellable cancel, |
|
293 |
double scale) throws ReadException { |
|
299 | 294 |
|
300 |
if (legend == null) {
|
|
295 |
if( legend == null ) {
|
|
301 | 296 |
return; |
302 | 297 |
} |
303 | 298 |
|
304 |
if (!this.isWithinScale(scale)) {
|
|
299 |
if( !this.isWithinScale(scale) ) {
|
|
305 | 300 |
return; |
306 | 301 |
} |
307 |
if (cancel.isCanceled()) {
|
|
302 |
if( cancel.isCanceled() ) {
|
|
308 | 303 |
return; |
309 | 304 |
} |
310 | 305 |
|
311 |
if (spatialCache.isEnabled()) {
|
|
306 |
if( spatialCache.isEnabled() ) {
|
|
312 | 307 |
spatialCache.clearAll(); |
313 | 308 |
legend.addDrawingObserver(this); |
314 | 309 |
} |
... | ... | |
317 | 312 |
|
318 | 313 |
try { |
319 | 314 |
FeatureAttributeDescriptor featureAttributeDescriptor |
320 |
= getFeatureStore().getDefaultFeatureType().getDefaultTimeAttribute();
|
|
315 |
= getFeatureStore().getDefaultFeatureType().getDefaultTimeAttribute(); |
|
321 | 316 |
|
322 |
if ((viewPort.getTime() != null) && (featureAttributeDescriptor != null)) {
|
|
317 |
if( (viewPort.getTime() != null) && (featureAttributeDescriptor != null) ) {
|
|
323 | 318 |
IntersectsTimeEvaluator intersectsTimeEvaluator |
324 |
= new IntersectsTimeEvaluator(viewPort.getTime(), featureAttributeDescriptor.getName());
|
|
319 |
= new IntersectsTimeEvaluator(viewPort.getTime(), featureAttributeDescriptor.getName()); |
|
325 | 320 |
featureQuery.addFilter(intersectsTimeEvaluator); |
326 | 321 |
} |
327 | 322 |
} catch (DataException e1) { |
... | ... | |
333 | 328 |
long tini = System.currentTimeMillis(); |
334 | 329 |
|
335 | 330 |
legend.draw(image, |
336 |
g,
|
|
337 |
viewPort,
|
|
338 |
cancel,
|
|
339 |
scale,
|
|
340 |
null,
|
|
341 |
getCoordTrans(),
|
|
342 |
getFeatureStore(),
|
|
343 |
featureQuery);
|
|
331 |
g, |
|
332 |
viewPort, |
|
333 |
cancel, |
|
334 |
scale, |
|
335 |
null, |
|
336 |
getCoordTrans(), |
|
337 |
getFeatureStore(), |
|
338 |
featureQuery); |
|
344 | 339 |
|
345 | 340 |
logger.debug("Layer " + this.getName() + " drawn in " |
346 |
+ (System.currentTimeMillis() - tini) + " milliseconds.");
|
|
341 |
+ (System.currentTimeMillis() - tini) + " milliseconds."); |
|
347 | 342 |
|
348 | 343 |
} catch (LegendException e) { |
349 | 344 |
this.setAvailable(false); |
350 | 345 |
this.setError(e); |
351 | 346 |
throw new ReadException(getName(), e); |
352 | 347 |
} finally { |
353 |
if (spatialCache.isEnabled()) {
|
|
348 |
if( spatialCache.isEnabled() ) {
|
|
354 | 349 |
legend.deleteDrawingObserver(this); |
355 | 350 |
} |
356 | 351 |
} |
357 | 352 |
} |
358 | 353 |
|
359 | 354 |
public void print(Graphics2D g, |
360 |
ViewPort viewPort,
|
|
361 |
Cancellable cancel,
|
|
362 |
double scale,
|
|
363 |
PrintAttributes properties) throws ReadException {
|
|
364 |
if (!this.isWithinScale(scale)) {
|
|
355 |
ViewPort viewPort, |
|
356 |
Cancellable cancel, |
|
357 |
double scale, |
|
358 |
PrintAttributes properties) throws ReadException { |
|
359 |
if( !this.isWithinScale(scale) ) {
|
|
365 | 360 |
return; |
366 | 361 |
} |
367 |
if (cancel.isCanceled()) {
|
|
362 |
if( cancel.isCanceled() ) {
|
|
368 | 363 |
return; |
369 | 364 |
} |
370 | 365 |
FeatureQuery featureQuery = createFeatureQuery(); |
371 | 366 |
|
372 | 367 |
try { |
373 | 368 |
legend.print(g, |
374 |
viewPort,
|
|
375 |
cancel,
|
|
376 |
scale,
|
|
377 |
null,
|
|
378 |
getCoordTrans(),
|
|
379 |
getFeatureStore(),
|
|
380 |
featureQuery,
|
|
381 |
properties);
|
|
369 |
viewPort, |
|
370 |
cancel, |
|
371 |
scale, |
|
372 |
null, |
|
373 |
getCoordTrans(), |
|
374 |
getFeatureStore(), |
|
375 |
featureQuery, |
|
376 |
properties); |
|
382 | 377 |
|
383 | 378 |
} catch (LegendException e) { |
384 | 379 |
this.setVisible(false); |
... | ... | |
388 | 383 |
} |
389 | 384 |
|
390 | 385 |
public void setLegend(IVectorLegend legend) throws LegendLayerException { |
391 |
if (this.legend == legend) {
|
|
386 |
if( this.legend == legend ) {
|
|
392 | 387 |
return; |
393 | 388 |
} |
394 |
if (this.legend != null && this.legend.equals(legend)) {
|
|
389 |
if( this.legend != null && this.legend.equals(legend) ) {
|
|
395 | 390 |
return; |
396 | 391 |
} |
397 | 392 |
IVectorLegend oldLegend = this.legend; |
398 | 393 |
this.legend = legend; |
399 |
if (oldLegend != null) {
|
|
394 |
if( oldLegend != null ) {
|
|
400 | 395 |
oldLegend.removeLegendListener(this); |
401 | 396 |
oldLegend.deleteDrawingObserver(this); |
402 | 397 |
} |
403 |
if (legend != null) {
|
|
398 |
if( legend != null ) {
|
|
404 | 399 |
this.legend.addDrawingObserver(this); |
405 | 400 |
this.legend.addLegendListener(this); |
406 | 401 |
} |
... | ... | |
420 | 415 |
} |
421 | 416 |
|
422 | 417 |
public int getShapeType() throws ReadException { |
423 |
if (typeShape == -1) {
|
|
418 |
if( typeShape == -1 ) {
|
|
424 | 419 |
FeatureType featureType = null; |
425 | 420 |
try { |
426 |
if (getDataStore() != null) {
|
|
421 |
if( getDataStore() != null ) {
|
|
427 | 422 |
featureType |
428 |
= (((FeatureStore) getDataStore()).getDefaultFeatureType());
|
|
423 |
= (((FeatureStore) getDataStore()).getDefaultFeatureType()); |
|
429 | 424 |
} |
430 | 425 |
} catch (DataException e) { |
431 | 426 |
throw new ReadException(getName(), e); |
432 | 427 |
} |
433 |
if (featureType != null) {
|
|
428 |
if( featureType != null ) {
|
|
434 | 429 |
int indexGeom = featureType.getDefaultGeometryAttributeIndex(); |
435 | 430 |
typeShape |
436 |
= featureType.getAttributeDescriptor(indexGeom).getGeometryType();
|
|
431 |
= featureType.getAttributeDescriptor(indexGeom).getGeometryType(); |
|
437 | 432 |
} |
438 | 433 |
} |
439 | 434 |
return typeShape; |
... | ... | |
449 | 444 |
public GeometryType getGeometryType() throws ReadException { |
450 | 445 |
FeatureType featureType = null; |
451 | 446 |
try { |
452 |
if (getDataStore() != null) {
|
|
447 |
if( getDataStore() != null ) {
|
|
453 | 448 |
featureType |
454 |
= (((FeatureStore) getDataStore()).getDefaultFeatureType());
|
|
449 |
= (((FeatureStore) getDataStore()).getDefaultFeatureType()); |
|
455 | 450 |
} |
456 | 451 |
} catch (DataException e) { |
457 | 452 |
throw new ReadException(getName(), e); |
458 | 453 |
} |
459 | 454 |
return featureType == null ? null : featureType |
460 |
.getDefaultGeometryAttribute().getGeomType();
|
|
455 |
.getDefaultGeometryAttribute().getGeomType(); |
|
461 | 456 |
} |
462 | 457 |
|
463 | 458 |
public void saveToState(PersistentState state) throws PersistenceException { |
464 | 459 |
|
465 | 460 |
FeatureStore featureStore = null; |
466 | 461 |
|
467 |
if (!this.isAvailable()) {
|
|
462 |
if( !this.isAvailable() ) {
|
|
468 | 463 |
logger.info("The '" + this.getName() + "' layer is not available, it will persist not."); |
469 | 464 |
return; |
470 | 465 |
} |
... | ... | |
472 | 467 |
try { |
473 | 468 |
super.saveToState(state); |
474 | 469 |
|
475 |
if (getLegend() != null) {
|
|
470 |
if( getLegend() != null ) {
|
|
476 | 471 |
state.set("legend", getLegend()); |
477 | 472 |
} |
478 | 473 |
|
479 | 474 |
featureStore = getFeatureStore(); |
480 | 475 |
|
481 |
if (featureStore != null) {
|
|
476 |
if( featureStore != null ) {
|
|
482 | 477 |
state.set("featureStore", featureStore); |
483 | 478 |
} |
484 | 479 |
|
485 | 480 |
state.set("isLabeled", isLabeled); |
486 | 481 |
|
487 |
if (strategy != null) {
|
|
482 |
if( strategy != null ) {
|
|
488 | 483 |
state.set("labelingStrategy", strategy); |
489 | 484 |
} |
490 | 485 |
|
491 |
if (getLinkProperties() != null) {
|
|
486 |
if( getLinkProperties() != null ) {
|
|
492 | 487 |
state.set("linkProperties", getLinkProperties()); |
493 | 488 |
} |
494 | 489 |
|
... | ... | |
503 | 498 |
|
504 | 499 |
} |
505 | 500 |
|
501 |
@Override |
|
506 | 502 |
public void loadFromState(PersistentState state) throws PersistenceException { |
507 | 503 |
|
508 |
DataStore store = null; |
|
509 |
IVectorLegend vectorLegend = null; |
|
510 |
ILabelingStrategy labelingStrategy = null; |
|
511 |
Boolean isLabeled = Boolean.FALSE; |
|
512 |
|
|
504 |
FeatureStore store = null; |
|
513 | 505 |
try { |
514 | 506 |
super.loadFromState(state); |
515 |
store = (DataStore) state.get("featureStore"); |
|
516 | 507 |
|
508 |
this.setIsLabeled(false); |
|
509 |
this.setLabelingStrategy(null); |
|
510 |
|
|
511 |
typeShape = state.getInt("typeShape", Geometry.TYPES.GEOMETRY); |
|
512 |
|
|
513 |
store = (FeatureStore) state.get("featureStore"); |
|
514 |
if( store == null ) { // Averiguar como puede llegar aqui un null. |
|
515 |
this.setAvailable(false); |
|
516 |
this.addError(new RuntimeException("Can't retrieve store information.")); |
|
517 |
} else { |
|
518 |
if( store.isBroken() ) { |
|
519 |
this.setAvailable(false); |
|
520 |
this.addError(store.getBreakingsCause()); |
|
521 |
} |
|
522 |
} |
|
517 | 523 |
try { |
518 | 524 |
this.bindToDataStore(store); |
519 |
} catch (LoadLayerException e) { |
|
520 |
throw new PersistenceException("Can't bind layer '" + this.getName() + "' to store '" + store.getFullName() + "'.", e); |
|
525 |
} catch (Exception ex) { |
|
526 |
this.setAvailable(false); |
|
527 |
this.addError(ex); |
|
521 | 528 |
} |
522 | 529 |
|
523 |
vectorLegend = (IVectorLegend) state.get("legend"); |
|
524 |
|
|
525 | 530 |
try { |
531 |
IVectorLegend vectorLegend = (IVectorLegend) state.get("legend"); |
|
526 | 532 |
this.setLegend(vectorLegend); |
527 |
} catch (LegendLayerException e) { |
|
528 |
throw new PersistenceException("Can't set vector legend to the layer.", e); |
|
533 |
} catch (Exception ex) { |
|
534 |
this.setAvailable(false); |
|
535 |
this.addError(ex); |
|
529 | 536 |
} |
530 | 537 |
|
531 | 538 |
try { |
532 |
isLabeled = (Boolean) state.get("isLabeled"); |
|
533 |
if (isLabeled.booleanValue()) { |
|
534 |
labelingStrategy = (ILabelingStrategy) state.get("labelingStrategy"); |
|
539 |
if( state.getBoolean("isLabeled", false) ) { |
|
540 |
this.setIsLabeled(true); |
|
541 |
ILabelingStrategy labelingStrategy = (ILabelingStrategy) state.get("labelingStrategy"); |
|
542 |
this.setLabelingStrategy(labelingStrategy); |
|
535 | 543 |
} |
536 | 544 |
} catch (Exception ex) { |
537 |
throw new PersistenceException("Can't load labeling strategi from persistent state.",
|
|
538 |
ex);
|
|
545 |
this.setAvailable(false);
|
|
546 |
this.addError(ex);
|
|
539 | 547 |
} |
540 | 548 |
|
541 |
if (isLabeled.booleanValue()) { |
|
542 |
this.setIsLabeled(true); |
|
543 |
this.setLabelingStrategy(labelingStrategy); |
|
544 |
} else { |
|
545 |
this.setIsLabeled(false); |
|
546 |
this.setLabelingStrategy(null); |
|
547 |
} |
|
548 |
|
|
549 |
typeShape = state.getInt("typeShape"); |
|
550 |
|
|
551 | 549 |
} catch (Throwable e) { |
552 | 550 |
String storeName = (store == null) ? "unknow" : store.getFullName(); |
553 | 551 |
logger.warn("can't load layer '" + this.getName() + "' (store=" + storeName + ") from persisted state.", e); |
554 | 552 |
this.setAvailable(false); |
555 |
return;
|
|
553 |
this.addError(e);
|
|
556 | 554 |
} |
557 | 555 |
|
558 | 556 |
} |
... | ... | |
570 | 568 |
*/ |
571 | 569 |
String ret = super.toString(); |
572 | 570 |
|
573 |
return ret ; //"layer" + ret.substring(ret.indexOf('@') + 1);
|
|
571 |
return ret; //"layer" + ret.substring(ret.indexOf('@') + 1); |
|
574 | 572 |
} |
575 | 573 |
|
576 | 574 |
public boolean isEditing() { |
577 | 575 |
FeatureStore fs = getFeatureStore(); |
578 |
if (fs == null) {
|
|
576 |
if( fs == null ) {
|
|
579 | 577 |
/* |
580 | 578 |
* This happens when layer is not available, for example, |
581 | 579 |
* it was not possible to load from persistence |
... | ... | |
594 | 592 |
logger.info("This method is deprecated. ", th); |
595 | 593 |
} |
596 | 594 |
|
597 |
if (b == super.isEditing()) {
|
|
595 |
if( b == super.isEditing() ) {
|
|
598 | 596 |
return; |
599 | 597 |
} |
600 | 598 |
|
601 | 599 |
super.setEditing(b); |
602 | 600 |
FeatureStore fs = getFeatureStore(); |
603 |
if (b) {
|
|
601 |
if( b ) {
|
|
604 | 602 |
try { |
605 | 603 |
fs.edit(); |
606 | 604 |
} catch (DataException e) { |
... | ... | |
642 | 640 |
* @param maxFeatures |
643 | 641 |
*/ |
644 | 642 |
public void setMaxFeaturesInEditionCache(int maxFeatures) { |
645 |
if (maxFeatures > spatialCache.getMaxFeatures()) {
|
|
643 |
if( maxFeatures > spatialCache.getMaxFeatures() ) {
|
|
646 | 644 |
spatialCache.setMaxFeatures(maxFeatures); |
647 | 645 |
} |
648 | 646 |
|
... | ... | |
688 | 686 |
} |
689 | 687 |
|
690 | 688 |
protected void putLoadLegend() throws LegendLayerException { |
691 |
if (this.loadLegend == null) {
|
|
689 |
if( this.loadLegend == null ) {
|
|
692 | 690 |
return; |
693 | 691 |
} |
694 | 692 |
this.setLegend(this.loadLegend); |
... | ... | |
718 | 716 |
|
719 | 717 |
clonedLayer.setIsLabeled(isLabeled()); |
720 | 718 |
ILabelingStrategy labelingStrategy = getLabelingStrategy(); |
721 |
if (labelingStrategy != null) {
|
|
719 |
if( labelingStrategy != null ) {
|
|
722 | 720 |
clonedLayer.setLabelingStrategy(labelingStrategy); |
723 | 721 |
} |
724 | 722 |
|
... | ... | |
726 | 724 |
} |
727 | 725 |
|
728 | 726 |
protected boolean isOnePoint(AffineTransform graphicsTransform, |
729 |
ViewPort viewPort,
|
|
730 |
double dpi,
|
|
731 |
CartographicSupport csSym,
|
|
732 |
Geometry geom,
|
|
733 |
int[] xyCoords) {
|
|
727 |
ViewPort viewPort, |
|
728 |
double dpi, |
|
729 |
CartographicSupport csSym, |
|
730 |
Geometry geom, |
|
731 |
int[] xyCoords) { |
|
734 | 732 |
return isOnePoint(graphicsTransform, viewPort, geom, xyCoords) |
735 |
&& csSym.getCartographicSize(viewPort, dpi, geom) <= 1;
|
|
733 |
&& csSym.getCartographicSize(viewPort, dpi, geom) <= 1; |
|
736 | 734 |
} |
737 | 735 |
|
738 | 736 |
private boolean isOnePoint(AffineTransform graphicsTransform, |
739 |
ViewPort viewPort,
|
|
740 |
Geometry geom,
|
|
741 |
int[] xyCoords) {
|
|
737 |
ViewPort viewPort, |
|
738 |
Geometry geom, |
|
739 |
int[] xyCoords) { |
|
742 | 740 |
boolean onePoint = false; |
743 | 741 |
int type = geom.getType(); |
744 |
if (type == Geometry.TYPES.NULL) {
|
|
742 |
if( type == Geometry.TYPES.NULL ) {
|
|
745 | 743 |
return false; |
746 | 744 |
} |
747 |
if (type != Geometry.TYPES.POINT && type != Geometry.TYPES.MULTIPOINT) {
|
|
745 |
if( type != Geometry.TYPES.POINT && type != Geometry.TYPES.MULTIPOINT ) {
|
|
748 | 746 |
|
749 | 747 |
Envelope geomBounds = geom.getEnvelope(); |
750 | 748 |
|
... | ... | |
757 | 755 |
double dist1Pixel = viewPort.getDist1pixel(); |
758 | 756 |
|
759 | 757 |
onePoint |
760 |
= (geomBounds.getLength(0) <= dist1Pixel && geomBounds.getLength(1) <= dist1Pixel);
|
|
758 |
= (geomBounds.getLength(0) <= dist1Pixel && geomBounds.getLength(1) <= dist1Pixel); |
|
761 | 759 |
|
762 |
if (onePoint) {
|
|
760 |
if( onePoint ) {
|
|
763 | 761 |
// avoid out of range exceptions |
764 | 762 |
org.gvsig.fmap.geom.primitive.Point p; |
765 | 763 |
try { |
766 | 764 |
p |
767 |
= geomManager.createPoint(geomBounds.getMinimum(0),
|
|
768 |
geomBounds.getMinimum(1),
|
|
769 |
SUBTYPES.GEOM2D);
|
|
765 |
= geomManager.createPoint(geomBounds.getMinimum(0), |
|
766 |
geomBounds.getMinimum(1), |
|
767 |
SUBTYPES.GEOM2D); |
|
770 | 768 |
p.transform(viewPort.getAffineTransform()); |
771 | 769 |
p.transform(graphicsTransform); |
772 | 770 |
xyCoords[0] = (int) p.getX(); |
... | ... | |
795 | 793 |
|
796 | 794 |
public void setLabelingStrategy(ILabelingStrategy strategy) { |
797 | 795 |
this.strategy = strategy; |
798 |
if (strategy == null) {
|
|
796 |
if( strategy == null ) {
|
|
799 | 797 |
return; |
800 | 798 |
} |
801 | 799 |
strategy.setLayer(this); |
... | ... | |
803 | 801 |
} |
804 | 802 |
|
805 | 803 |
public void drawLabels(BufferedImage image, |
806 |
Graphics2D g,
|
|
807 |
ViewPort viewPort,
|
|
808 |
Cancellable cancel,
|
|
809 |
double scale,
|
|
810 |
double dpi) throws ReadException {
|
|
811 |
if (strategy != null && isWithinScale(scale)) {
|
|
804 |
Graphics2D g, |
|
805 |
ViewPort viewPort, |
|
806 |
Cancellable cancel, |
|
807 |
double scale, |
|
808 |
double dpi) throws ReadException { |
|
809 |
if( strategy != null && isWithinScale(scale) ) {
|
|
812 | 810 |
strategy.draw(image, g, scale, viewPort, cancel, dpi); |
813 | 811 |
} |
814 | 812 |
} |
815 | 813 |
|
816 | 814 |
public void printLabels(Graphics2D g, |
817 |
ViewPort viewPort,
|
|
818 |
Cancellable cancel,
|
|
819 |
double scale,
|
|
820 |
PrintAttributes properties) throws ReadException {
|
|
821 |
if (strategy != null) {
|
|
815 |
ViewPort viewPort, |
|
816 |
Cancellable cancel, |
|
817 |
double scale, |
|
818 |
PrintAttributes properties) throws ReadException { |
|
819 |
if( strategy != null ) {
|
|
822 | 820 |
strategy.print(g, scale, viewPort, cancel, properties); |
823 | 821 |
} |
824 | 822 |
} |
... | ... | |
841 | 839 |
} |
842 | 840 |
|
843 | 841 |
public FeatureQuery createFeatureQuery() { |
844 |
if( this.baseQuery==null ) {
|
|
842 |
if( this.baseQuery == null ) {
|
|
845 | 843 |
return this.getFeatureStore().createFeatureQuery(); |
846 | 844 |
} |
847 | 845 |
try { |
... | ... | |
856 | 854 |
* {@link #queryByPoint(org.gvsig.fmap.geom.primitive.Point, double, FeatureType)} |
857 | 855 |
*/ |
858 | 856 |
public FeatureSet queryByPoint(Point2D mapPoint, |
859 |
double tol,
|
|
860 |
FeatureType featureType) throws DataException {
|
|
857 |
double tol, |
|
858 |
FeatureType featureType) throws DataException { |
|
861 | 859 |
logger.warn("Deprecated use of queryByPoint."); |
862 | 860 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
863 | 861 |
org.gvsig.fmap.geom.primitive.Point center; |
864 | 862 |
try { |
865 | 863 |
center |
866 |
= (org.gvsig.fmap.geom.primitive.Point) manager.create(TYPES.POINT,
|
|
867 |
SUBTYPES.GEOM2D);
|
|
864 |
= (org.gvsig.fmap.geom.primitive.Point) manager.create(TYPES.POINT, |
|
865 |
SUBTYPES.GEOM2D); |
|
868 | 866 |
center.setX(mapPoint.getX()); |
869 | 867 |
center.setY(mapPoint.getY()); |
870 | 868 |
Circle circle |
871 |
= (Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
|
|
869 |
= (Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
872 | 870 |
circle.setPoints(center, tol); |
873 | 871 |
return queryByGeometry(circle, featureType); |
874 | 872 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) { |
... | ... | |
877 | 875 |
} |
878 | 876 |
|
879 | 877 |
public FeatureSet queryByPoint(org.gvsig.fmap.geom.primitive.Point point, |
880 |
double tol,
|
|
881 |
FeatureType featureType) throws DataException {
|
|
878 |
double tol, |
|
879 |
FeatureType featureType) throws DataException { |
|
882 | 880 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
883 | 881 |
try { |
884 | 882 |
Circle circle |
885 |
= (Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
|
|
883 |
= (Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
886 | 884 |
circle.setPoints(point, tol); |
887 | 885 |
return queryByGeometry(circle, featureType); |
888 | 886 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) { |
... | ... | |
904 | 902 |
|
905 | 903 |
Geometry query_geo = this.transformToSourceCRS(geom, true); |
906 | 904 |
IProjection query_proj = getMapContext().getProjection(); |
907 |
if (this.getCoordTrans() != null) {
|
|
905 |
if( this.getCoordTrans() != null ) {
|
|
908 | 906 |
query_proj = this.getCoordTrans().getPOrig(); |
909 | 907 |
} |
910 | 908 |
Evaluator iee = SpatialEvaluatorsFactory.getInstance().intersects( |
... | ... | |
943 | 941 |
* @throws DataException |
944 | 942 |
*/ |
945 | 943 |
public FeatureSet queryByEnvelope(Envelope envelope, |
946 |
FeatureType featureType,
|
|
947 |
String[] names) throws DataException {
|
|
944 |
FeatureType featureType, |
|
945 |
String[] names) throws DataException { |
|
948 | 946 |
FeatureQuery featureQuery = createFeatureQuery(); |
949 |
if (names == null) {
|
|
947 |
if( names == null ) {
|
|
950 | 948 |
featureQuery.setFeatureType(featureType); |
951 | 949 |
} else { |
952 | 950 |
featureQuery.setAttributeNames(names); |
... | ... | |
955 | 953 |
|
956 | 954 |
Envelope query_env = fromViewPortCRSToSourceCRS(this, envelope); |
957 | 955 |
IProjection query_proj = getMapContext().getProjection(); |
958 |
if (this.getCoordTrans() != null) {
|
|
956 |
if( this.getCoordTrans() != null ) {
|
|
959 | 957 |
query_proj = this.getCoordTrans().getPOrig(); |
960 | 958 |
} |
961 | 959 |
|
962 | 960 |
Evaluator iee = SpatialEvaluatorsFactory.getInstance().intersects( |
963 |
query_env.getGeometry(),
|
|
964 |
query_proj,
|
|
965 |
featureStore
|
|
961 |
query_env.getGeometry(),
|
|
962 |
query_proj,
|
|
963 |
featureStore |
|
966 | 964 |
); |
967 | 965 |
featureQuery.setFilter(iee); |
968 | 966 |
return getFeatureStore().getFeatureSet(featureQuery); |
... | ... | |
970 | 968 |
} |
971 | 969 |
|
972 | 970 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel) throws LoadLayerException, |
973 |
DataException {
|
|
971 |
DataException { |
|
974 | 972 |
|
975 | 973 |
return getInfo(p, tolerance, cancel, true); |
976 | 974 |
} |
977 | 975 |
|
978 | 976 |
public DynObjectSet getInfo(Point p, |
979 |
double tolerance,
|
|
980 |
Cancellable cancel,
|
|
981 |
boolean fast) throws LoadLayerException, DataException {
|
|
977 |
double tolerance, |
|
978 |
Cancellable cancel, |
|
979 |
boolean fast) throws LoadLayerException, DataException { |
|
982 | 980 |
Point2D infop = new Point2D.Double(p.x, p.y); |
983 | 981 |
Point2D pReal = this.getMapContext().getViewPort().toMapPoint(infop); |
984 | 982 |
return queryByPoint(pReal, |
985 |
tolerance,
|
|
986 |
getFeatureStore().getDefaultFeatureType()).getDynObjectSet(fast);
|
|
983 |
tolerance, |
|
984 |
getFeatureStore().getDefaultFeatureType()).getDynObjectSet(fast); |
|
987 | 985 |
} |
988 | 986 |
|
989 | 987 |
public DynObjectSet getInfo(org.gvsig.fmap.geom.primitive.Point p, |
990 |
double tolerance) throws LoadLayerException, DataException {
|
|
988 |
double tolerance) throws LoadLayerException, DataException { |
|
991 | 989 |
return queryByPoint(p, tolerance, getFeatureStore().getDefaultFeatureType()).getDynObjectSet(false); |
992 | 990 |
} |
993 | 991 |
|
994 | 992 |
@Override |
995 | 993 |
public void legendCleared(LegendClearEvent event) { |
996 | 994 |
this.updateDrawVersion(); |
997 |
LegendChangedEvent e = LegendChangedEvent.createLegendChangedEvent(legend,event); |
|
995 |
LegendChangedEvent e = LegendChangedEvent.createLegendChangedEvent(legend, event);
|
|
998 | 996 |
this.callLegendChanged(e); |
999 | 997 |
} |
1000 | 998 |
|
... | ... | |
1007 | 1005 |
} |
1008 | 1006 |
|
1009 | 1007 |
public void update(Observable observable, Object notification) { |
1010 |
if (observable.equals(this.featureStore)) {
|
|
1011 |
if (notification instanceof FeatureStoreNotification) {
|
|
1008 |
if( observable.equals(this.featureStore) ) {
|
|
1009 |
if( notification instanceof FeatureStoreNotification ) {
|
|
1012 | 1010 |
FeatureStoreNotification event |
1013 |
= (FeatureStoreNotification) notification;
|
|
1014 |
if (event.getType() == FeatureStoreNotification.AFTER_DELETE
|
|
1015 |
|| event.getType() == FeatureStoreNotification.AFTER_UNDO
|
|
1016 |
|| event.getType() == FeatureStoreNotification.AFTER_REDO
|
|
1017 |
|| event.getType() == FeatureStoreNotification.AFTER_REFRESH
|
|
1018 |
|| event.getType() == FeatureStoreNotification.AFTER_UPDATE
|
|
1019 |
|| event.getType() == FeatureStoreNotification.AFTER_UPDATE_TYPE
|
|
1020 |
|| event.getType() == FeatureStoreNotification.SELECTION_CHANGE
|
|
1021 |
|| event.getType() == FeatureStoreNotification.AFTER_INSERT) {
|
|
1011 |
= (FeatureStoreNotification) notification; |
|
1012 |
if( event.getType() == FeatureStoreNotification.AFTER_DELETE
|
|
1013 |
|| event.getType() == FeatureStoreNotification.AFTER_UNDO |
|
1014 |
|| event.getType() == FeatureStoreNotification.AFTER_REDO |
|
1015 |
|| event.getType() == FeatureStoreNotification.AFTER_REFRESH |
|
1016 |
|| event.getType() == FeatureStoreNotification.AFTER_UPDATE |
|
1017 |
|| event.getType() == FeatureStoreNotification.AFTER_UPDATE_TYPE |
|
1018 |
|| event.getType() == FeatureStoreNotification.SELECTION_CHANGE |
|
1019 |
|| event.getType() == FeatureStoreNotification.AFTER_INSERT ) {
|
|
1022 | 1020 |
this.updateDrawVersion(); |
1023 | 1021 |
|
1024 |
} else if (event.getType() == FeatureStoreNotification.AFTER_CANCELEDITING) {
|
|
1022 |
} else if( event.getType() == FeatureStoreNotification.AFTER_CANCELEDITING ) {
|
|
1025 | 1023 |
|
1026 | 1024 |
setSpatialCacheEnabled(false); |
1027 | 1025 |
callEditionChanged(LayerEvent.createEditionChangedEvent(this, "edition")); |
1028 | 1026 |
this.updateDrawVersion(); |
1029 | 1027 |
|
1030 |
} else if (event.getType() == FeatureStoreNotification.AFTER_STARTEDITING) {
|
|
1028 |
} else if( event.getType() == FeatureStoreNotification.AFTER_STARTEDITING ) {
|
|
1031 | 1029 |
|
1032 | 1030 |
setSpatialCacheEnabled(true); |
1033 | 1031 |
callEditionChanged(LayerEvent.createEditionChangedEvent(this, "edition")); |
1034 | 1032 |
|
1035 |
} else if (event.getType() == FeatureStoreNotification.TRANSFORM_CHANGE) {
|
|
1033 |
} else if( event.getType() == FeatureStoreNotification.TRANSFORM_CHANGE ) {
|
|
1036 | 1034 |
//If a transform has to be applied, try to reload the layer. |
1037 | 1035 |
try { |
1038 | 1036 |
reload(); |
... | ... | |
1040 | 1038 |
logger.info("While reloading layer.", e); |
1041 | 1039 |
this.setAvailable(false); |
1042 | 1040 |
} |
1043 |
} else if (event.getType() == FeatureStoreNotification.RESOURCE_CHANGED) {
|
|
1041 |
} else if( event.getType() == FeatureStoreNotification.RESOURCE_CHANGED ) {
|
|
1044 | 1042 |
this.setAvailable(false); |
1045 |
} else if (event.getType() == FeatureStoreNotification.AFTER_FINISHEDITING) {
|
|
1043 |
} else if( event.getType() == FeatureStoreNotification.AFTER_FINISHEDITING ) {
|
|
1046 | 1044 |
this.setAvailable(true); |
1047 | 1045 |
setSpatialCacheEnabled(false); |
1048 | 1046 |
callEditionChanged(LayerEvent.createEditionChangedEvent(this, "edition")); |
1049 | 1047 |
this.updateDrawVersion(); |
1050 | 1048 |
} |
1051 | 1049 |
} |
1052 |
} else if (notification instanceof FeatureDrawnNotification
|
|
1053 |
&& (isEditing() || isLayerToSnap())) {
|
|
1050 |
} else if( notification instanceof FeatureDrawnNotification
|
|
1051 |
&& (isEditing() || isLayerToSnap()) ) {
|
|
1054 | 1052 |
// This code is needed in editing mode |
1055 | 1053 |
// for all layers involved in snapping |
1056 | 1054 |
// (including the layer being edited) |
1057 | 1055 |
Geometry geometry |
1058 |
= ((FeatureDrawnNotification) notification).getDrawnGeometry();
|
|
1056 |
= ((FeatureDrawnNotification) notification).getDrawnGeometry(); |
|
1059 | 1057 |
spatialCache.insert(geometry.getEnvelope(), geometry); |
1060 | 1058 |
} |
1061 | 1059 |
} |
1062 | 1060 |
|
1063 | 1061 |
private boolean isLayerToSnap() { |
1064 | 1062 |
|
1065 |
if (this.getMapContext() == null) {
|
|
1063 |
if( this.getMapContext() == null ) {
|
|
1066 | 1064 |
/* |
1067 | 1065 |
* This happens with the graphics layer because it has no parent |
1068 | 1066 |
*/ |
... | ... | |
1102 | 1100 |
*/ |
1103 | 1101 |
public Object getMetadataID() throws MetadataException { |
1104 | 1102 |
return "Layer(" + this.getName() + "):" |
1105 |
+ this.featureStore.getMetadataID();
|
|
1103 |
+ this.featureStore.getMetadataID(); |
|
1106 | 1104 |
} |
1107 | 1105 |
|
1108 | 1106 |
public GeometryType getTypeVectorLayer() throws DataException, |
1109 |
LocatorException,
|
|
1110 |
GeometryTypeNotSupportedException,
|
|
1111 |
GeometryTypeNotValidException {
|
|
1107 |
LocatorException, |
|
1108 |
GeometryTypeNotSupportedException, |
|
1109 |
GeometryTypeNotValidException { |
|
1112 | 1110 |
// FIXME Esto deberia de pedirse a FType!!!! |
1113 | 1111 |
FeatureStore fs = this.getFeatureStore(); |
1114 | 1112 |
FeatureType fType = fs.getDefaultFeatureType(); |
1115 | 1113 |
FeatureAttributeDescriptor attr |
1116 |
= fType.getAttributeDescriptor(fType.getDefaultGeometryAttributeIndex());
|
|
1114 |
= fType.getAttributeDescriptor(fType.getDefaultGeometryAttributeIndex()); |
|
1117 | 1115 |
GeometryType geomType |
1118 |
= GeometryLocator.getGeometryManager()
|
|
1116 |
= GeometryLocator.getGeometryManager() |
|
1119 | 1117 |
.getGeometryType(attr.getGeometryType(), |
1120 |
attr.getGeometrySubType());
|
|
1118 |
attr.getGeometrySubType()); |
|
1121 | 1119 |
return geomType; |
1122 | 1120 |
} |
1123 | 1121 |
|
1124 |
public static class RegisterPersistence implements Callable { |
|
1122 |
public static class RegisterPersistence |
|
1123 |
implements Callable { |
|
1125 | 1124 |
|
1126 | 1125 |
public Object call() { |
1127 | 1126 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
1128 | 1127 |
|
1129 | 1128 |
DynStruct definition |
1130 |
= manager.addDefinition(FLyrVect.class,
|
|
1131 |
"FLyrVect",
|
|
1132 |
"FLyrVect Persistence definition",
|
|
1133 |
null,
|
|
1134 |
null);
|
|
1129 |
= manager.addDefinition(FLyrVect.class, |
|
1130 |
"FLyrVect", |
|
1131 |
"FLyrVect Persistence definition", |
|
1132 |
null, |
|
1133 |
null); |
|
1135 | 1134 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
1136 |
"FLyrDefault");
|
|
1135 |
"FLyrDefault"); |
|
1137 | 1136 |
|
1138 | 1137 |
definition.addDynFieldObject("legend") |
1139 |
.setClassOfValue(IVectorLegend.class)
|
|
1140 |
.setMandatory(true);
|
|
1138 |
.setClassOfValue(IVectorLegend.class) |
|
1139 |
.setMandatory(true); |
|
1141 | 1140 |
definition.addDynFieldObject("featureStore") |
1142 |
.setClassOfValue(FeatureStore.class)
|
|
1143 |
.setMandatory(true);
|
|
1141 |
.setClassOfValue(FeatureStore.class) |
|
1142 |
.setMandatory(true); |
|
1144 | 1143 |
definition.addDynFieldBoolean("isLabeled").setMandatory(true); |
1145 | 1144 |
definition.addDynFieldInt("typeShape").setMandatory(true); |
1146 | 1145 |
definition.addDynFieldObject("labelingStrategy") |
1147 |
.setClassOfValue(ILabelingStrategy.class)
|
|
1148 |
.setMandatory(false);
|
|
1146 |
.setClassOfValue(ILabelingStrategy.class) |
|
1147 |
.setMandatory(false); |
|
1149 | 1148 |
|
1150 | 1149 |
return Boolean.TRUE; |
1151 | 1150 |
} |
... | ... | |
1166 | 1165 |
*/ |
1167 | 1166 |
public static Envelope fromViewPortCRSToSourceCRS(FLayer lyr, Envelope env) { |
1168 | 1167 |
|
1169 |
if (lyr == null || env == null) {
|
|
1168 |
if( lyr == null || env == null ) {
|
|
1170 | 1169 |
return null; |
1171 | 1170 |
} |
1172 | 1171 |
|
1173 | 1172 |
ICoordTrans ct = lyr.getCoordTrans(); |
1174 |
if (ct == null) {
|
|
1173 |
if( ct == null ) {
|
|
1175 | 1174 |
return env; |
1176 | 1175 |
} else { |
1177 | 1176 |
return env.convert(ct.getInverted()); |
... | ... | |
1193 | 1192 |
* @deprecated use the transformToSourceCRS method of layer. |
1194 | 1193 |
*/ |
1195 | 1194 |
public static Geometry fromViewPortCRSToSourceCRS( |
1196 |
FLayer lyr,
|
|
1197 |
Geometry geo,
|
|
1198 |
boolean clone) {
|
|
1195 |
FLayer lyr, |
|
1196 |
Geometry geo, |
|
1197 |
boolean clone) { |
|
1199 | 1198 |
|
1200 |
if (lyr == null || geo == null) {
|
|
1199 |
if( lyr == null || geo == null ) {
|
|
1201 | 1200 |
return null; |
1202 | 1201 |
} |
1203 | 1202 |
ICoordTrans ct = lyr.getCoordTrans(); |
1204 | 1203 |
Geometry resp = geo; |
1205 |
if (clone) {
|
|
1204 |
if( clone ) {
|
|
1206 | 1205 |
resp = resp.cloneGeometry(); |
1207 | 1206 |
} |
1208 |
if (ct != null) {
|
|
1207 |
if( ct != null ) {
|
|
1209 | 1208 |
resp.reProject(ct.getInverted()); |
1210 | 1209 |
} |
1211 | 1210 |
return resp; |
... | ... | |
1215 | 1214 |
return this.getFeatureStore().iterator(); |
1216 | 1215 |
} |
1217 | 1216 |
|
1218 |
protected class EnvelopeCantBeInitializedException extends BaseException { |
|
1217 |
protected class EnvelopeCantBeInitializedException |
|
1218 |
extends BaseException { |
|
1219 | 1219 |
|
1220 | 1220 |
/** |
1221 | 1221 |
* |
... | ... | |
1231 | 1231 |
|
1232 | 1232 |
@Override |
1233 | 1233 |
public String getInfoString() { |
1234 |
LayerInformationBuilder builder = MapContextLocator.getMapContextManager().createLayerInformationBuilder(); |
|
1235 |
|
|
1236 |
if( !this.isAvailable() ) { |
|
1237 |
builder.title().labelkey("Warning"); |
|
1238 |
builder.text().value("The layer is not available."); |
|
1239 |
} |
|
1240 |
|
|
1234 | 1241 |
Envelope env = null; |
1235 | 1242 |
FeatureAttributeDescriptor attrgeom = null; |
1243 |
|
|
1236 | 1244 |
try { |
1237 | 1245 |
env = this.getFullEnvelope(); |
1238 |
} catch (ReadException ex) {
|
|
1246 |
} catch (Exception ex) { |
|
1239 | 1247 |
} |
1240 | 1248 |
FeatureStore store = this.getFeatureStore(); |
1241 |
|
|
1242 | 1249 |
try { |
1243 | 1250 |
FeatureType ft = store.getDefaultFeatureType(); |
1244 | 1251 |
attrgeom = ft.getDefaultGeometryAttribute(); |
1245 |
} catch (DataException ex) {
|
|
1252 |
} catch (Exception ex) { |
|
1246 | 1253 |
} |
1247 |
|
|
1248 |
LayerInformationBuilder builder = MapContextLocator.getMapContextManager().createLayerInformationBuilder(); |
|
1249 | 1254 |
|
1250 | 1255 |
builder.title().labelkey("Data_source"); |
1251 | 1256 |
builder.property().labelkey("Source_type").value(store.getProviderName()); |
1252 | 1257 |
builder.property().labelkey("origen").value(store.getFullName()); |
1253 | 1258 |
if( store.getParameters() instanceof FilesystemStoreParameters ) { |
1254 |
File f = ((FilesystemStoreParameters)(store.getParameters())).getFile(); |
|
1255 |
if( f!=null ) {
|
|
1259 |
File f = ((FilesystemStoreParameters) (store.getParameters())).getFile();
|
|
1260 |
if( f != null && f.exists() ) {
|
|
1256 | 1261 |
builder.property().labelkey("_Size").value("%d bytes", f.length()); |
1257 | 1262 |
} |
1258 | 1263 |
} |
... | ... | |
1262 | 1267 |
} |
1263 | 1268 |
|
1264 | 1269 |
builder.title().labelkey("_Coordenadas_geograficas"); |
1265 |
builder.envelope().value(env); |
|
1270 |
if( this.isAvailable() ) { |
|
1271 |
builder.envelope().value(env); |
|
1272 |
} |
|
1266 | 1273 |
|
1267 | 1274 |
builder.title().labelkey("_Projection"); |
1268 |
builder.property().value(this.getProjection()); |
|
1269 |
builder.text().asWKT(this.getProjection()); |
|
1270 |
|
|
1275 |
if( this.isAvailable() ) { |
|
1276 |
builder.property().value(this.getProjection()); |
|
1277 |
builder.text().asWKT(this.getProjection()); |
|
1278 |
} |
|
1271 | 1279 |
return builder.toString(); |
1272 | 1280 |
} |
1273 | 1281 |
|
1274 |
|
|
1275 | 1282 |
} |
Also available in: Unified diff