svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / VectorialIntervalLegend.java @ 435
History | View | Annotate | Download (5.27 KB)
1 |
package com.iver.cit.gvsig.fmap.rendering; |
---|---|
2 |
|
3 |
import java.util.HashMap; |
4 |
|
5 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
6 |
import com.iver.utiles.XMLEntity; |
7 |
|
8 |
|
9 |
/**
|
10 |
* DOCUMENT ME!
|
11 |
*
|
12 |
* @author Vicente Caballero Navarro
|
13 |
*/
|
14 |
public class VectorialIntervalLegend implements IntervalLegend, VectorialLegend { |
15 |
private HashMap symbols = new HashMap(); |
16 |
private HashMap values = new HashMap(); |
17 |
private int index = 0; |
18 |
private int field; |
19 |
private int labelfield; |
20 |
private FStyle2D defaultSymbol;
|
21 |
|
22 |
/*
|
23 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(java.lang.Object)
|
24 |
*
|
25 |
public FStyle2D getSymbol(Object value) {
|
26 |
return (FStyle2D) symbols.get(value);
|
27 |
}
|
28 |
// TODO transformar la funci?n anterior en la siguiente
|
29 |
*
|
30 |
*/
|
31 |
|
32 |
/**
|
33 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(int)
|
34 |
*/
|
35 |
public FStyle2D getSymbol(int recordIndex) { |
36 |
return null; |
37 |
} |
38 |
|
39 |
/**
|
40 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getDescriptions()
|
41 |
*/
|
42 |
public String[] getDescriptions() { |
43 |
return null; |
44 |
} |
45 |
|
46 |
/**
|
47 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getValues()
|
48 |
*/
|
49 |
public Object[] getValues() { |
50 |
return (Object[]) symbols.keySet().toArray(new Object[0]); |
51 |
} |
52 |
|
53 |
/**
|
54 |
* DOCUMENT ME!
|
55 |
*
|
56 |
* @return DOCUMENT ME!
|
57 |
*/
|
58 |
private int[] getIndexs() { |
59 |
Integer[] integers = (Integer[]) values.keySet().toArray(new Integer[0]); |
60 |
int[] ent = new int[integers.length]; |
61 |
|
62 |
for (int i = 0; i < integers.length; i++) { |
63 |
ent[i] = integers[i].intValue(); |
64 |
} |
65 |
|
66 |
return ent;
|
67 |
} |
68 |
|
69 |
/**
|
70 |
* @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#setIntervalSymbol(com.iver.cit.gvsig.fmap.rendering.FInterval,
|
71 |
* org.geotools.renderer.style.Style2D)
|
72 |
*/
|
73 |
public void setIntervalSymbol(FInterval interval, FStyle2D symbol) { |
74 |
symbols.put(interval, symbol); |
75 |
values.put(new Integer(index), interval); |
76 |
index++; |
77 |
} |
78 |
|
79 |
/**
|
80 |
* @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#changeInterval(int,
|
81 |
* com.iver.cit.gvsig.fmap.rendering.FInterval)
|
82 |
*/
|
83 |
public void changeInterval(int index, FInterval newInterval) { |
84 |
Object value = values.remove(new Integer(index)); |
85 |
Object symbol = symbols.remove(value);
|
86 |
values.put(new Integer(index), newInterval); |
87 |
symbols.put(newInterval, symbol); |
88 |
} |
89 |
|
90 |
/**
|
91 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
|
92 |
*/
|
93 |
public void clear() { |
94 |
index = 0;
|
95 |
values.clear(); |
96 |
symbols.clear(); |
97 |
} |
98 |
|
99 |
/**
|
100 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
|
101 |
*/
|
102 |
public FStyle2D[] getSymbols() { |
103 |
return (FStyle2D[]) symbols.values().toArray(new FStyle2D[0]); |
104 |
} |
105 |
|
106 |
/**
|
107 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getField()
|
108 |
*/
|
109 |
public int getField() { |
110 |
return field;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#setDefaultSymbol(com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D)
|
115 |
*/
|
116 |
public void setDefaultSymbol(FStyle2D s) { |
117 |
defaultSymbol = s; |
118 |
} |
119 |
|
120 |
/**
|
121 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setField(int)
|
122 |
*/
|
123 |
public void setField(int i) { |
124 |
field = i; |
125 |
} |
126 |
|
127 |
/**
|
128 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
|
129 |
*/
|
130 |
public void setLabelField(int fieldIndex) { |
131 |
} |
132 |
|
133 |
/**
|
134 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getLabelField()
|
135 |
*/
|
136 |
public int getLabelField() { |
137 |
return 0; |
138 |
} |
139 |
|
140 |
/**
|
141 |
* @see com.iver.cit.gvsig.fmap.rendering.LegendInfo#getDefaultSymbol()
|
142 |
*/
|
143 |
public FStyle2D getDefaultSymbol() {
|
144 |
return null; |
145 |
} |
146 |
|
147 |
/**
|
148 |
* @see com.iver.cit.gvsig.fmap.rendering.LegendInfo#getXMLEntity()
|
149 |
*/
|
150 |
public XMLEntity getXMLEntity() {
|
151 |
XMLEntity xml = new XMLEntity();
|
152 |
xml.putProperty("nameClass",this.getClass().getName()); |
153 |
//TODO defaultSymbol
|
154 |
xml.putProperty("field", field);
|
155 |
xml.putProperty("index", index);
|
156 |
xml.putProperty("labelfield", labelfield);
|
157 |
|
158 |
// TODO symbols
|
159 |
xml.putProperty("numSymbols", symbols.size());
|
160 |
xml.putProperty("indexs", getIndexs());
|
161 |
xml.putProperty("values", getValues());
|
162 |
|
163 |
return xml;
|
164 |
} |
165 |
public void setXMLEntity(XMLEntity xml) { |
166 |
//TODO vuvl.defaultSymbol=
|
167 |
field = xml.getIntProperty("field");
|
168 |
index = xml.getIntProperty("index");
|
169 |
labelfield = xml.getIntProperty("labelfield");
|
170 |
|
171 |
//TODO vuvl.symbols=
|
172 |
int numSymbols = xml.getIntProperty("numSymbols"); |
173 |
int[] indexs = xml.getIntArrayProperty("indexs"); |
174 |
Object[] val = xml.getStringArrayProperty("values"); |
175 |
|
176 |
for (int i = 0; i < numSymbols; i++) { |
177 |
values.put(new Integer(indexs[i]), val[i]); |
178 |
} |
179 |
} |
180 |
/**
|
181 |
* @throws IllegalAccessException
|
182 |
* @throws InstantiationException
|
183 |
* @throws ClassNotFoundException
|
184 |
* @see com.iver.cit.gvsig.fmap.rendering.LegendInfo#cloner()
|
185 |
*/
|
186 |
public LegendInfo cloner() throws ClassNotFoundException, InstantiationException, IllegalAccessException { |
187 |
return (LegendInfo)LegendFactory.createFromXML(getXMLEntity());
|
188 |
} |
189 |
} |