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 / PieChartLegend.java @ 571
History | View | Annotate | Download (4.94 KB)
1 |
package org.gvsig.project.documents.view.legend; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import org.gvsig.chart.legend.IChartLegend; |
5 |
import org.gvsig.chart.legend.IPieChartLegend; |
6 |
import org.gvsig.chart.legend.symbols.IChartSymbol; |
7 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
8 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
9 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
10 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
11 |
import static org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend.VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME; |
12 |
import org.gvsig.tools.ToolsLocator; |
13 |
import org.gvsig.tools.dynobject.DynStruct; |
14 |
import org.gvsig.tools.persistence.PersistenceManager; |
15 |
import org.gvsig.tools.persistence.PersistentState; |
16 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
17 |
import org.gvsig.tools.util.Callable; |
18 |
|
19 |
/**
|
20 |
* @author Fjp
|
21 |
*
|
22 |
* TODO: CAMBIAR EL NOMBRE DE ESTA LEYENDA A CHARTLEGEND, PORQUE EN REALIDAD
|
23 |
* ESTA SE USA PARA TODO TIPO DE CHARTS. (BarsChartLegend no se usa, borrarla)
|
24 |
*/
|
25 |
public final class PieChartLegend extends BasePieChartLegend implements IPieChartLegend { |
26 |
|
27 |
public static class RegisterLegend implements Callable { |
28 |
|
29 |
@Override
|
30 |
public Object call() throws Exception { |
31 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
32 |
|
33 |
manager.registerLegend(IChartLegend.PIECHART_LEGEND_NAME, |
34 |
PieChartLegend.class); |
35 |
|
36 |
return Boolean.TRUE; |
37 |
} |
38 |
|
39 |
} |
40 |
|
41 |
public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend"; |
42 |
|
43 |
private static final String FIELD_NAMES = "FieldLegendNames"; |
44 |
private static final String FIELD_LABEL_NAMES = "FieldLabelNames"; |
45 |
private static final String FIELD_LABEL_COLOR = "FieldLabelColor"; |
46 |
|
47 |
public PieChartLegend() {
|
48 |
super();
|
49 |
} |
50 |
|
51 |
public PieChartLegend(int shapeType) { |
52 |
super(shapeType);
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
public void loadFromState(PersistentState state) throws PersistenceException { |
57 |
// Set parent properties
|
58 |
super.loadFromState(state);
|
59 |
|
60 |
} |
61 |
|
62 |
@Override
|
63 |
public void saveToState(PersistentState state) throws PersistenceException { |
64 |
// Save parent properties
|
65 |
super.saveToState(state);
|
66 |
} |
67 |
|
68 |
public static class RegisterPersistence implements Callable { |
69 |
|
70 |
@Override
|
71 |
public Object call() throws Exception { |
72 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
73 |
if (manager.getDefinition(PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) { |
74 |
DynStruct definition = manager.addDefinition( |
75 |
PieChartLegend.class, |
76 |
PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME, |
77 |
PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME + " Persistence definition",
|
78 |
null,
|
79 |
null
|
80 |
); |
81 |
// Extend the Classified Vector Legend base definition
|
82 |
definition.extend(manager.getDefinition(VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME)); |
83 |
|
84 |
// Field names
|
85 |
definition.addDynFieldArray(FIELD_NAMES) |
86 |
.setClassOfItems(String.class);
|
87 |
definition.addDynFieldArray(FIELD_LABEL_NAMES) |
88 |
.setClassOfItems(String.class);
|
89 |
definition.addDynFieldArray(FIELD_LABEL_COLOR) |
90 |
.setClassOfItems(Color.class);
|
91 |
|
92 |
definition.addDynField("backgroundSymbol").setClassOfValue(ISymbol.class);
|
93 |
definition.addDynFieldInt("size");
|
94 |
definition.addDynFieldBoolean("is3D");
|
95 |
|
96 |
definition.addDynFieldBoolean("isOutlineShow");
|
97 |
definition.addDynFieldBoolean("onlySelection");
|
98 |
definition.addDynFieldBoolean("isActiveLimits");
|
99 |
|
100 |
definition.addDynFieldInt("outlineWidth");
|
101 |
definition.addDynFieldInt("referenceSystem");
|
102 |
definition.addDynFieldInt("sizeFrom");
|
103 |
definition.addDynFieldInt("sizeTo");
|
104 |
definition.addDynFieldInt("unit");
|
105 |
definition.addDynFieldInt("sizeOption");
|
106 |
|
107 |
definition.addDynFieldObject("outlineColor").setClassOfValue(Color.class); |
108 |
definition.addDynFieldObject("symbol").setClassOfValue(IChartSymbol.class);
|
109 |
definition.addDynFieldObject("featSelection").setClassOfValue(FeatureSelection.class);
|
110 |
|
111 |
definition.addDynFieldString("fieldSize");
|
112 |
definition.addDynFieldString("fieldNormalize");
|
113 |
|
114 |
definition.addDynFieldDouble("minFeature");
|
115 |
definition.addDynFieldDouble("maxFeature");
|
116 |
definition.addDynFieldDouble("maxField");
|
117 |
} |
118 |
return Boolean.TRUE; |
119 |
} |
120 |
|
121 |
} |
122 |
|
123 |
} |