Revision 479 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/VectorialUniqueValueLegend.java
VectorialUniqueValueLegend.java | ||
---|---|---|
8 | 8 |
import com.hardcode.gdbms.engine.data.DriverException; |
9 | 9 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
10 | 10 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
11 |
import com.hardcode.gdbms.engine.instruction.SemanticException; |
|
11 | 12 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
12 | 13 |
import com.hardcode.gdbms.engine.values.Value; |
14 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
13 | 15 |
import com.iver.cit.gvsig.fmap.core.FShape; |
14 | 16 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
15 | 17 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
... | ... | |
192 | 194 |
fieldName = str; |
193 | 195 |
} |
194 | 196 |
|
195 |
/* |
|
196 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(java.lang.Object) |
|
197 |
* |
|
198 |
public FStyle2D getSymbol(Object value) { |
|
199 |
return (FStyle2D) symbols.get(value); |
|
200 |
} |
|
201 |
//TODO cambiar la implementaci?n del metodo comentado para que encaje |
|
202 |
* en este de abajo |
|
203 |
*/ |
|
204 |
|
|
205 | 197 |
/** |
206 | 198 |
* @throws DriverException |
207 | 199 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(int) |
... | ... | |
229 | 221 |
xml.putProperty("nameClass",this.getClass().getName()); |
230 | 222 |
xml.putProperty("fieldName", fieldName); |
231 | 223 |
xml.putProperty("labelfield", labelFieldName); |
232 |
|
|
233 |
xml.putProperty("numKeys", keys.size()); |
|
234 |
String[] sk = new String[keys.size()]; |
|
235 |
|
|
236 |
for (int i = 0; i < keys.size(); i++) { |
|
237 |
sk[i] = (String) keys.get(i); |
|
224 |
if (getDefaultSymbol() == null) |
|
225 |
{ |
|
226 |
xml.putProperty("useDefaultSymbol", false); |
|
238 | 227 |
} |
239 |
xml.putProperty("keys", sk); |
|
240 |
|
|
241 |
xml.addChild(getDefaultSymbol().getXMLEntity()); |
|
242 |
|
|
243 |
for (int i = 0; i < keys.size(); i++) { |
|
244 |
xml.addChild(getSymbolByID(i).getXMLEntity()); |
|
228 |
else |
|
229 |
{ |
|
230 |
xml.putProperty("useDefaultSymbol", true); |
|
231 |
xml.addChild(getDefaultSymbol().getXMLEntity()); |
|
245 | 232 |
} |
246 |
|
|
233 |
xml.putProperty("numKeys", keys.size()); |
|
234 |
if (keys.size() > 0) |
|
235 |
{ |
|
236 |
xml.putProperty("tipoValueKeys", keys.get(0).getClass().getName()); |
|
237 |
String[] sk = new String[keys.size()]; |
|
238 |
|
|
239 |
for (int i = 0; i < keys.size(); i++) { |
|
240 |
sk[i] = ((Value) keys.get(i)).toString(); |
|
241 |
} |
|
242 |
xml.putProperty("keys", sk); |
|
243 |
|
|
244 |
|
|
245 |
for (int i = 0; i < keys.size(); i++) { |
|
246 |
xml.addChild(getSymbolByID(i).getXMLEntity()); |
|
247 |
} |
|
248 |
} |
|
247 | 249 |
return xml; |
248 | 250 |
} |
249 | 251 |
|
... | ... | |
255 | 257 |
* @return DOCUMENT ME! |
256 | 258 |
*/ |
257 | 259 |
public void setXMLEntity(XMLEntity xml) { |
260 |
clear(); |
|
261 |
setFieldName(xml.getStringProperty("fieldName")); |
|
262 |
setLabelField(xml.getStringProperty("labelfield")); |
|
263 |
boolean useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol"); |
|
264 |
if (useDefaultSymbol) |
|
265 |
setDefaultSymbol(FSymbol.createFSymbol(xml.getChild(0))); |
|
266 |
else |
|
267 |
setDefaultSymbol(null); |
|
268 |
int numKeys = xml.getIntProperty("numKeys"); |
|
269 |
if (numKeys > 0) |
|
270 |
{ |
|
271 |
String className = xml.getStringProperty("tipoValueKeys"); |
|
272 |
String[] sk = xml.getStringArrayProperty("keys"); |
|
273 |
Value auxValue; |
|
274 |
for (int i = 0; i < numKeys; i++) { |
|
275 |
try { |
|
276 |
auxValue = ValueFactory.createValue(sk[i], className); |
|
277 |
symbols.put(auxValue, FSymbol.createFSymbol(xml.getChild(i+1))); |
|
278 |
} catch (SemanticException e) { |
|
279 |
// TODO Auto-generated catch block |
|
280 |
e.printStackTrace(); |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
} |
|
285 |
|
|
286 |
|
|
287 |
|
|
258 | 288 |
} |
259 | 289 |
|
260 | 290 |
/** |
Also available in: Unified diff