Revision 23303 branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/FLyrDefault.java
FLyrDefault.java | ||
---|---|---|
56 | 56 |
import org.apache.log4j.Logger; |
57 | 57 |
import org.cresques.cts.ICoordTrans; |
58 | 58 |
import org.cresques.cts.IProjection; |
59 |
import org.gvsig.tools.exception.BaseException; |
|
60 | 59 |
import org.gvsig.fmap.crs.CRSFactory; |
61 | 60 |
import org.gvsig.fmap.data.ReadException; |
62 | 61 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
66 | 65 |
import org.gvsig.fmap.mapcontext.layers.operations.ComposedLayer; |
67 | 66 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent; |
68 | 67 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener; |
68 |
import org.gvsig.tools.exception.BaseException; |
|
69 | 69 |
|
70 | 70 |
import com.iver.utiles.IPersistence; |
71 | 71 |
import com.iver.utiles.XMLEntity; |
... | ... | |
346 | 346 |
projection = proj; |
347 | 347 |
// Comprobar que la proyecci?n es la misma que la de FMap |
348 | 348 |
// Si no lo es, es una capa que est? reproyectada al vuelo |
349 |
if ((proj != null) && (getMapContext() != null)) |
|
349 |
if ((proj != null) && (getMapContext() != null)) {
|
|
350 | 350 |
if (proj != getMapContext().getProjection()) { |
351 | 351 |
ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
352 | 352 |
setCoordTrans(ct); |
... | ... | |
354 | 354 |
+ getMapContext().getProjection().getAbrev() + " y capa " |
355 | 355 |
+ getName() + " con " + proj.getAbrev()); |
356 | 356 |
} |
357 |
} |
|
357 | 358 |
} |
358 | 359 |
|
359 | 360 |
/* |
... | ... | |
469 | 470 |
Set keyset = properties.keySet(); |
470 | 471 |
Iterator keyitr = keyset.iterator(); |
471 | 472 |
XMLEntity xmlProperties = new XMLEntity(); |
472 |
xmlProperties.putProperty("childName","properties");
|
|
473 |
xmlProperties.putProperty("tagName", "properties");
|
|
473 | 474 |
while (keyitr.hasNext()) { |
474 | 475 |
String propName = (String)keyitr.next(); |
475 | 476 |
Object obj = properties.get(propName); |
... | ... | |
530 | 531 |
if (xml.contains("proj")) { |
531 | 532 |
setProjection(CRSFactory.getCRS(xml.getStringProperty("proj"))); |
532 | 533 |
} |
533 |
if (xml.contains("transparency")) |
|
534 |
if (xml.contains("transparency")) {
|
|
534 | 535 |
transparency = xml.getIntProperty("transparency"); |
535 |
if (xml.contains("isInTOC")) |
|
536 |
} |
|
537 |
if (xml.contains("isInTOC")) { |
|
536 | 538 |
status.inTOC = xml.getBooleanProperty("isInTOC"); |
539 |
} |
|
537 | 540 |
|
538 | 541 |
// recreate Properties hashTable |
539 |
if (xml.contains("numProperties")) { // for older projects |
|
540 |
int numProps = xml.getIntProperty("numProperties"); |
|
541 |
Object obj= null; |
|
542 |
int xmlPropertiesPos = xml.firstIndexOfChild("childName", "properties"); |
|
543 |
XMLEntity xmlProperties = null; |
|
544 |
if (xmlPropertiesPos > -1) { |
|
545 |
xmlProperties = xml.getChild(xmlPropertiesPos); |
|
546 |
} |
|
547 |
|
|
548 |
if (xmlProperties != null) { |
|
549 |
|
|
550 |
int numProps = xmlProperties.getChildrenCount(); |
|
551 |
Object obj; |
|
552 |
String className; |
|
553 |
Class classProp; |
|
542 | 554 |
IPersistence objPersist; |
543 | 555 |
for (int iProp=0; iProp<numProps; iProp++) { |
544 |
XMLEntity xmlProp = xml.getChild(0);
|
|
556 |
XMLEntity xmlProp = xmlProperties.getChild(iProp);
|
|
545 | 557 |
try { |
546 |
String className = xmlProp.getStringProperty("className");
|
|
558 |
className = xmlProp.getStringProperty("className"); |
|
547 | 559 |
if (className.equals(String.class.getName())) { |
548 | 560 |
obj = xmlProp.getStringProperty("value"); |
549 | 561 |
} else { |
550 |
Class classProp = Class.forName(className);
|
|
562 |
classProp = Class.forName(className); |
|
551 | 563 |
obj = classProp.newInstance(); |
552 | 564 |
objPersist = (IPersistence)obj; |
553 | 565 |
objPersist.setXMLEntity(xmlProp); |
566 |
|
|
554 | 567 |
} |
555 | 568 |
String propName = xmlProp.getStringProperty("layerPropertyName"); |
556 | 569 |
properties.put(propName, obj); |
557 | 570 |
} catch (Exception e) { |
571 |
logger.error("Layer:" + this.getName() |
|
572 |
+ ": Error loading properties", e); |
|
558 | 573 |
continue; |
559 | 574 |
} |
560 |
// remove Properties children to avoid breaking layers' XML reading logic |
|
561 |
xml.removeChild(0); |
|
562 | 575 |
} |
563 |
} // newer projects store properties under a node |
|
564 |
else { |
|
565 |
int xmlPropertiesPos = xml.firstIndexOfChild("childName","properties"); |
|
566 |
XMLEntity xmlProperties =null; |
|
567 |
if (xmlPropertiesPos > -1) |
|
568 |
xmlProperties = xml.getChild(xmlPropertiesPos); |
|
569 |
|
|
570 |
if (xmlProperties != null) { |
|
571 |
|
|
572 |
int numProps = xmlProperties.getChildrenCount(); |
|
573 |
Object obj; |
|
574 |
String className; |
|
575 |
Class classProp; |
|
576 |
IPersistence objPersist; |
|
577 |
for (int iProp=0; iProp<numProps; iProp++) { |
|
578 |
XMLEntity xmlProp = xmlProperties.getChild(iProp); |
|
579 |
try { |
|
580 |
className = xmlProp.getStringProperty("className"); |
|
581 |
if (className.equals(String.class.getName())) { |
|
582 |
obj = xmlProp.getStringProperty("value"); |
|
583 |
} else { |
|
584 |
classProp = Class.forName(className); |
|
585 |
obj = classProp.newInstance(); |
|
586 |
objPersist = (IPersistence)obj; |
|
587 |
objPersist.setXMLEntity(xmlProp); |
|
588 |
|
|
589 |
} |
|
590 |
String propName = xmlProp.getStringProperty("layerPropertyName"); |
|
591 |
properties.put(propName, obj); |
|
592 |
} catch (Exception e) { |
|
593 |
//FIXME: OJO !!!!! |
|
594 |
continue; |
|
595 |
} |
|
596 |
} |
|
597 |
// remove Properties children to avoid breaking layers' XML reading logic |
|
598 |
xml.removeChild(xmlPropertiesPos); |
|
599 |
} |
|
600 | 576 |
} |
601 | 577 |
} |
602 | 578 |
|
... | ... | |
617 | 593 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#addLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener) |
618 | 594 |
*/ |
619 | 595 |
public boolean addLayerListener(LayerListener o) { |
620 |
if (layerListeners.contains(o)) |
|
596 |
if (layerListeners.contains(o)) {
|
|
621 | 597 |
return false; |
598 |
} |
|
622 | 599 |
return layerListeners.add(o); |
623 | 600 |
} |
624 | 601 |
/* |
... | ... | |
771 | 748 |
|
772 | 749 |
boolean bVisible = true; |
773 | 750 |
if (getMinScale() != -1) { |
774 |
if (scale < getMinScale()) |
|
751 |
if (scale < getMinScale()) {
|
|
775 | 752 |
bVisible = false; |
753 |
} |
|
776 | 754 |
} |
777 | 755 |
if (getMaxScale() != -1) { |
778 |
if (scale > getMaxScale()) |
|
756 |
if (scale > getMaxScale()) {
|
|
779 | 757 |
bVisible = false; |
758 |
} |
|
780 | 759 |
} |
781 | 760 |
|
782 | 761 |
return bVisible; |
... | ... | |
848 | 827 |
*/ |
849 | 828 |
public void setCachingDrawnLayers(boolean bCacheDrawnLayers) { |
850 | 829 |
status.cacheDrawnLayers = bCacheDrawnLayers; |
851 |
if (status.cacheDrawnLayers == false) |
|
830 |
if (status.cacheDrawnLayers == false) {
|
|
852 | 831 |
this.cacheImageDrawnLayers = null; |
832 |
} |
|
853 | 833 |
} |
854 | 834 |
/* |
855 | 835 |
* (non-Javadoc) |
... | ... | |
1048 | 1028 |
*/ |
1049 | 1029 |
protected void callLegendChanged(LegendChangedEvent e) { |
1050 | 1030 |
layerChangeSupport.callLegendChanged(e); |
1051 |
if(parentLayer != null) |
|
1031 |
if(parentLayer != null) {
|
|
1052 | 1032 |
parentLayer.callLegendChanged(e); |
1033 |
} |
|
1053 | 1034 |
} |
1054 | 1035 |
|
1055 | 1036 |
/** |
Also available in: Unified diff