Revision 9669 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerSymbol.java

View differences:

MultiLayerSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2007-01-10 16:39:41  jaume
46
* Revision 1.3  2007-01-11 12:17:34  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.2  2007/01/10 16:39:41  jaume
47 50
* ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
48 51
*
49 52
* Revision 1.1  2007/01/10 16:31:36  jaume
......
60 63

  
61 64
import javax.print.attribute.PrintRequestAttributeSet;
62 65

  
63
import com.hardcode.gdbms.engine.data.driver.DriverException;
64 66
import com.iver.cit.gvsig.fmap.core.FShape;
65 67
import com.iver.cit.gvsig.fmap.core.IGeometry;
68
import com.iver.cit.gvsig.fmap.core.SymbolFactory;
66 69
import com.iver.utiles.XMLEntity;
67 70

  
71
/**
72
 * <p>Symbol that allows to combine many symbols into one and treat it
73
 * as a single one. Within MultiLayerSymbol, each symbol is defined as a
74
 * layer inside the MultiLayerSymbol.<br></p>
75
 *
76
 * <p>This symbol does not perform anything by itself. Rather than that it
77
 * keeps a list of symbols and iterates over each element performing the
78
 * operation over each one.<br></p>
79
 *
80
 * <p>The elements of the list can be any symbol, even other MultiLayerSymbol
81
 * so, it is also possible to define symbols as a tree of symbols</p>
82
 *
83
 * @author jaume dominguez faus - jaume.dominguez@iver.es
84
 *
85
 */
68 86
public class MultiLayerSymbol extends AbstractSymbol {
69 87
	private ISymbol[] layers;
70 88
	private MultiLayerSymbol selectionSymbol;
71 89

  
90
	/**
91
	 * Gets the symbol in the layerIndex position of the symbol list.
92
	 * @param int layerIndex
93
	 * @return
94
	 */
72 95
	public ISymbol getLayer(int layerIndex) {
73 96
		try{
74 97
			return layers[layerIndex];
......
94 117
		return selectionSymbol;
95 118
	}
96 119

  
120
	/**
121
	 * Stacks a new symbol to the symbol list. The symbol is appended to the
122
	 * list and, in terms of use, it will be the last symbol to be processed.
123
	 * @param ISymbol newLayer
124
	 */
97 125
	public void addLayer(ISymbol newLayer) {
98 126
		selectionSymbol = null; /* forces the selection symbol to be re-created
99 127
								 * next time it is required
......
123 151
	}
124 152

  
125 153
	public XMLEntity getXMLEntity() {
126
		// TODO Auto-generated method stub
127
		throw new Error("Not yet implemented!");
128

  
154
		XMLEntity xml = new XMLEntity();
155
		xml.putProperty("isShapeVisible", isShapeVisible());
156
		xml.putProperty("desc", getDescription());
157
		for (int i = 0; i < layers.length; i++) {
158
			xml.addChild(layers[i].getXMLEntity());
159
		}
160
		return xml;
129 161
	}
130 162

  
131 163
	public int getSymbolType() {
......
135 167
	}
136 168

  
137 169
	public boolean isSuitableFor(IGeometry geom) {
138
		// TODO Auto-generated method stub
139
		throw new Error("Not yet implemented!");
140

  
170
		return true;
141 171
	}
142 172

  
143 173
	public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) {
......
151 181
	}
152 182

  
153 183
	public void setXMLEntity(XMLEntity xml) {
154
		// TODO Auto-generated method stub
155
		throw new Error("Not yet implemented!");
156

  
184
		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
185
		setDescription(xml.getStringProperty("desc"));
186
		layers = new ISymbol[xml.getChildrenCount()];
187
		for (int i = 0; i < layers.length; i++) {
188
			layers[i] = SymbolFactory.createFromXML(xml.getChild(i), "layer" + i);
189
		}
157 190
	}
158 191

  
159 192
	public void setPrintingProperties(PrintRequestAttributeSet properties) {

Also available in: Unified diff