Revision 10679 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java

View differences:

FLyrVect.java
55 55
import org.cresques.cts.ICoordTrans;
56 56

  
57 57
import com.hardcode.driverManager.DriverLoadException;
58
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException;
59
import com.hardcode.gdbms.driver.exceptions.OpenDriverException;
60 58
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
61
import com.hardcode.gdbms.driver.exceptions.ReloadDriverException;
62 59
import com.hardcode.gdbms.engine.data.DataSourceFactory;
63 60
import com.hardcode.gdbms.engine.data.NoSuchTableException;
64 61
import com.hardcode.gdbms.engine.data.driver.DriverException;
......
71 68
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
72 69
import com.iver.cit.gvsig.fmap.ViewPort;
73 70
import com.iver.cit.gvsig.fmap.core.IGeometry;
71
import com.iver.cit.gvsig.fmap.core.ILabelable;
74 72
import com.iver.cit.gvsig.fmap.core.IPrintable;
75 73
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
76 74
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
......
89 87
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
90 88
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
91 89
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint;
92
import com.iver.cit.gvsig.fmap.layers.layerOperations.Labelable;
93 90
import com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData;
94 91
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer;
95 92
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData;
......
104 101
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
105 102
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend;
106 103
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
104
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingStrategy;
105
import com.iver.cit.gvsig.fmap.rendering.styling.LabelingFactory;
107 106
import com.iver.cit.gvsig.fmap.spatialindex.IPersistentSpatialIndex;
108 107
import com.iver.cit.gvsig.fmap.spatialindex.ISpatialIndex;
109 108
import com.iver.cit.gvsig.fmap.spatialindex.QuadtreeGt2;
......
111 110
import com.iver.cit.gvsig.fmap.spatialindex.SpatialIndexException;
112 111
import com.iver.utiles.FileUtils;
113 112
import com.iver.utiles.IPersistance;
113
import com.iver.utiles.NotExistInXMLEntity;
114 114
import com.iver.utiles.PostProcessSupport;
115 115
import com.iver.utiles.XMLEntity;
116 116
import com.iver.utiles.swing.threads.Cancellable;
......
123 123
 */
124 124

  
125 125
// TODO Cuando no sea para pruebas debe no ser public
126
public class FLyrVect extends FLyrDefault implements Labelable,
126
public class FLyrVect extends FLyrDefault implements ILabelable,
127 127
		ClassifiableVectorial, SingleLayer, VectorialData, RandomVectorialData,
128 128
		AlphanumericData, InfoByPoint {
129 129
	private static Logger logger = Logger.getLogger(FLyrVect.class.getName());
......
806 806
		if (bHasJoin)
807 807
			xml.putProperty("hasJoin", "true");
808 808

  
809

  
810
		// properties from ILabelable
811
		xml.putProperty("isLabeled", isLabeled);
812
		if (strategy != null) {
813
			XMLEntity strategyXML = strategy.getXMLEntity();
814
			strategyXML.putProperty("Strategy", strategy.getClassName());
815
			xml.addChild(strategy.getXMLEntity());
816
		}
809 817
		return xml;
810 818
	}
811 819

  
......
888 896
				}
889 897
			}
890 898

  
899

  
900
			// set properties for ILabelable
901
			for (int i = 0; i < xml.getChildrenCount(); i++) {
902
				try {
903
					if (xml.getChild(i).contains("Strategy")) {
904
						XMLEntity xmlStrategy = xml.getChild(i);
905
						this.strategy = LabelingFactory.createStrategyFromXML(xmlStrategy.getChild(0));
906
					}
907
				} catch (NotExistInXMLEntity neXMLEX) {
908
					// no strategy was set, just continue;
909
					logger.warn("Reached what should be unreachable code");
910
				}
911
			}
891 912
		} catch (XMLException e) {
892 913
			this.setAvailable(false);
893 914
			this.orgXMLEntity = xml;
......
1363 1384
		clonedLayer.setName(getName());
1364 1385
		clonedLayer.setCoordTrans(getCoordTrans());
1365 1386

  
1387

  
1388
		// TODO, substitute this stuff by the new labeling
1389

  
1366 1390
		if (legend.getLabelField() != null) // Hay etiquetas
1367 1391
		{
1368 1392
			FLyrText lyrText = getLayerText();
......
1376 1400
		}
1377 1401
		else
1378 1402
			clonedLayer.setLegend((VectorialLegend)getLegend());
1403

  
1404
		// TODO by this
1405
//		clonedLayer.setIsLabeled(isLabeled());
1406
//		clonedLayer.setLabelingStrategy(getLabelingStrategy());
1407

  
1379 1408
		return clonedLayer;
1380 1409
	}
1381 1410

  
1411

  
1412
	/*
1413
	 * jaume. Stuff from ILabeled.
1414
	 */
1415
	private boolean isLabeled;
1416
	private ILabelingStrategy strategy;
1417

  
1418
	public boolean isLabeled() {
1419
		return isLabeled;
1420
	}
1421

  
1422
	public void setIsLabeled(boolean isLabeled) {
1423
		this.isLabeled = isLabeled;
1424
	}
1425

  
1426
	public ILabelingStrategy getLabelingStrategy() {
1427
		return strategy;
1428
	}
1429

  
1430
	public void setLabelingStrategy(ILabelingStrategy strategy) {
1431
		this.strategy = strategy;
1432
	}
1433

  
1434
	public void drawLabels(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadDriverException {
1435
		if (isWithinScale(scale)) {
1436
			strategy.draw(image, g, viewPort, cancel);
1437
		}
1438
	}
1439

  
1382 1440
}

Also available in: Unified diff