svn-gvsig-desktop / trunk / libraries / lib3DMap-share / src / main / java / com / iver / ai2 / gvsig3d / legend / ExtrusionLegend.java @ 25260
History | View | Annotate | Download (3.24 KB)
1 |
package com.iver.ai2.gvsig3d.legend; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
|
5 |
import com.hardcode.gdbms.engine.values.Value; |
6 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
7 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
8 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
9 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
10 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
11 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
12 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
13 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
14 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol; |
15 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
16 |
import com.iver.utiles.XMLEntity; |
17 |
|
18 |
public class ExtrusionLegend extends VectorialUniqueValueLegend { |
19 |
|
20 |
private BaseExtrusionSymbol defaultSimbolExtrusion;
|
21 |
private double extrusionFactor; |
22 |
|
23 |
|
24 |
public ExtrusionLegend(int shapeType) { |
25 |
super(shapeType);
|
26 |
} |
27 |
public ISymbol getSymbolByFeature(IFeature feat) {
|
28 |
return super.getSymbolByFeature(feat); |
29 |
} |
30 |
|
31 |
public ISymbol getSymbolByValue(Value key) {
|
32 |
ISymbol theSymbol = super.getSymbolByValue(key);
|
33 |
|
34 |
if (theSymbol== null) |
35 |
return null; |
36 |
double extrusion = Double.parseDouble(theSymbol.getDescription()); |
37 |
|
38 |
|
39 |
|
40 |
defaultSimbolExtrusion = new BaseExtrusionSymbol(extrusion);
|
41 |
if (theSymbol.getClass().equals(SimpleFillSymbol.class)) {// Nuevo s?mbolo pol?gono |
42 |
Color color = ((IFillSymbol)theSymbol).getFillColor();
|
43 |
defaultSimbolExtrusion.setFillColor(color); |
44 |
} |
45 |
else if (theSymbol.getClass().equals(SimpleLineSymbol.class)) {// Nuevo s?mbolo l?nea |
46 |
Color color = ((ILineSymbol)theSymbol).getColor();
|
47 |
defaultSimbolExtrusion.setFillColor(color); |
48 |
} |
49 |
else if (theSymbol.getClass().equals(SimpleMarkerSymbol.class)) {// Nuevo s?mbolo punto |
50 |
Color color = ((IMarkerSymbol)theSymbol).getColor();
|
51 |
defaultSimbolExtrusion.setFillColor(color); |
52 |
} |
53 |
|
54 |
// defaultSimbolExtrusion.setExtrusion(factorExtrusion);
|
55 |
|
56 |
return defaultSimbolExtrusion;
|
57 |
} |
58 |
|
59 |
public String getClassName() { |
60 |
return getClass().getName();
|
61 |
} |
62 |
|
63 |
public double getExtrusionFactor() { |
64 |
return extrusionFactor;
|
65 |
} |
66 |
|
67 |
public void setExtrusionFactor(double extrusionFactor) { |
68 |
this.extrusionFactor = extrusionFactor;
|
69 |
} |
70 |
|
71 |
|
72 |
public XMLEntity getXMLEntity() {
|
73 |
// XMLEntity xml = super.getXMLEntity();
|
74 |
XMLEntity xml = new XMLEntity();
|
75 |
xml.putProperty("className", this.getClassName()); |
76 |
xml.putProperty("fieldNames", getClassifyingFieldNames()[0]); |
77 |
xml.putProperty("fieldTypes", getClassifyingFieldTypes()[0]); |
78 |
xml.putProperty("extrusionFactor", this.extrusionFactor); |
79 |
return xml;
|
80 |
|
81 |
} |
82 |
|
83 |
public void setXMLEntity(XMLEntity xml) { |
84 |
// TODO: It is necessary to insert here all the properties to load with the extrusion legend.
|
85 |
// super.setXMLEntity(xml);
|
86 |
clear(); |
87 |
if (xml.contains("fieldName")) |
88 |
setClassifyingFieldNames(new String[] {xml.getStringProperty("fieldName")}); |
89 |
else
|
90 |
setClassifyingFieldNames(xml.getStringArrayProperty("fieldNames"));
|
91 |
|
92 |
if (xml.contains("fieldTypes")) |
93 |
setClassifyingFieldTypes(new int[] {xml.getIntProperty("fieldTypes")}); |
94 |
if (xml.contains("extrusionFactor")) |
95 |
extrusionFactor = xml.getDoubleProperty("extrusionFactor");
|
96 |
|
97 |
} |
98 |
|
99 |
} |