Revision 571 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

View differences:

PieChartLegend.java
1 1
package org.gvsig.project.documents.view.legend;
2 2

  
3 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
import org.gvsig.chart.ChartLocator;
12
import org.gvsig.chart.ChartService;
13 4
import org.gvsig.chart.legend.IChartLegend;
14 5
import org.gvsig.chart.legend.IPieChartLegend;
15 6
import org.gvsig.chart.legend.symbols.IChartSymbol;
16
import org.gvsig.chart.model.ChartDataSet;
17
import org.gvsig.chart.renderer.ChartSerieEntity;
18
import org.gvsig.fmap.dal.exception.DataException;
19
import org.gvsig.fmap.dal.feature.Feature;
20
import org.gvsig.fmap.dal.feature.FeatureQuery;
21 7
import org.gvsig.fmap.dal.feature.FeatureSelection;
22
import org.gvsig.fmap.dal.feature.FeatureStore;
23
import org.gvsig.fmap.mapcontext.MapContextException;
24 8
import org.gvsig.fmap.mapcontext.MapContextLocator;
25 9
import org.gvsig.fmap.mapcontext.MapContextManager;
26
import org.gvsig.fmap.mapcontext.ViewPort;
27
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
28
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
29 10
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
30
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
11
import static org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend.VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME;
31 12
import org.gvsig.tools.ToolsLocator;
32 13
import org.gvsig.tools.dynobject.DynStruct;
33 14
import org.gvsig.tools.persistence.PersistenceManager;
34 15
import org.gvsig.tools.persistence.PersistentState;
35 16
import org.gvsig.tools.persistence.exception.PersistenceException;
36
import org.gvsig.tools.task.Cancellable;
37 17
import org.gvsig.tools.util.Callable;
38
import org.jfree.chart.LegendItem;
39 18

  
40 19
/**
41 20
 * @author Fjp
......
43 22
 * TODO: CAMBIAR EL NOMBRE DE ESTA LEYENDA A CHARTLEGEND, PORQUE EN REALIDAD
44 23
 * ESTA SE USA PARA TODO TIPO DE CHARTS. (BarsChartLegend no se usa, borrarla)
45 24
 */
46
public final class PieChartLegend extends BasePieChartLegend implements IPieChartLegend{
25
public final class PieChartLegend extends BasePieChartLegend implements IPieChartLegend {
47 26

  
48
	public static class RegisterLegend implements Callable {
27
    public static class RegisterLegend implements Callable {
49 28

  
50
		public Object call() throws Exception {
51
	        MapContextManager manager = MapContextLocator.getMapContextManager();
29
        @Override
30
        public Object call() throws Exception {
31
            MapContextManager manager = MapContextLocator.getMapContextManager();
52 32

  
53 33
            manager.registerLegend(IChartLegend.PIECHART_LEGEND_NAME,
54 34
                    PieChartLegend.class);
55 35

  
56
			return Boolean.TRUE;
57
		}
36
            return Boolean.TRUE;
37
        }
58 38

  
59
	}
39
    }
60 40

  
61
	public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend";
41
    public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend";
62 42

  
63
	public PieChartLegend() {
64
	    super();
65
	}
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";
66 46

  
67
	public PieChartLegend(int shapeType) {
68
		super(shapeType);
69
	}
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

  
70 123
}

Also available in: Unified diff