Index: PieChartLegend.java
===================================================================
--- PieChartLegend.java	(revision 570)
+++ PieChartLegend.java	(revision 571)
@@ -1,41 +1,20 @@
 package org.gvsig.project.documents.view.legend;
 
 import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.cresques.cts.ICoordTrans;
-import org.gvsig.chart.ChartLocator;
-import org.gvsig.chart.ChartService;
 import org.gvsig.chart.legend.IChartLegend;
 import org.gvsig.chart.legend.IPieChartLegend;
 import org.gvsig.chart.legend.symbols.IChartSymbol;
-import org.gvsig.chart.model.ChartDataSet;
-import org.gvsig.chart.renderer.ChartSerieEntity;
-import org.gvsig.fmap.dal.exception.DataException;
-import org.gvsig.fmap.dal.feature.Feature;
-import org.gvsig.fmap.dal.feature.FeatureQuery;
 import org.gvsig.fmap.dal.feature.FeatureSelection;
-import org.gvsig.fmap.dal.feature.FeatureStore;
-import org.gvsig.fmap.mapcontext.MapContextException;
 import org.gvsig.fmap.mapcontext.MapContextLocator;
 import org.gvsig.fmap.mapcontext.MapContextManager;
-import org.gvsig.fmap.mapcontext.ViewPort;
-import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
-import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
 import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
-import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
+import static org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend.VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME;
 import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.dynobject.DynStruct;
 import org.gvsig.tools.persistence.PersistenceManager;
 import org.gvsig.tools.persistence.PersistentState;
 import org.gvsig.tools.persistence.exception.PersistenceException;
-import org.gvsig.tools.task.Cancellable;
 import org.gvsig.tools.util.Callable;
-import org.jfree.chart.LegendItem;
 
 /**
  * @author Fjp
@@ -43,28 +22,102 @@
  * TODO: CAMBIAR EL NOMBRE DE ESTA LEYENDA A CHARTLEGEND, PORQUE EN REALIDAD
  * ESTA SE USA PARA TODO TIPO DE CHARTS. (BarsChartLegend no se usa, borrarla)
  */
-public final class PieChartLegend extends BasePieChartLegend implements IPieChartLegend{
+public final class PieChartLegend extends BasePieChartLegend implements IPieChartLegend {
 
-	public static class RegisterLegend implements Callable {
+    public static class RegisterLegend implements Callable {
 
-		public Object call() throws Exception {
-	        MapContextManager manager = MapContextLocator.getMapContextManager();
+        @Override
+        public Object call() throws Exception {
+            MapContextManager manager = MapContextLocator.getMapContextManager();
 
             manager.registerLegend(IChartLegend.PIECHART_LEGEND_NAME,
                     PieChartLegend.class);
 
-			return Boolean.TRUE;
-		}
+            return Boolean.TRUE;
+        }
 
-	}
+    }
 
-	public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend";
+    public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend";
 
-	public PieChartLegend() {
-	    super();
-	}
+    private static final String FIELD_NAMES = "FieldLegendNames";
+    private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
+    private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
 
-	public PieChartLegend(int shapeType) {
-		super(shapeType);
-	}
+    public PieChartLegend() {
+        super();
+    }
+
+    public PieChartLegend(int shapeType) {
+        super(shapeType);
+    }
+
+    @Override
+    public void loadFromState(PersistentState state) throws PersistenceException {
+        // Set parent properties
+        super.loadFromState(state);
+
+    }
+
+    @Override
+    public void saveToState(PersistentState state) throws PersistenceException {
+        // Save parent properties
+        super.saveToState(state);
+    }
+
+    public static class RegisterPersistence implements Callable {
+
+        @Override
+        public Object call() throws Exception {
+            PersistenceManager manager = ToolsLocator.getPersistenceManager();
+            if (manager.getDefinition(PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) {
+                DynStruct definition = manager.addDefinition(
+                        PieChartLegend.class,
+                        PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
+                        PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME + " Persistence definition",
+                        null,
+                        null
+                );
+                // Extend the Classified Vector Legend base definition
+                definition.extend(manager.getDefinition(VECTORIAL_UNIQUE_VALUE_LEGEND_PERSISTENCE_DEFINITION_NAME));
+
+                // Field names
+                definition.addDynFieldArray(FIELD_NAMES)
+                        .setClassOfItems(String.class);
+                definition.addDynFieldArray(FIELD_LABEL_NAMES)
+                        .setClassOfItems(String.class);
+                definition.addDynFieldArray(FIELD_LABEL_COLOR)
+                        .setClassOfItems(Color.class);
+
+                definition.addDynField("backgroundSymbol").setClassOfValue(ISymbol.class);
+                definition.addDynFieldInt("size");
+                definition.addDynFieldBoolean("is3D");
+
+                definition.addDynFieldBoolean("isOutlineShow");
+                definition.addDynFieldBoolean("onlySelection");
+                definition.addDynFieldBoolean("isActiveLimits");
+
+                definition.addDynFieldInt("outlineWidth");
+                definition.addDynFieldInt("referenceSystem");
+                definition.addDynFieldInt("sizeFrom");
+                definition.addDynFieldInt("sizeTo");
+                definition.addDynFieldInt("unit");
+                definition.addDynFieldInt("sizeOption");
+
+                definition.addDynFieldObject("outlineColor").setClassOfValue(Color.class);
+                definition.addDynFieldObject("symbol").setClassOfValue(IChartSymbol.class);
+                definition.addDynFieldObject("featSelection").setClassOfValue(FeatureSelection.class);
+
+                definition.addDynFieldString("fieldSize");
+                definition.addDynFieldString("fieldNormalize");
+
+                definition.addDynFieldDouble("minFeature");
+                definition.addDynFieldDouble("maxFeature");
+                definition.addDynFieldDouble("maxField");
+            }
+            return Boolean.TRUE;
+        }
+
+    }
+
 }
