root / org.gvsig.chart / trunk / org.gvsig.chart / org.gvsig.chart.app / org.gvsig.chart.app.legendplugin / src / main / java / org / gvsig / project / documents / view / legend / BasePieChartLegend.java @ 571
History | View | Annotate | Download (18.6 KB)
1 | 369 | fdiaz | package org.gvsig.project.documents.view.legend; |
---|---|---|---|
2 | |||
3 | import java.awt.Color; |
||
4 | import java.awt.Graphics2D; |
||
5 | import java.awt.image.BufferedImage; |
||
6 | import java.util.ArrayList; |
||
7 | import java.util.List; |
||
8 | import java.util.Map; |
||
9 | |||
10 | import org.cresques.cts.ICoordTrans; |
||
11 | 381 | fdiaz | import org.jfree.chart.LegendItem; |
12 | import org.slf4j.Logger; |
||
13 | import org.slf4j.LoggerFactory; |
||
14 | |||
15 | 369 | fdiaz | import org.gvsig.chart.ChartLocator; |
16 | import org.gvsig.chart.ChartService; |
||
17 | import org.gvsig.chart.legend.symbols.IChartSymbol; |
||
18 | import org.gvsig.chart.model.ChartDataSet; |
||
19 | import org.gvsig.chart.renderer.ChartSerieEntity; |
||
20 | import org.gvsig.fmap.dal.exception.DataException; |
||
21 | import org.gvsig.fmap.dal.feature.Feature; |
||
22 | import org.gvsig.fmap.dal.feature.FeatureQuery; |
||
23 | import org.gvsig.fmap.dal.feature.FeatureSelection; |
||
24 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
25 | import org.gvsig.fmap.mapcontext.MapContextException; |
||
26 | import org.gvsig.fmap.mapcontext.MapContextLocator; |
||
27 | import org.gvsig.fmap.mapcontext.ViewPort; |
||
28 | import org.gvsig.fmap.mapcontext.rendering.legend.LegendException; |
||
29 | import org.gvsig.fmap.mapcontext.rendering.legend.ZSort; |
||
30 | import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
||
31 | 381 | fdiaz | import org.gvsig.symbology.SymbologyLocator; |
32 | 369 | fdiaz | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend; |
33 | 381 | fdiaz | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol; |
34 | 369 | fdiaz | import org.gvsig.tools.persistence.PersistentState; |
35 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
36 | import org.gvsig.tools.task.Cancellable; |
||
37 | |||
38 | /**
|
||
39 | * @author Fjp
|
||
40 | *
|
||
41 | * TODO: CAMBIAR EL NOMBRE DE ESTA LEYENDA A CHARTLEGEND, PORQUE EN REALIDAD
|
||
42 | * ESTA SE USA PARA TODO TIPO DE CHARTS. (BarsChartLegend no se usa, borrarla)
|
||
43 | */
|
||
44 | public class BasePieChartLegend extends VectorialUniqueValueLegend { |
||
45 | 571 | fdiaz | |
46 | 381 | fdiaz | final static private Logger LOG = LoggerFactory.getLogger(BasePieChartLegend.class); |
47 | 369 | fdiaz | |
48 | 571 | fdiaz | public static final String BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "BasePieChartLegend"; |
49 | 369 | fdiaz | |
50 | 571 | fdiaz | private static final String FIELD_NAMES = "FieldLegendNames"; |
51 | private static final String FIELD_LABEL_NAMES = "FieldLabelNames"; |
||
52 | private static final String FIELD_LABEL_COLOR = "FieldLabelColor"; |
||
53 | 369 | fdiaz | |
54 | 571 | fdiaz | protected ISymbol backgroundSymbol;
|
55 | protected String[] fields; |
||
56 | protected String[] labels; |
||
57 | protected int size = 150; |
||
58 | protected boolean is3D; |
||
59 | 369 | fdiaz | |
60 | 571 | fdiaz | protected boolean isOutlineShow; |
61 | protected Color outlineColor; |
||
62 | protected int outlineWidth; |
||
63 | protected boolean onlySelection = false; |
||
64 | protected int referenceSystem = 0; |
||
65 | protected String fieldSize; |
||
66 | protected String fieldNormalize = "---"; |
||
67 | protected int sizeFrom = 10; |
||
68 | protected int sizeTo = 1000; |
||
69 | protected int unit = -1; |
||
70 | protected int sizeOption = IChartSymbol.SIZEFIXED; |
||
71 | protected ZSort zSort = null; |
||
72 | protected boolean isActiveLimits; |
||
73 | protected double minFeature; |
||
74 | protected double maxFeature; |
||
75 | protected Color[] colors = null; |
||
76 | protected IChartSymbol symbol;
|
||
77 | private double maxField; |
||
78 | protected FeatureSelection featSelection;
|
||
79 | 369 | fdiaz | |
80 | 571 | fdiaz | public BasePieChartLegend() {
|
81 | } |
||
82 | 369 | fdiaz | |
83 | 571 | fdiaz | public BasePieChartLegend(int shapeType) { |
84 | super(shapeType);
|
||
85 | } |
||
86 | 369 | fdiaz | |
87 | 571 | fdiaz | @Override
|
88 | public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
89 | Cancellable cancel, double scale, Map queryParameters, |
||
90 | ICoordTrans coordTrans, FeatureStore featureStore, |
||
91 | FeatureQuery featureQuery) throws LegendException {
|
||
92 | try {
|
||
93 | this.featSelection = featureStore.getFeatureSelection();
|
||
94 | System.out.println("CHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados."); |
||
95 | } catch (DataException e) {
|
||
96 | e.printStackTrace(); |
||
97 | } |
||
98 | 369 | fdiaz | |
99 | 571 | fdiaz | super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
|
100 | featureStore, featureQuery); |
||
101 | } |
||
102 | 369 | fdiaz | |
103 | 571 | fdiaz | /* (non-Javadoc)
|
104 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#is3D()
|
105 | 571 | fdiaz | */
|
106 | public boolean is3D() { |
||
107 | return is3D;
|
||
108 | } |
||
109 | 369 | fdiaz | |
110 | 571 | fdiaz | /* (non-Javadoc)
|
111 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setIs3D(boolean)
|
112 | 571 | fdiaz | */
|
113 | public void setIs3D(boolean b) { |
||
114 | is3D = b; |
||
115 | } |
||
116 | 369 | fdiaz | |
117 | 571 | fdiaz | /* (non-Javadoc)
|
118 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getSize()
|
119 | 571 | fdiaz | */
|
120 | public int getSize() { |
||
121 | return size;
|
||
122 | } |
||
123 | 369 | fdiaz | |
124 | 571 | fdiaz | /* (non-Javadoc)
|
125 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setSize(int)
|
126 | 571 | fdiaz | */
|
127 | public void setSize(int size) { |
||
128 | this.size = size;
|
||
129 | } |
||
130 | 369 | fdiaz | |
131 | 571 | fdiaz | /* (non-Javadoc)
|
132 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOutlineShow()
|
133 | 571 | fdiaz | */
|
134 | public boolean isOutlineShow() { |
||
135 | return isOutlineShow;
|
||
136 | } |
||
137 | 369 | fdiaz | |
138 | 571 | fdiaz | /* (non-Javadoc)
|
139 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineShow(boolean)
|
140 | 571 | fdiaz | */
|
141 | public void setOutlineShow(boolean isOutlineShow) { |
||
142 | this.isOutlineShow = isOutlineShow;
|
||
143 | } |
||
144 | 369 | fdiaz | |
145 | 571 | fdiaz | /* (non-Javadoc)
|
146 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineColor()
|
147 | 571 | fdiaz | */
|
148 | public Color getOutlineColor() { |
||
149 | return outlineColor;
|
||
150 | } |
||
151 | 369 | fdiaz | |
152 | 571 | fdiaz | /* (non-Javadoc)
|
153 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineColor(java.awt.Color)
|
154 | 571 | fdiaz | */
|
155 | public void setOutlineColor(Color outlineColor) { |
||
156 | this.outlineColor = outlineColor;
|
||
157 | } |
||
158 | 369 | fdiaz | |
159 | 571 | fdiaz | /* (non-Javadoc)
|
160 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineWidth()
|
161 | 571 | fdiaz | */
|
162 | public int getOutlineWidth() { |
||
163 | return outlineWidth;
|
||
164 | } |
||
165 | 369 | fdiaz | |
166 | 571 | fdiaz | /* (non-Javadoc)
|
167 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineWidth(int)
|
168 | 571 | fdiaz | */
|
169 | public void setOutlineWidth(int outlineWidth) { |
||
170 | this.outlineWidth = outlineWidth;
|
||
171 | } |
||
172 | |||
173 | /* (non-Javadoc)
|
||
174 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOnlySelection(boolean)
|
175 | 571 | fdiaz | */
|
176 | public void setOnlySelection(boolean onlySelection) { |
||
177 | this.onlySelection = onlySelection;
|
||
178 | } |
||
179 | 369 | fdiaz | |
180 | 571 | fdiaz | /* (non-Javadoc)
|
181 | 369 | fdiaz | * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOnlySelection()
|
182 | 571 | fdiaz | */
|
183 | public boolean isOnlySelection() { |
||
184 | return onlySelection;
|
||
185 | } |
||
186 | 369 | fdiaz | |
187 | 571 | fdiaz | public ISymbol getBackgroundSymbol() {
|
188 | return backgroundSymbol;
|
||
189 | } |
||
190 | 369 | fdiaz | |
191 | 571 | fdiaz | public void setBackgroundSymbol(ISymbol backgroundSymbol) { |
192 | this.backgroundSymbol = backgroundSymbol;
|
||
193 | } |
||
194 | 369 | fdiaz | |
195 | 571 | fdiaz | public int getSizeOption() { |
196 | return this.sizeOption; |
||
197 | } |
||
198 | 369 | fdiaz | |
199 | 571 | fdiaz | public String getFieldSize() { |
200 | return this.fieldSize; |
||
201 | } |
||
202 | 369 | fdiaz | |
203 | 571 | fdiaz | public String getFieldNormalize() { |
204 | return this.fieldNormalize; |
||
205 | } |
||
206 | 369 | fdiaz | |
207 | 571 | fdiaz | public int getSizeFrom() { |
208 | return this.sizeFrom; |
||
209 | } |
||
210 | 369 | fdiaz | |
211 | 571 | fdiaz | public int getSizeTo() { |
212 | return this.sizeTo; |
||
213 | } |
||
214 | 369 | fdiaz | |
215 | 571 | fdiaz | public int getUnit() { |
216 | return unit;
|
||
217 | } |
||
218 | 369 | fdiaz | |
219 | 571 | fdiaz | public void setSizeFrom(int s) { |
220 | this.sizeFrom = s;
|
||
221 | } |
||
222 | 369 | fdiaz | |
223 | 571 | fdiaz | public void setSizeTo(int s) { |
224 | this.sizeTo = s;
|
||
225 | } |
||
226 | 369 | fdiaz | |
227 | 571 | fdiaz | public void setUnit(int unit) { |
228 | this.unit = unit;
|
||
229 | } |
||
230 | 369 | fdiaz | |
231 | 571 | fdiaz | public void setFieldSize(String f) { |
232 | this.fieldSize = f;
|
||
233 | } |
||
234 | 369 | fdiaz | |
235 | 571 | fdiaz | public void setFieldNormalize(String f) { |
236 | this.fieldNormalize = f;
|
||
237 | } |
||
238 | 369 | fdiaz | |
239 | 571 | fdiaz | public void setSizeOption(int option) { |
240 | this.sizeOption = option;
|
||
241 | } |
||
242 | 369 | fdiaz | |
243 | 571 | fdiaz | public boolean isActiveLimits() { |
244 | return isActiveLimits;
|
||
245 | } |
||
246 | 369 | fdiaz | |
247 | 571 | fdiaz | public void setActiveLimits(boolean b) { |
248 | this.isActiveLimits = b;
|
||
249 | } |
||
250 | 369 | fdiaz | |
251 | 571 | fdiaz | public Color[] getColors() { |
252 | return colors;
|
||
253 | } |
||
254 | 369 | fdiaz | |
255 | 571 | fdiaz | public void setColors(Color[] colors) { |
256 | this.colors = colors;
|
||
257 | updateSymbols(); |
||
258 | } |
||
259 | 369 | fdiaz | |
260 | 571 | fdiaz | public int getReferenceSystem() { |
261 | return referenceSystem;
|
||
262 | } |
||
263 | 369 | fdiaz | |
264 | 571 | fdiaz | public void setReferenceSystem(int rs) { |
265 | this.referenceSystem = rs;
|
||
266 | } |
||
267 | 369 | fdiaz | |
268 | 571 | fdiaz | public void setMinFeature(double min) { |
269 | this.minFeature = min;
|
||
270 | } |
||
271 | 369 | fdiaz | |
272 | 571 | fdiaz | public void setMaxFeature(double max) { |
273 | this.maxFeature = max;
|
||
274 | } |
||
275 | 369 | fdiaz | |
276 | 571 | fdiaz | @Override
|
277 | public ISymbol getSymbolByFeature(Feature feat) throws MapContextException { |
||
278 | 369 | fdiaz | |
279 | 571 | fdiaz | if (this.onlySelection) { |
280 | if (!featSelection.isSelected(feat)) {
|
||
281 | return null; |
||
282 | } |
||
283 | } |
||
284 | 369 | fdiaz | |
285 | 571 | fdiaz | // TODO: AQU? PRODR?AMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
|
286 | symbol = (IChartSymbol) getDefaultSymbol(); |
||
287 | if (symbol == null) { |
||
288 | symbol = (IChartSymbol) MapContextLocator |
||
289 | .getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME); |
||
290 | 369 | fdiaz | |
291 | 571 | fdiaz | } |
292 | symbol.setOnlySelection(onlySelection); |
||
293 | double size = 0; |
||
294 | 369 | fdiaz | |
295 | 571 | fdiaz | ChartDataSet dataSet = ChartLocator.getServiceManager() |
296 | .getChartManager().createChartDataSet(); |
||
297 | 369 | fdiaz | |
298 | 571 | fdiaz | String[] names = getFieldNames(); |
299 | String[] labels = getFieldLabels(); |
||
300 | if (names != null && labels != null && labels.length == names.length) { |
||
301 | 369 | fdiaz | |
302 | 571 | fdiaz | ArrayList serie = new ArrayList(); |
303 | ArrayList category = new ArrayList(); |
||
304 | for (int i = 0; i < names.length; i++) { |
||
305 | double val = feat.getDouble(names[i]);
|
||
306 | if (sizeOption == IChartSymbol.SIZESUM) {
|
||
307 | size += val; |
||
308 | } |
||
309 | if (!this.onlySelection || featSelection.isSelected(feat)) { |
||
310 | serie.add(labels[i]); |
||
311 | category.add(val); |
||
312 | } |
||
313 | } |
||
314 | dataSet.addData("series", serie);
|
||
315 | dataSet.addData("categories", category);
|
||
316 | 369 | fdiaz | |
317 | 571 | fdiaz | if (!this.onlySelection || featSelection.isSelected(feat)) { |
318 | symbol.getChart().setChartDataSet(dataSet); |
||
319 | } |
||
320 | ChartService cs = symbol.getChart(); |
||
321 | 369 | fdiaz | |
322 | 571 | fdiaz | List<ChartSerieEntity> lst = cs.getChartLegendItems();
|
323 | 369 | fdiaz | |
324 | 571 | fdiaz | for (int j = 0; j < names.length; j++) { |
325 | LegendItem item = new LegendItem(names[j], getSymbolByValue(names[j]).getColor());
|
||
326 | item.setSeriesKey(names[j]); |
||
327 | ChartSerieEntity e = cs.createNewChartSerieEntity(item); |
||
328 | if (e != null) { |
||
329 | lst.add(e); |
||
330 | } |
||
331 | } |
||
332 | } |
||
333 | double separation = sizeTo - sizeFrom;
|
||
334 | 369 | fdiaz | |
335 | 571 | fdiaz | switch (sizeOption) {
|
336 | case IChartSymbol.SIZESUM:
|
||
337 | if (isActiveLimits()) {
|
||
338 | double difFeat = maxFeature - minFeature;
|
||
339 | double step = difFeat / separation;
|
||
340 | size = sizeFrom + ((size - minFeature) / step); |
||
341 | } |
||
342 | symbol.setSize(size); |
||
343 | break;
|
||
344 | case IChartSymbol.SIZEFIELD:
|
||
345 | if (separation == 0) { |
||
346 | separation = 1;
|
||
347 | } |
||
348 | double value = feat.getDouble(getFieldSize());
|
||
349 | if (!getFieldNormalize().equals("---")) { |
||
350 | double normalize = feat.getDouble(getFieldNormalize());
|
||
351 | if (normalize != 0) { |
||
352 | value = value / normalize; |
||
353 | } |
||
354 | if (isActiveLimits()) {
|
||
355 | size = sizeFrom + (value * separation); |
||
356 | } else {
|
||
357 | size = value; |
||
358 | } |
||
359 | } else {
|
||
360 | if (isActiveLimits()) {
|
||
361 | double difFeat = maxFeature - minFeature;
|
||
362 | double step = difFeat / separation;
|
||
363 | size = sizeFrom + ((value - minFeature) / step); |
||
364 | } else {
|
||
365 | size = value; |
||
366 | } |
||
367 | } |
||
368 | symbol.setSize(size); |
||
369 | break;
|
||
370 | default:
|
||
371 | symbol.setSize(getSize()); |
||
372 | break;
|
||
373 | } |
||
374 | return symbol;
|
||
375 | 369 | fdiaz | |
376 | 571 | fdiaz | } |
377 | 369 | fdiaz | |
378 | 571 | fdiaz | public String[] getFieldNames() { |
379 | return fields;
|
||
380 | } |
||
381 | 369 | fdiaz | |
382 | 571 | fdiaz | public String[] getFieldLabels() { |
383 | if (labels == null) { |
||
384 | return new String[0]; |
||
385 | } |
||
386 | return labels;
|
||
387 | } |
||
388 | 369 | fdiaz | |
389 | 571 | fdiaz | public void setFields(String[] fields) { |
390 | this.fields = fields;
|
||
391 | updateSymbols(); |
||
392 | } |
||
393 | 369 | fdiaz | |
394 | 571 | fdiaz | public void setLabels(String[] fields) { |
395 | this.labels = fields;
|
||
396 | updateSymbols(); |
||
397 | } |
||
398 | 369 | fdiaz | |
399 | 571 | fdiaz | @SuppressWarnings({"unchecked", "rawtypes"}) |
400 | public void loadFromState(PersistentState state) |
||
401 | throws PersistenceException {
|
||
402 | // Set parent properties
|
||
403 | super.loadFromState(state);
|
||
404 | 369 | fdiaz | |
405 | 571 | fdiaz | this.fields = state.getStringArray(FIELD_NAMES);
|
406 | this.labels = state.getStringArray(FIELD_LABEL_NAMES);
|
||
407 | this.colors = (Color[]) state.getArray(FIELD_LABEL_COLOR, Color.class); |
||
408 | // Set own properties
|
||
409 | this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol"); |
||
410 | this.size = state.getInt("size"); |
||
411 | this.is3D = state.getBoolean("is3D"); |
||
412 | 369 | fdiaz | |
413 | 571 | fdiaz | this.isOutlineShow = state.getBoolean("isOutlineShow"); |
414 | this.onlySelection = state.getBoolean("onlySelection"); |
||
415 | this.isActiveLimits = state.getBoolean("isActiveLimits"); |
||
416 | 369 | fdiaz | |
417 | 571 | fdiaz | this.outlineWidth = state.getInt("outlineWidth"); |
418 | this.referenceSystem = state.getInt("referenceSystem"); |
||
419 | this.sizeFrom = state.getInt("sizeFrom"); |
||
420 | this.sizeTo = state.getInt("sizeTo"); |
||
421 | this.unit = state.getInt("unit"); |
||
422 | this.sizeOption = state.getInt("sizeOption"); |
||
423 | 369 | fdiaz | |
424 | 571 | fdiaz | this.outlineColor = (Color) state.get("outlineColor"); |
425 | this.symbol = (IChartSymbol) state.get("symbol"); |
||
426 | this.featSelection = (FeatureSelection) state.get("featSelection"); |
||
427 | 369 | fdiaz | |
428 | 571 | fdiaz | this.fieldSize = state.getString("fieldSize"); |
429 | this.fieldNormalize = state.getString("fieldNormalize"); |
||
430 | 369 | fdiaz | |
431 | 571 | fdiaz | this.minFeature = state.getDouble("minFeature"); |
432 | this.maxFeature = state.getDouble("maxFeature"); |
||
433 | this.maxField = state.getDouble("maxField"); |
||
434 | } |
||
435 | 369 | fdiaz | |
436 | 571 | fdiaz | public void saveToState(PersistentState state) throws PersistenceException { |
437 | // Save parent properties
|
||
438 | super.saveToState(state);
|
||
439 | // Save own properties
|
||
440 | state.set(FIELD_NAMES, this.fields);
|
||
441 | state.set(FIELD_LABEL_NAMES, this.labels);
|
||
442 | state.set(FIELD_LABEL_COLOR, this.colors);
|
||
443 | 369 | fdiaz | |
444 | 571 | fdiaz | state.set("backgroundSymbol", this.backgroundSymbol); |
445 | state.set("size", this.size); |
||
446 | state.set("is3D", this.is3D); |
||
447 | 369 | fdiaz | |
448 | 571 | fdiaz | state.set("isOutlineShow", this.isOutlineShow); |
449 | state.set("onlySelection", this.onlySelection); |
||
450 | state.set("isActiveLimits", this.isActiveLimits); |
||
451 | 369 | fdiaz | |
452 | 571 | fdiaz | state.set("outlineWidth", this.outlineWidth); |
453 | state.set("referenceSystem", this.referenceSystem); |
||
454 | state.set("sizeFrom", this.sizeFrom); |
||
455 | state.set("sizeTo", this.sizeTo); |
||
456 | state.set("unit", this.unit); |
||
457 | state.set("sizeOption", this.sizeOption); |
||
458 | 369 | fdiaz | |
459 | 571 | fdiaz | state.set("outlineColor", this.outlineColor); |
460 | state.set("symbol", this.symbol); |
||
461 | state.set("featSelection", this.featSelection); |
||
462 | 369 | fdiaz | |
463 | 571 | fdiaz | state.set("fieldSize", this.fieldSize); |
464 | state.set("fieldNormalize", this.fieldNormalize); |
||
465 | 369 | fdiaz | |
466 | 571 | fdiaz | state.set("minFeature", this.minFeature); |
467 | state.set("maxFeature", this.maxFeature); |
||
468 | state.set("maxField", this.maxField); |
||
469 | 369 | fdiaz | |
470 | 571 | fdiaz | } |
471 | 369 | fdiaz | |
472 | 571 | fdiaz | // public static class RegisterPersistence implements Callable {
|
473 | //
|
||
474 | // public Object call() throws Exception {
|
||
475 | // PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
||
476 | // if( manager.getDefinition(BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
|
||
477 | // DynStruct definition = manager.addDefinition(
|
||
478 | // BasePieChartLegend.class,
|
||
479 | // BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
|
||
480 | // BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
||
481 | // null,
|
||
482 | // null
|
||
483 | // );
|
||
484 | // // Extend the Classified Vector Legend base definition
|
||
485 | // definition.extend(manager.getDefinition(VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME));
|
||
486 | //
|
||
487 | // // Field names
|
||
488 | // definition.addDynFieldArray(FIELD_NAMES)
|
||
489 | // .setClassOfItems(String.class);
|
||
490 | // definition.addDynFieldArray(FIELD_LABEL_NAMES)
|
||
491 | // .setClassOfItems(String.class);
|
||
492 | // definition.addDynFieldArray(FIELD_LABEL_COLOR)
|
||
493 | // .setClassOfItems(Color.class);
|
||
494 | //
|
||
495 | // definition.addDynField("backgroundSymbol").setClassOfValue(ISymbol.class);
|
||
496 | // definition.addDynFieldInt("size");
|
||
497 | // definition.addDynFieldBoolean("is3D");
|
||
498 | //
|
||
499 | // definition.addDynFieldBoolean("isOutlineShow");
|
||
500 | // definition.addDynFieldBoolean("onlySelection");
|
||
501 | // definition.addDynFieldBoolean("isActiveLimits");
|
||
502 | //
|
||
503 | // definition.addDynFieldInt("outlineWidth");
|
||
504 | // definition.addDynFieldInt("referenceSystem");
|
||
505 | // definition.addDynFieldInt("sizeFrom");
|
||
506 | // definition.addDynFieldInt("sizeTo");
|
||
507 | // definition.addDynFieldInt("unit");
|
||
508 | // definition.addDynFieldInt("sizeOption");
|
||
509 | //
|
||
510 | // definition.addDynFieldObject("outlineColor").setClassOfValue(Color.class);
|
||
511 | // definition.addDynFieldObject("symbol").setClassOfValue(IChartSymbol.class);
|
||
512 | // definition.addDynFieldObject("featSelection").setClassOfValue(FeatureSelection.class);
|
||
513 | //
|
||
514 | // definition.addDynFieldString("fieldSize");
|
||
515 | // definition.addDynFieldString("fieldNormalize");
|
||
516 | //
|
||
517 | // definition.addDynFieldDouble("minFeature");
|
||
518 | // definition.addDynFieldDouble("maxFeature");
|
||
519 | // definition.addDynFieldDouble("maxField");
|
||
520 | // }
|
||
521 | // return Boolean.TRUE;
|
||
522 | // }
|
||
523 | //
|
||
524 | // }
|
||
525 | 381 | fdiaz | protected void updateSymbols() { |
526 | ISymbol[] symbols = getSymbols();
|
||
527 | 571 | fdiaz | for (ISymbol symbol1 : symbols) {
|
528 | delSymbol(getSymbolKey(symbol1)); |
||
529 | 381 | fdiaz | } |
530 | if (fields != null && colors != null && labels != null) { |
||
531 | |||
532 | if (fields.length != colors.length) {
|
||
533 | LOG.warn("The length of fields and colors isn't the same: fields.length = " + fields.length
|
||
534 | 571 | fdiaz | + " fields.length = " + colors.length);
|
535 | 381 | fdiaz | } |
536 | |||
537 | if (fields.length != labels.length) {
|
||
538 | LOG.warn("The length of fields and labels isn't the same: fields.length = " + fields.length
|
||
539 | 571 | fdiaz | + " labels.length = " + labels.length);
|
540 | 381 | fdiaz | } |
541 | |||
542 | for (int i = 0; i < Math.min(fields.length, Math.min(labels.length, colors.length)); i++) { |
||
543 | 571 | fdiaz | ISimpleFillSymbol symbol1 = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol(); |
544 | symbol1.setColor(colors[i]); |
||
545 | symbol1.setDescription(labels[i]); |
||
546 | addSymbol(fields[i], symbol1); |
||
547 | 381 | fdiaz | } |
548 | } |
||
549 | } |
||
550 | 369 | fdiaz | } |