Revision 10679 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/SingleSymbolLegend.java
SingleSymbolLegend.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.util.ArrayList; |
44 | 44 |
|
45 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
46 | 45 |
import com.hardcode.gdbms.engine.data.DataSource; |
47 | 46 |
import com.iver.cit.gvsig.fmap.core.FShape; |
48 | 47 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
49 | 48 |
import com.iver.cit.gvsig.fmap.core.ISLDCompatible; |
50 | 49 |
import com.iver.cit.gvsig.fmap.core.SLDTags; |
50 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
51 | 51 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
52 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
52 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
53 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
54 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol; |
|
53 | 55 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
54 | 56 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
55 | 57 |
import com.iver.utiles.XMLEntity; |
... | ... | |
57 | 59 |
|
58 | 60 |
/** |
59 | 61 |
* Leyenda se s?mbolo ?nico. |
60 |
* |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
* @author Vicente Caballero Navarro |
|
62 | 63 |
*/ |
63 | 64 |
public class SingleSymbolLegend implements VectorialLegend { |
64 | 65 |
private ISymbol defaultSymbol; |
65 | 66 |
private String labelFieldName = null; |
66 | 67 |
private String labelFieldHeight = null; |
67 | 68 |
private String labelFieldRotation = null; |
69 |
/** |
|
70 |
* @uml.property name="shapeType" |
|
71 |
*/ |
|
68 | 72 |
private int shapeType = FShape.POLYGON; // Por defecto, tipo pol?gono |
69 | 73 |
// private boolean bWithHeightText; |
70 | 74 |
/** |
... | ... | |
83 | 87 |
defaultSymbol = LegendFactory.DEFAULT_POLYGON_SYMBOL; |
84 | 88 |
} |
85 | 89 |
|
86 |
/** |
|
87 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol) |
|
88 |
*/ |
|
89 | 90 |
public void setDefaultSymbol(ISymbol s) { |
90 | 91 |
setShapeType(s.getSymbolType()); |
91 | 92 |
defaultSymbol = s; |
92 | 93 |
} |
93 | 94 |
|
94 | 95 |
/** |
95 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelField()
|
|
96 |
* @deprecated
|
|
96 | 97 |
*/ |
97 | 98 |
public String getLabelField() { |
98 | 99 |
return labelFieldName; |
99 | 100 |
} |
100 | 101 |
|
101 | 102 |
/** |
102 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setLabelField(int)
|
|
103 |
* @deprecated
|
|
103 | 104 |
*/ |
104 | 105 |
public void setLabelField(String fieldName) { |
105 | 106 |
labelFieldName = fieldName; |
106 | 107 |
} |
107 | 108 |
|
108 |
/** |
|
109 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int) |
|
110 |
*/ |
|
111 |
public ISymbol getSymbol(int recordIndex) throws ReadDriverException { |
|
109 |
public ISymbol getSymbol(int recordIndex) { |
|
112 | 110 |
return defaultSymbol; |
113 | 111 |
} |
114 | 112 |
|
115 |
/** |
|
116 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol() |
|
117 |
*/ |
|
118 | 113 |
public ISymbol getDefaultSymbol() { |
119 | 114 |
return defaultSymbol; |
120 | 115 |
} |
121 | 116 |
|
122 |
/** |
|
123 |
* creates the SLD String that defines this legend type. |
|
124 |
*/ |
|
125 | 117 |
public String getSLDString(String layerName) |
126 | 118 |
{ |
127 | 119 |
// StyledLayerDescriptor sld = new StyledLayerDescriptor(); |
... | ... | |
179 | 171 |
} |
180 | 172 |
} |
181 | 173 |
|
182 |
/** |
|
183 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity() |
|
184 |
*/ |
|
185 | 174 |
public XMLEntity getXMLEntity() { |
186 | 175 |
XMLEntity xml = new XMLEntity(); |
187 | 176 |
xml.putProperty("className",this.getClass().getName()); |
... | ... | |
193 | 182 |
return xml; |
194 | 183 |
} |
195 | 184 |
|
196 |
/** |
|
197 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setXMLEntity() |
|
198 |
*/ |
|
199 | 185 |
public void setXMLEntity03(XMLEntity xml) { |
200 | 186 |
setLabelField(xml.getStringProperty("labelFieldName")); |
201 | 187 |
|
... | ... | |
203 | 189 |
setDefaultSymbol(auxSym); |
204 | 190 |
} |
205 | 191 |
|
206 |
/** |
|
207 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setXMLEntity() |
|
208 |
*/ |
|
209 | 192 |
public void setXMLEntity(XMLEntity xml) { |
210 | 193 |
setLabelField(xml.getStringProperty("labelFieldName")); |
211 | 194 |
if (xml.contains("labelHeightFieldName")) |
... | ... | |
213 | 196 |
if (xml.contains("labelRotationFieldName")) |
214 | 197 |
setLabelRotationField(xml.getStringProperty("labelRotationFieldName")); |
215 | 198 |
|
216 |
FSymbol auxSym = FSymbol.createFromXML(xml.getChild(0)); |
|
199 |
// FSymbol auxSym = FSymbol.createFromXML(xml.getChild(0)); |
|
200 |
ISymbol auxSym = SymbologyFactory.createSymbolFromXML(xml.getChild(0), null); |
|
217 | 201 |
setDefaultSymbol(auxSym); |
218 | 202 |
} |
219 | 203 |
|
220 |
/** |
|
221 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend() |
|
222 |
*/ |
|
204 |
|
|
223 | 205 |
public Legend cloneLegend() throws XMLException { |
224 | 206 |
return (Legend) LegendFactory.createFromXML(getXMLEntity()); |
225 | 207 |
} |
226 | 208 |
|
227 |
/* (non-Javadoc) |
|
228 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource) |
|
229 |
*/ |
|
230 |
public void setDataSource(DataSource ds) throws ReadDriverException { |
|
209 |
|
|
210 |
public void setDataSource(DataSource ds) { |
|
231 | 211 |
// No hacemos nada, no lo vamos a usar |
232 | 212 |
} |
233 | 213 |
|
234 |
/* (non-Javadoc) |
|
235 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType() |
|
236 |
*/ |
|
237 | 214 |
public int getShapeType() { |
238 | 215 |
return shapeType; |
239 | 216 |
} |
240 | 217 |
|
241 |
/* (non-Javadoc) |
|
242 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setShapeType(int) |
|
243 |
*/ |
|
244 | 218 |
public void setShapeType(int shapeType) { |
245 | 219 |
if (this.shapeType != shapeType) { |
246 | 220 |
switch (shapeType) { |
247 | 221 |
case FShape.POINT: |
248 |
defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
249 |
|
|
222 |
defaultSymbol = new SimpleMarkerSymbol(); |
|
250 | 223 |
break; |
251 | 224 |
|
252 | 225 |
case FShape.LINE: |
253 |
defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE);
|
|
226 |
defaultSymbol = new SimpleLineSymbol();
|
|
254 | 227 |
|
255 | 228 |
break; |
256 | 229 |
|
257 | 230 |
case FShape.POLYGON: |
258 |
defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_FILL);
|
|
231 |
defaultSymbol = new SimpleFillSymbol();
|
|
259 | 232 |
|
260 | 233 |
break; |
261 | 234 |
} |
... | ... | |
264 | 237 |
} |
265 | 238 |
} |
266 | 239 |
|
267 |
/* (non-Javadoc)
|
|
268 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
|
|
240 |
/**
|
|
241 |
* @deprecated
|
|
269 | 242 |
*/ |
270 | 243 |
public String getLabelHeightField() { |
271 | 244 |
return labelFieldHeight; |
... | ... | |
273 | 246 |
|
274 | 247 |
/** |
275 | 248 |
* Inserta el texto que refleja el alto del campo. |
276 |
* |
|
249 |
* @deprecated
|
|
277 | 250 |
* @param str String. |
278 | 251 |
*/ |
279 | 252 |
public void setLabelHeightField(String str) { |
280 | 253 |
labelFieldHeight = str; |
281 | 254 |
} |
282 | 255 |
|
283 |
/* (non-Javadoc)
|
|
284 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
|
|
256 |
/**
|
|
257 |
* @deprecated
|
|
285 | 258 |
*/ |
286 | 259 |
public String getLabelRotationField() { |
287 | 260 |
return labelFieldRotation; |
... | ... | |
289 | 262 |
|
290 | 263 |
/** |
291 | 264 |
* Inserta el texto que refleja la rotaci?n del campo. |
265 |
* @deprecated |
|
292 | 266 |
* |
293 | 267 |
* @param str String. |
294 | 268 |
*/ |
... | ... | |
304 | 278 |
// TODO Auto-generated method stub |
305 | 279 |
} |
306 | 280 |
|
307 |
/* (non-Javadoc) |
|
308 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields() |
|
309 |
*/ |
|
310 | 281 |
public String[] getUsedFields() { |
311 | 282 |
ArrayList usedFields = new ArrayList(); |
312 | 283 |
if (getLabelField() != null) |
... | ... | |
319 | 290 |
return (String[]) usedFields.toArray(new String[0]); |
320 | 291 |
} |
321 | 292 |
|
322 |
/* public boolean isBWithHeightText() { |
|
323 |
return bWithHeightText; |
|
324 |
} |
|
293 |
public boolean isUseDefaultSymbol() { |
|
294 |
return true; |
|
325 | 295 |
|
326 |
public void setBWithHeightText(boolean withHeightText) { |
|
327 |
bWithHeightText = withHeightText; |
|
328 |
} */ |
|
296 |
} |
|
329 | 297 |
} |
Also available in: Unified diff