Index: 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/gui/ChartLegendPanelPie.java
===================================================================
--- 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/gui/ChartLegendPanelPie.java	(revision 570)
+++ 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/gui/ChartLegendPanelPie.java	(revision 571)
@@ -374,7 +374,6 @@
                         ((DefaultListModel) getJFieldList().getModel())
                                 .removeElement(fields[i]);
                     }
-                    actualizePreviewSymbol();
                 }
             });
         }
@@ -428,7 +427,6 @@
                                 .addElement(fields[i]);
                     }
                     getFieldsTable().removeSelectedRows();
-                    actualizePreviewSymbol();
                 }
             });
         }
@@ -463,30 +461,12 @@
                         ((DefaultListModel) getJFieldList().getModel())
                                 .removeElement(fields[i]);
                     }
-                    actualizePreviewSymbol();
                 }
             });
         }
         return addAllButton;
     }
 
-    private void actualizePreviewSymbol() {
-        int count = getFieldsTable().getRowCount();
-        String[] fieldsTable = new String[count];
-        for (int i = 0; i < count; i++) {
-            fieldsTable[i] = (String) getFieldsTable().getFieldValue(i, 1);
-        }
-        String[] labelsTable = new String[count];
-        for (int i = 0; i < count; i++) {
-            labelsTable[i] = (String) getFieldsTable().getFieldValue(i, 2);
-        }
-        Color[] colorsTable = new Color[count];
-        for (int i = 0; i < count; i++) {
-            colorsTable[i] = ((JPanel) getFieldsTable().getFieldValue(i, 0))
-                    .getBackground();
-        }
-    }
-
     /**
      * This method initializes removeAllButton
      *
@@ -502,7 +482,6 @@
                         public void actionPerformed(java.awt.event.ActionEvent e) {
                             fillFieldNames();
                             getFieldsTable().removeAllItems();
-                            actualizePreviewSymbol();
                         }
                     });
         }
Index: 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/gui/ChartLegendPanelBars.java
===================================================================
--- 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/gui/ChartLegendPanelBars.java	(revision 570)
+++ 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/gui/ChartLegendPanelBars.java	(revision 571)
@@ -70,7 +70,7 @@
     private JPanel centerPanel = null; // @jve:decl-index=0:visual-constraint="10,10"
     private JScrollPane jScrollPane = null;
     private JList jFieldList = null;
-    private Random rand = new Random(System.currentTimeMillis());
+    private final Random rand = new Random(System.currentTimeMillis());
     private JPanel buttons = null;
     private JButton addButton = null;
     private JButton removeButton = null;
@@ -300,12 +300,9 @@
             bSize.setText(PluginServices.getText(this, "size"));
             bSize.setPreferredSize(new Dimension(100, 30));
             bSize.setMaximumSize(new Dimension(100, 30));
-            bSize.addActionListener(new ActionListener() {
-                public void actionPerformed(ActionEvent e) {
-                    PluginServices.getMDIManager().addCentredWindow(
-                            new SizePanel(layer, (IChartLegend) getLegend()));
-                }
-
+            bSize.addActionListener((ActionEvent e) -> {
+                PluginServices.getMDIManager().addCentredWindow(
+                        new SizePanel(layer, (IChartLegend) getLegend()));
             });
         }
         return bSize;
@@ -346,23 +343,15 @@
             addButton = new JButton();
             addButton.setText(">");
             addButton.setPreferredSize(new Dimension(50, 40));
-            addButton.addActionListener(new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    Object[] fields = getJFieldList().getSelectedValues();
-                    Color[] colorScheme = colorCombo.getSelectedColors();
-
-                    Color[] colors = new Color[colorScheme.length];
-                    for (int i = 0; i < colorScheme.length; i++) {
-                        colors[i] = colorScheme[i];
-                    }
-                    for (int i = 0; i < fields.length; i++) {
-                        getFieldsTable().addTableRecord(
-                                colorScheme[rand.nextInt(colorScheme.length)],
-                                (String) fields[i], (String) fields[i]);
-                        ((DefaultListModel) getJFieldList().getModel())
-                                .removeElement(fields[i]);
-                    }
-                    actualizePreviewSymbol();
+            addButton.addActionListener((java.awt.event.ActionEvent e) -> {
+                Object[] fields = getJFieldList().getSelectedValues();
+                Color[] colorScheme = colorCombo.getSelectedColors();
+                
+                Color[] colors = new Color[colorScheme.length];
+                System.arraycopy(colorScheme, 0, colors, 0, colorScheme.length);
+                for (Object field : fields) {
+                    getFieldsTable().addTableRecord(colorScheme[rand.nextInt(colorScheme.length)], (String) field, (String) field);
+                    ((DefaultListModel) getJFieldList().getModel()).removeElement(field);
                 }
             });
         }
@@ -403,21 +392,17 @@
             removeButton = new JButton();
             removeButton.setPreferredSize(new Dimension(50, 40));
             removeButton.setText("<");
-            removeButton.addActionListener(new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    int[] index = getFieldsTable().getSelectedRows();
-                    String[] fields = new String[index.length];
-                    for (int i = 0; i < index.length; i++) {
-                        fields[i] = (String) getFieldsTable().getFieldValue(
-                                index[i], 1);
-                    }
-                    for (int i = 0; i < fields.length; i++) {
-                        ((DefaultListModel) getJFieldList().getModel())
-                                .addElement(fields[i]);
-                    }
-                    getFieldsTable().removeSelectedRows();
-                    actualizePreviewSymbol();
+            removeButton.addActionListener((java.awt.event.ActionEvent e) -> {
+                int[] index = getFieldsTable().getSelectedRows();
+                String[] fields = new String[index.length];
+                for (int i = 0; i < index.length; i++) {
+                    fields[i] = (String) getFieldsTable().getFieldValue(
+                            index[i], 1);
                 }
+                for (String field : fields) {
+                    ((DefaultListModel) getJFieldList().getModel()).addElement(field);
+                }
+                getFieldsTable().removeSelectedRows();
             });
         }
         return removeButton;
@@ -433,49 +418,23 @@
             addAllButton = new JButton();
             addAllButton.setPreferredSize(new Dimension(50, 40));
             addAllButton.setText(">>");
-            addAllButton.addActionListener(new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    Object[] fields = ((DefaultListModel) getJFieldList()
-                            .getModel()).toArray();
-
-                    Color[] colorScheme = colorCombo.getSelectedColors();
-
-                    Color[] colors = new Color[colorScheme.length];
-                    for (int i = 0; i < colorScheme.length; i++) {
-                        colors[i] = colorScheme[i];
-                    }
-                    for (int i = 0; i < fields.length; i++) {
-                        getFieldsTable().addTableRecord(
-                                colorScheme[rand.nextInt(colorScheme.length)],
-                                (String) fields[i], (String) fields[i]);
-                        ((DefaultListModel) getJFieldList().getModel())
-                                .removeElement(fields[i]);
-                    }
-                    actualizePreviewSymbol();
+            addAllButton.addActionListener((java.awt.event.ActionEvent e) -> {
+                Object[] fields = ((DefaultListModel) getJFieldList()
+                        .getModel()).toArray();
+                
+                Color[] colorScheme = colorCombo.getSelectedColors();
+                
+                Color[] colors = new Color[colorScheme.length];
+                System.arraycopy(colorScheme, 0, colors, 0, colorScheme.length);
+                for (Object field : fields) {
+                    getFieldsTable().addTableRecord(colorScheme[rand.nextInt(colorScheme.length)], (String) field, (String) field);
+                    ((DefaultListModel) getJFieldList().getModel()).removeElement(field);
                 }
             });
         }
         return addAllButton;
     }
 
-    private void actualizePreviewSymbol() {
-        int count = getFieldsTable().getRowCount();
-        String[] fieldsTable = new String[count];
-        for (int i = 0; i < count; i++) {
-            fieldsTable[i] = (String) getFieldsTable().getFieldValue(i, 1);
-        }
-        String[] labelsTable = new String[count];
-        for (int i = 0; i < count; i++) {
-            labelsTable[i] = (String) getFieldsTable().getFieldValue(i, 2);
-        }
-        Color[] colorsTable = new Color[count];
-        for (int i = 0; i < count; i++) {
-            colorsTable[i] = ((JPanel) getFieldsTable().getFieldValue(i, 0))
-                    .getBackground();
-        }
-
-    }
-
     /**
      * This method initializes removeAllButton
      *
@@ -754,7 +713,16 @@
                     props.setHasPlotOutline(auxLegend.isOutlineShow());
                     props.setIsLegendVisible(false);
                     props.setPlotBackgroundColor(auxLegend.getOutlineColor());
-                    props.setPlotBackgroundAlpha(colorButton.getAlpha() / 100);
+                    if (getJCheckBox().isSelected()) {
+                        float alpha = colorButton.getAlpha() / 100;
+                        if (alpha > 1) {
+                            props.setPlotBackgroundAlpha(1.0f);
+                        } else {
+                            props.setPlotBackgroundAlpha(alpha);
+                        }
+                    } else {
+                        props.setPlotBackgroundAlpha(0.0f);
+                    }
                     props.setIsMandatoryChart(jShowAxis.isSelected());
                     props.setIsXYPlotChart(false);
                     props.setChartDimension(auxLegend.is3D());
Index: 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/LinkedChartLegend.java
===================================================================
--- 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/LinkedChartLegend.java	(revision 570)
+++ 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/LinkedChartLegend.java	(revision 571)
@@ -1,5 +1,6 @@
 package org.gvsig.project.documents.view.legend;
 
+import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
 import java.util.ArrayList;
@@ -9,6 +10,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
 
 import org.cresques.cts.ICoordTrans;
 
@@ -38,6 +40,7 @@
 import org.gvsig.fmap.mapcontext.ViewPort;
 import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
 import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
+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.dispose.DisposableIterator;
 import org.gvsig.tools.dynobject.DynStruct;
@@ -51,518 +54,560 @@
 import org.jfree.chart.LegendItem;
 
 @Deprecated
-public final class LinkedChartLegend extends BasePieChartLegend implements ILinkedChartLegend{
+public final class LinkedChartLegend extends BasePieChartLegend implements ILinkedChartLegend {
 
-	public static class RegisterLegend implements Callable {
+    public static class RegisterLegend implements Callable {
 
-		public Object call() throws Exception {
-	        MapContextManager manager = MapContextLocator.getMapContextManager();
+        public Object call() throws Exception {
+            MapContextManager manager = MapContextLocator.getMapContextManager();
 
             manager.registerLegend(IChartLegend.LINKED_LEGEND_NAME,
-            		LinkedChartLegend.class);
+                    LinkedChartLegend.class);
 
-			return Boolean.TRUE;
-		}
+            return Boolean.TRUE;
+        }
 
-	}
+    }
 
+    public static final String LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "LinkedChartLegend";
 
-	public static final String LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "LinkedChartLegend";
+    private static final String FIELD_NAMES = "FieldLegendNames";
+    private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
+    private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
 
+    protected Map<String, List> indexHash;
+    private String linkedField;
+    private String groupedByField = "";
+    private List<String> linkedFieldValues;
+    private String[] linkedFieldTableNames;
+    private String[] linkedFieldName;
+    private String linkedTable;
+    private boolean originSelected;
+    private boolean destinationSelected;
+    private String[] linkedFields;
 
-	protected Map<String,List> indexHash = new HashMap<String,List>();
-	private String linkedField;
-	private String groupedByField="";
-	private List<String> linkedFieldValues;
-	private String[] linkedFieldTableNames;
-	private String[] linkedFieldName;
-	private String linkedTable;
-	private boolean originSelected;
-	private boolean destinationSelected;
-	private String[] linkedFields;
+    private String timeField;
 
+    private String legendType;
 
-	private String timeField;
+    public LinkedChartLegend() {
+        this.indexHash = new HashMap<>();
+    }
 
+    @Override
+    public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
+            Cancellable cancel, double scale, Map queryParameters,
+            ICoordTrans coordTrans, FeatureStore featureStore,
+            FeatureQuery featureQuery) throws LegendException {
+        FeatureSelection fsel;
+        try {
+            this.featSelection = featureStore.getFeatureSelection();
+            System.out.println("LINKEDCHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
+        } catch (DataException e) {
+            e.printStackTrace();
+        }
 
-	private String legendType;
+        super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
+                featureStore, featureQuery);
+    }
 
-	public LinkedChartLegend(){
-	}
+    /**
+     * Devuelve un array con los campos seleccionados a pintar de la capa
+     * enlazada
+     *
+     * @return
+     */
+    public String[] getLinkedClassifyingFieldNames() {
+        return getClassifyingFieldNames();
+    }
 
-	@Override
-	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
-			Cancellable cancel, double scale, Map queryParameters,
-			ICoordTrans coordTrans, FeatureStore featureStore,
-			FeatureQuery featureQuery) throws LegendException {
-		FeatureSelection fsel;
-		try {
-			this.featSelection = featureStore.getFeatureSelection();
-			System.out.println("LINKEDCHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
-		} catch (DataException e) {
-			e.printStackTrace();
-		}
+    @Override
+    public String[] getClassifyingFieldNames() {
+        return this.linkedFieldName;
+    }
 
+    @Override
+    public void setLinkedFieldName(String[] fieldName) {
+        this.linkedFieldName = fieldName;
+        updateSymbols();
+    }
 
-		super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
-				featureStore, featureQuery);
-	}
+    @Override
+    public void setDataHash(Map<String, List> hash) {
+        this.indexHash = hash;
+    }
 
-	/**
-	 * Devuelve un array con los campos seleccionados a pintar de la capa enlazada
-	 * @return
-	 */
-	public String[] getLinkedClassifyingFieldNames() {
-		return getClassifyingFieldNames();
-	}
+    @Override
+    public Set<String> getLinkedFieldValues() {
+        return this.indexHash.keySet();
+    }
 
+    public void setLinkedFieldValues(List<String> values) {
+        this.linkedFieldValues = values;
+        updateSymbols();
+    }
 
-	@Override
-	public String[] getClassifyingFieldNames() {
-		return this.linkedFieldName;
-	}
+    @Override
+    public Map<String, List> getLinkedData() {
 
-	public void setLinkedFieldName(String[] fieldName){
-		this.linkedFieldName = fieldName;
-		updateSymbols();
-	}
+        indexHash = new HashMap<>();
 
-	public void setDataHash(Map<String,List> hash){
-		this.indexHash  = hash;
-	}
+        ApplicationManager appManager = ApplicationLocator.getManager();
+        final Project project = appManager.getCurrentProject();
 
+        TableDocument selDoc = (TableDocument) project.getDocument(this.linkedTable,
+                TableManager.TYPENAME);
 
+        if (selDoc != null) {
+            try {
+                FeatureType featType = selDoc.getStore().getDefaultFeatureType();
+                FeatureAttributeDescriptor[] atts = featType.getAttributeDescriptors();
 
-	public Set<String> getLinkedFieldValues() {
-		return this.indexHash.keySet();
-	}
+                FeatureSelection fsel = selDoc.getStore().getFeatureSelection();
+                FeatureSet fs = selDoc.getStore().getFeatureSet();
 
-	public void setLinkedFieldValues(List<String> values){
-		this.linkedFieldValues = values;
-		updateSymbols();
-	}
+                DisposableIterator it = null;
+                if (this.destinationSelected) {
+                    it = fsel.fastIterator();
+                } else {
+                    it = fs.fastIterator();
+                }
 
-	public Map<String, List> getLinkedData() {
+                while (it.hasNext()) {
+                    Feature f = (Feature) it.next();
 
-	    indexHash = new HashMap<String,List>();
+                    String key = f.getString(this.linkedField);
+                    if (key != null) {
+                        List<Map<String, Double>> array = indexHash.get(key);
+                        if (array == null) {
+                            array = new ArrayList<>();
+                            indexHash.put(key, array);
+                        }
+                        if (array instanceof DelegatedList) {
+                            List<Map<String, Double>> auxarray = new ArrayList<>();
+                            for (int i = 0; i < array.size(); i++) {
+                                auxarray.add(array.get(i));
+                            }
+                            array = auxarray;
+                        }
 
-		ApplicationManager appManager = ApplicationLocator.getManager();
-		final Project project = appManager.getCurrentProject();
+                        Map<String, Double> elem = new HashMap<>();
+                        for (String field : getLinkedFields()) {
+                            if (!field.equalsIgnoreCase(key)) {
+                                Double value = f.getDouble(field);
+                                elem.put(field, value);
+                            }
+                        }
+                        String xAxis = this.timeField;
+                        if (StringUtils.isNotEmpty(xAxis)) {
+                            Double value = f.getDouble(xAxis);
+                            elem.put(xAxis, value);
+                        }
+                        array.add(elem);
+                    }
+                }
 
-		TableDocument selDoc = (TableDocument) project.getDocument(this.linkedTable,
-			TableManager.TYPENAME);
+                it.dispose();
+            } catch (DataException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
 
-		if (selDoc != null) {
-					try {
-						FeatureType featType = selDoc.getStore().getDefaultFeatureType();
-						FeatureAttributeDescriptor[] atts = featType.getAttributeDescriptors();
+        } else {
+            throw new RuntimeException("No se encuentra la tabla "
+                    + this.linkedTable);
+        }
 
-						FeatureSelection fsel = selDoc.getStore().getFeatureSelection();
-						FeatureSet fs = selDoc.getStore().getFeatureSet();
+        return indexHash;
+    }
 
-						DisposableIterator it = null;
-						if (this.destinationSelected) {
-							it = fsel.fastIterator();
-						}
-						else {
-							it = fs.fastIterator();
-						}
+    @Override
+    public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
 
-						while (it.hasNext()) {
-							Feature f = (Feature) it.next();
+        if (this.onlySelection) {
+            if (!featSelection.isSelected(feat)) {
+                return null;
+            }
+        }
+        String name = "";
+        if (getClassifyingFieldNames() != null && getClassifyingFieldNames().length > 0) {
+            name = feat.getString(getClassifyingFieldNames()[0]);
+        } else {
+            return null;
+        }
+        Set<String> indexes = getLinkedFieldValues();
+        if (!indexes.contains(name)) {
+            return null;
+        }
 
-							String key = f.getString(this.linkedField);
-							if(key != null){
-								List<Map<String,Double>> array = indexHash.get(key);
-								if(array == null){
-									array = new ArrayList<Map<String,Double>>();
-									indexHash.put(key, array);
-								}
-								if(array instanceof DelegatedList){
-									List<Map<String,Double>> auxarray = new ArrayList<Map<String,Double>>();
-									for(int i=0;i<array.size();i++){
-										auxarray.add(array.get(i));
-									}
-									array = auxarray;
-								}
+        // TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
+        symbol = (IChartSymbol) getDefaultSymbol();
+        if (symbol == null) {
+            symbol = (IChartSymbol) MapContextLocator
+                    .getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
 
-								Map<String,Double> elem = new HashMap<String,Double>();
-								for(int i=0;i<getLinkedFields().length; i++) {
-									String field = getLinkedFields()[i];
-									if(!field.equalsIgnoreCase(key)){
-										Double value = f.getDouble(field);
-										if(value != null){
-											elem.put(field, value);
-										}
-									}
-								}
-								String xAxis = this.timeField;
-								if(xAxis != "" && xAxis!=null) {
-										Double value = f.getDouble(xAxis);
-										if(value != null){
-											elem.put(xAxis, value);
-										}
-								}
-								array.add(elem);
-							}
-						}
+        }
+        symbol.setOnlySelection(onlySelection);
+        double size = 0;
 
-						it.dispose();
-					} catch (DataException e) {
-						// TODO Auto-generated catch block
-						e.printStackTrace();
-					}
+        ChartDataSet dataSet = ChartLocator.getServiceManager()
+                .getChartManager().createChartDataSet();
 
-		}else{
-			throw new RuntimeException("No se encuentra la tabla "
-					+ this.linkedTable);
-		}
+        ChartService cs = symbol.getChart();
+        if (StringUtils.equals(cs.getChartType(), "BarsChart")) {
+            addBarsDataSetInfo(dataSet, name);
+        } else {
+            addPieDataSetInfo(dataSet, name);
+        }
+        cs.getChartProperties().setChartDimension(this.is3D);
 
-		return indexHash;
-	}
+        String[] names = getFieldNames();
+        if (names != null) {
+            cs.setChartDataSet(dataSet);
+            List<ChartSerieEntity> lst = cs.getChartLegendItems();
 
+            for (int j = 0; j < names.length; j++) {
+                colors[j] = getSymbolByValue(names[j]).getColor();
+                LegendItem item = new LegendItem(names[j], colors[j]);
+                item.setSeriesKey(names[j]);
+                ChartSerieEntity e = cs.createNewChartSerieEntity(item);
+                if (e != null) {
+                    lst.add(e);
+                }
+            }
+            cs.setCategoriesPaint(Arrays.asList(colors));
+        }
+        double separation = sizeTo - sizeFrom;
 
-	@Override
-	public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
+        switch (sizeOption) {
+            case IChartSymbol.SIZESUM:
+                if (isActiveLimits()) {
+                    double difFeat = maxFeature - minFeature;
+                    double step = difFeat / separation;
+                    size = sizeFrom + ((size - minFeature) / step);
+                }
+                symbol.setSize(size);
+                break;
+            case IChartSymbol.SIZEFIELD:
+                if (separation == 0) {
+                    separation = 1;
+                }
+                double value = feat.getDouble(getFieldSize());
+                if (!getFieldNormalize().equals("---")) {
+                    double normalize = feat.getDouble(getFieldNormalize());
+                    if (normalize != 0) {
+                        value = value / normalize;
+                    }
+                    if (isActiveLimits()) {
+                        size = sizeFrom + (value * separation);
+                    } else {
+                        size = value;
+                    }
+                } else {
+                    if (isActiveLimits()) {
+                        double difFeat = maxFeature - minFeature;
+                        double step = difFeat / separation;
+                        size = sizeFrom + ((value - minFeature) / step);
+                    } else {
+                        size = value;
+                    }
+                }
+                symbol.setSize(size);
+                break;
+            default:
+                symbol.setSize(getSize());
+                break;
+        }
+        return symbol;
+    }
 
-		if (this.onlySelection)
-			if (!featSelection.isSelected(feat))
-				return null;
-		String name="";
-		if(getClassifyingFieldNames()!=null && getClassifyingFieldNames().length>0){
-			name = feat.getString(getClassifyingFieldNames()[0]);
-		}
-		else{
-			return null;
-		}
-		Set<String> indexes = getLinkedFieldValues();
-		if(!indexes.contains(name)){
-			return null;
-		}
+    private void addPieDataSetInfo(ChartDataSet dataSet, String name) {
 
-		// TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
-		symbol = (IChartSymbol) getDefaultSymbol();
-		if (symbol==null){
-			symbol = (IChartSymbol) MapContextLocator
-				.getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
+        String[] names = getFieldNames();
+        String[] _labels = getFieldLabels();
+        if (names != null && _labels != null && _labels.length == names.length) {
+            ArrayList serie = new ArrayList();
+            ArrayList category = new ArrayList();
+            ArrayList groupedBy = new ArrayList();
 
-		}
-		symbol.setOnlySelection(onlySelection);
-		double size=0;
+            Iterator it = indexHash.get(name).iterator();
+            int ji = 1;
+            while (it.hasNext()) {
+                Map<String, Object> it_next = (Map<String, Object>) it.next();
 
-			ChartDataSet dataSet = ChartLocator.getServiceManager()
-				.getChartManager().createChartDataSet();
+                for (int i = 0; i < names.length; i++) {
+                    if (getGroupedField() != null && getGroupedField() != "") {
+                        groupedBy.add("" + it_next.get(getGroupedField()));
+                    } else {
+                        if (ji != 1 || (ji == 1 && it.hasNext())) {
+                            groupedBy.add("" + ji);
+                        } else {
+                            groupedBy.add(" ");
+                        }
+                    }
+                    double val = (Double) it_next.get(names[i]);
+                    if (sizeOption == IChartSymbol.SIZESUM) {
+                        size += val;
+                    }
+                    serie.add(_labels[i]);
+                    category.add(val);
+                }
+                ji++;
+            }
 
+            dataSet.addData("groupby", groupedBy);
+            dataSet.addData("series", serie);
+            dataSet.addData("categories", category);
 
-			ChartService cs = symbol.getChart();
-			if(cs.getChartType()=="BarsChart"){
-				addBarsDataSetInfo(dataSet, name);
-			}else{
-				addPieDataSetInfo(dataSet, name);
-			}
-			cs.getChartProperties().setChartDimension(this.is3D);
+        }
+    }
 
-		String[] names=getFieldNames();
-		if (names!=null){
-			//ChartDataSet dataSet = createSeriesCollection(feat);
+    private void addBarsDataSetInfo(ChartDataSet dataSet, String name) {
+        String[] names = getFieldNames();
+        if (names != null) {
+            ArrayList serie = new ArrayList();
+            ArrayList category = new ArrayList();
+            ArrayList groupedBy = new ArrayList();
 
-			cs.setChartDataSet(dataSet);
+            Iterator it = indexHash.get(name).iterator();
+            int ji = 1;
+            while (it.hasNext()) {
+                Map<String, Object> it_next = (Map<String, Object>) it.next();
 
-//			cs.createChartLegendItems();
-			List<ChartSerieEntity> lst  = cs.getChartLegendItems();
+                for (int i = 0; i < names.length; i++) {
+                    if (getGroupedField() != null && getGroupedField() != "") {
+                        serie.add("" + it_next.get(getGroupedField()));
+                    } else {
+                        serie.add("" + ji);
+                    }
+                    double val = (Double) it_next.get(names[i]);
+                    if (sizeOption == IChartSymbol.SIZESUM) {
+                        size += val;
+                    }
+                    groupedBy.add(names[i]);
+                    category.add(val);
+                }
+                ji++;
+            }
 
-            for (int j=0; j < names.length; j++) {
-                colors[j] = getSymbolByValue(names[j]).getColor();
-                LegendItem item = new LegendItem(names[j], colors[j]);
-				item.setSeriesKey(names[j]);
-				ChartSerieEntity e = cs.createNewChartSerieEntity(item);
-				if(e!=null)
-					lst.add(e);
-			}
-            cs.setCategoriesPaint(Arrays.asList(colors));
-		}
-		double separation = sizeTo-sizeFrom;
+            dataSet.addData("groupby", groupedBy);
+            dataSet.addData("series", serie);
+            dataSet.addData("categories", category);
+        }
+    }
 
-		if (sizeOption==IChartSymbol.SIZESUM){
-			if (isActiveLimits()){
-				double difFeat = maxFeature - minFeature;
-				double step = difFeat/separation;
-				size = sizeFrom + ((size - minFeature)/step);
-			}
-			symbol.setSize(size);
-		}else if (sizeOption==IChartSymbol.SIZEFIELD){
-			if(separation == 0)
-				separation = 1;
-			double value=feat.getDouble(getFieldSize());
+    @Override
+    public String getLinkedField() {
+        return this.linkedField;
+    }
 
-			if (!getFieldNormalize().equals("---")){
-				double normalize=feat.getDouble(getFieldNormalize());
-				if (normalize!=0){
-					value= value/normalize;
-				}
-				if (isActiveLimits())
-					size = sizeFrom + (value * separation) ;
-				else
-					size=value;
-			}else{
-				if (isActiveLimits()){
-					double difFeat = maxFeature - minFeature;
-					double step = difFeat/separation;
-					size = sizeFrom + ((value - minFeature)/step);
-				}else{
-					size=value;
-				}
-			}
-			symbol.setSize(size);
-		}else{
-			symbol.setSize(getSize());
-		}
-//		JFreeChart theChart=configureBarChart(dataSet);
-//		symbol.setChart(theChart);
+    @Override
+    public void setLinkedField(String field) {
+        this.linkedField = field;
+    }
 
-//		if (backgroundSymbol!=null){
-//			multiChartSymbol multiChartSymbol=new MultiChartSymbol();
-//			multiChartSymbol.addLayer(backgroundSymbol);
-//			multiChartSymbol.addLayer(symbol);
-//			return multiChartSymbol;
-//		}
-		return symbol;
-	}
+    @Override
+    public String getTimeField() {
+        return this.timeField;
+    }
 
-	private void addPieDataSetInfo(ChartDataSet dataSet, String name) {
+    @Override
+    public void setTimeField(String field) {
+        this.timeField = field;
+    }
 
-		String[] names=getFieldNames();
-		String[] labels=getFieldLabels();
-		if (names!=null && labels != null && labels.length == names.length){
-			ArrayList serie = new ArrayList();
-			ArrayList category = new ArrayList();
-			ArrayList groupedBy = new ArrayList();
+    @Override
+    public String getLegendType() {
+        return this.legendType;
+    }
 
-				Iterator it = indexHash.get(name).iterator();
-				int ji = 1;
-				while(it.hasNext()){
-					Map<String,Object> it_next = (Map<String, Object>) it.next();
+    @Override
+    public void setLegendType(String field) {
+        this.legendType = field;
+    }
 
-					for (int i = 0; i < names.length; i++) {
-						if(getGroupedField()!=null && getGroupedField()!= ""){
-							groupedBy.add(""+it_next.get(getGroupedField()));
-						}else{
-							if(ji!=1 || (ji==1 && it.hasNext())){
-								groupedBy.add(""+ji);
-							}else{
-								groupedBy.add(" ");
-							}
-						}
-						double val = (Double) it_next.get(names[i]);
-						if (sizeOption==IChartSymbol.SIZESUM){
-							size+=val;
-						}
-						serie.add(labels[i]);
-						category.add(val);
-					}
-					ji++;
-				}
+    @Override
+    public void setGroupedField(String string) {
+        this.groupedByField = string;
+    }
 
-			dataSet.addData("groupby", groupedBy);
-			dataSet.addData("series", serie);
-			dataSet.addData("categories", category);
+    @Override
+    public String getGroupedField() {
+        return this.groupedByField;
+    }
 
-		}
-	}
+    @Override
+    public String getLinkedTable() {
+        return this.linkedTable;
+    }
 
-	private void addBarsDataSetInfo(ChartDataSet dataSet, String name) {
-		String[] names=getFieldNames();
-		if (names!=null){
-			ArrayList serie = new ArrayList();
-			ArrayList category = new ArrayList();
-			ArrayList groupedBy = new ArrayList();
+    @Override
+    public boolean getLinkedSelected() {
+        return this.destinationSelected;
+    }
 
-				Iterator it = indexHash.get(name).iterator();
-				int ji = 1;
-				while(it.hasNext()){
-					Map<String,Object> it_next = (Map<String, Object>) it.next();
+    @Override
+    public String[] getOriginFieldName() {
+        return linkedFieldName;
+    }
 
-					for (int i = 0; i < names.length; i++) {
-						if(getGroupedField()!=null && getGroupedField()!= ""){
-							serie.add(""+it_next.get(getGroupedField()));
-						}else{
-							serie.add(""+ji);
-						}
-						double val = (Double) it_next.get(names[i]);
-						if (sizeOption==IChartSymbol.SIZESUM){
-							size+=val;
-						}
-						groupedBy.add(names[i]);
-						category.add(val);
-					}
-					ji++;
-				}
+    @Override
+    public boolean getOriginSelected() {
+        return this.originSelected;
+    }
 
-			dataSet.addData("groupby", groupedBy);
-			dataSet.addData("series", serie);
-			dataSet.addData("categories", category);
-		}
-	}
+    @Override
+    public void setLinkedTable(String selectedItem) {
+        this.linkedTable = selectedItem;
+        updateSymbols();
+    }
 
-	public String getLinkedField() {
-		return this.linkedField;
-	}
+    @Override
+    public void setOriginSelected(boolean selected) {
+        this.originSelected = selected;
+    }
 
-	public void setLinkedField(String field){
-		this.linkedField = field;
-	}
+    @Override
+    public void setLinkedSelected(boolean selected) {
+        this.destinationSelected = selected;
+    }
 
-	public String getTimeField() {
-		return this.timeField;
-	}
+    @Override
+    public void setLinkedFields(String[] fields) {
+        this.linkedFields = fields;
+        updateSymbols();
+    }
 
-	public void setTimeField(String field){
-		this.timeField = field;
-	}
+    @Override
+    public String[] getLinkedFields() {
+        return linkedFields;
+    }
 
-	public String getLegendType() {
-		return this.legendType;
-	}
+    @Override
+    public void loadFromState(PersistentState state)
+            throws PersistenceException {
+        // Set parent properties
+        super.loadFromState(state);
 
-	public void setLegendType(String field){
-		this.legendType = field;
-	}
+        this.linkedFields = state.getStringArray("linkedFields");
+        this.linkedFieldName = state.getStringArray("linkedFieldName");
+        this.linkedFieldTableNames = state.getStringArray("linkedFieldTableNames");
 
-	public void setGroupedField(String string) {
-		this.groupedByField = string;
-	}
+        // Set own properties
+        this.linkedFieldValues = (List<String>) state.getList("linkedFieldValues");
 
-	public String getGroupedField(){
-		return this.groupedByField;
-	}
+        this.originSelected = state.getBoolean("originSelected");
+        this.destinationSelected = state.getBoolean("destinationSelected");
 
-	public String getLinkedTable() {
-		return this.linkedTable;
-	}
+        this.linkedTable = state.getString("linkedTable");
+        this.linkedField = state.getString("linkedField");
+        this.groupedByField = state.getString("groupedByField");
+        this.timeField = state.getString("timeField");
+        this.legendType = state.getString("legendType");
 
-	public boolean getLinkedSelected() {
-		return this.destinationSelected;
-	}
+        this.indexHash = state.getMap("indexHash");
 
-	public String[] getOriginFieldName() {
-		return linkedFieldName;
-	}
+        //getLinkedData();
+    }
 
-	public boolean getOriginSelected() {
-		return this.originSelected;
-	}
+    @Override
+    public void saveToState(PersistentState state) throws PersistenceException {
+        // Save parent properties
+        super.saveToState(state);
+        // Save own properties
+        state.set("linkedFields", this.linkedFields);
+        state.set("linkedFieldName", this.linkedFieldName);
+        state.set("linkedFieldTableNames", this.linkedFieldTableNames);
 
-	public void setLinkedTable(String selectedItem) {
-		this.linkedTable = selectedItem;
-		updateSymbols();
-	}
+        state.set("linkedFieldValues", this.linkedFieldValues);
 
-	public void setOriginSelected(boolean selected) {
-		this.originSelected = selected;
-	}
+        state.set("originSelected", this.originSelected);
+        state.set("destinationSelected", this.destinationSelected);
 
-	public void setLinkedSelected(boolean selected) {
-		this.destinationSelected = selected;
-	}
+        state.set("linkedTable", this.linkedTable);
+        state.set("linkedField", this.linkedField);
+        state.set("groupedByField", this.groupedByField);
+        state.set("timeField", this.timeField);
 
-	public void setLinkedFields(String[] fields) {
-		this.linkedFields = fields;
-		updateSymbols();
-	}
+        state.set("legendType", this.legendType);
 
-	public String[] getLinkedFields() {
-		return linkedFields;
-	}
+        state.set("indexHash", this.indexHash);
+    }
 
-	public void loadFromState(PersistentState state)
-	throws PersistenceException {
-		// Set parent properties
-		super.loadFromState(state);
+    public static class RegisterPersistence implements Callable {
 
-		this.linkedFields = state.getStringArray("linkedFields");
-		this.linkedFieldName = state.getStringArray("linkedFieldName");
-		this.linkedFieldTableNames = state.getStringArray("linkedFieldTableNames");
+        @Override
+        public Object call() throws Exception {
+            PersistenceManager manager = ToolsLocator.getPersistenceManager();
+            if (manager.getDefinition(LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) {
+                DynStruct definition = manager.addDefinition(
+                        LinkedChartLegend.class,
+                        LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
+                        LINKED_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);
 
-		// Set own properties
-		this.linkedFieldValues = (List<String>) state.getList("linkedFieldValues");
+                definition.addDynField("backgroundSymbol").setClassOfValue(ISymbol.class);
+                definition.addDynFieldInt("size");
+                definition.addDynFieldBoolean("is3D");
 
-		this.originSelected = state.getBoolean("originSelected");
-		this.destinationSelected = state.getBoolean("destinationSelected");
+                definition.addDynFieldBoolean("isOutlineShow");
+                definition.addDynFieldBoolean("onlySelection");
+                definition.addDynFieldBoolean("isActiveLimits");
 
-		this.linkedTable = state.getString("linkedTable");
-		this.linkedField = state.getString("linkedField");
-		this.groupedByField = state.getString("groupedByField");
-		this.timeField = state.getString("timeField");
-		this.legendType = state.getString("legendType");
+                definition.addDynFieldInt("outlineWidth");
+                definition.addDynFieldInt("referenceSystem");
+                definition.addDynFieldInt("sizeFrom");
+                definition.addDynFieldInt("sizeTo");
+                definition.addDynFieldInt("unit");
+                definition.addDynFieldInt("sizeOption");
 
-		this.indexHash = state.getMap("indexHash");
+                definition.addDynFieldObject("outlineColor").setClassOfValue(Color.class);
+                definition.addDynFieldObject("symbol").setClassOfValue(IChartSymbol.class);
+                definition.addDynFieldObject("featSelection").setClassOfValue(FeatureSelection.class);
 
-		//getLinkedData();
-	}
+                definition.addDynFieldString("fieldSize");
+                definition.addDynFieldString("fieldNormalize");
 
-	public void saveToState(PersistentState state) throws PersistenceException {
-		// Save parent properties
-		super.saveToState(state);
-		// Save own properties
-		state.set("linkedFields", this.linkedFields);
-		state.set("linkedFieldName", this.linkedFieldName);
-		state.set("linkedFieldTableNames", this.linkedFieldTableNames);
+                definition.addDynFieldDouble("minFeature");
+                definition.addDynFieldDouble("maxFeature");
+                definition.addDynFieldDouble("maxField");
 
-		state.set("linkedFieldValues", this.linkedFieldValues);
+                // Field names
+                definition.addDynFieldArray("linkedFields")
+                        .setClassOfItems(String.class);
+                definition.addDynFieldArray("linkedFieldName")
+                        .setClassOfItems(String.class);
+                definition.addDynFieldArray("linkedFieldTableNames")
+                        .setClassOfItems(String.class);
+                definition.addDynFieldList("linkedFieldValues")
+                        .setClassOfItems(String.class);
 
-		state.set("originSelected", this.originSelected);
-		state.set("destinationSelected", this.destinationSelected);
+                definition.addDynFieldBoolean("originSelected");
+                definition.addDynFieldBoolean("destinationSelected");
 
-		state.set("linkedTable", this.linkedTable);
-		state.set("linkedField", this.linkedField);
-		state.set("groupedByField", this.groupedByField);
-		state.set("timeField", this.timeField);
+                definition.addDynFieldString("linkedTable");
+                definition.addDynFieldString("linkedField");
+                definition.addDynFieldString("groupedByField");
+                definition.addDynFieldString("timeField");
 
-		state.set("legendType", this.legendType);
+                definition.addDynFieldMap("indexHash").setClassOfItems(List.class);
+                definition.addDynFieldString("legendType");
 
-		state.set("indexHash", this.indexHash);
-	}
+            }
+            return Boolean.TRUE;
+        }
 
-	public static class RegisterPersistence implements Callable {
-
-		public Object call() throws Exception {
-			PersistenceManager manager = ToolsLocator.getPersistenceManager();
-			if( manager.getDefinition(LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
-				DynStruct definition = manager.addDefinition(
-						LinkedChartLegend.class,
-						LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
-						LINKED_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
-						null,
-						null
-				);
-				// Extend the Classified Vector Legend base definition
-				definition.extend(manager.getDefinition(PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME));
-
-				// Field names
-				definition.addDynFieldArray("linkedFields")
-					.setClassOfItems(String.class);
-				definition.addDynFieldArray("linkedFieldName")
-					.setClassOfItems(String.class);
-				definition.addDynFieldArray("linkedFieldTableNames")
-					.setClassOfItems(String.class);
-				definition.addDynFieldList("linkedFieldValues")
-					.setClassOfItems(String.class);
-
-				definition.addDynFieldBoolean("originSelected");
-				definition.addDynFieldBoolean("destinationSelected");
-
-				definition.addDynFieldString("linkedTable");
-				definition.addDynFieldString("linkedField");
-				definition.addDynFieldString("groupedByField");
-				definition.addDynFieldString("timeField");
-
-				definition.addDynFieldMap("indexHash").setClassOfItems(List.class);
-				definition.addDynFieldString("legendType");
-
-			}
-			return Boolean.TRUE;
-		}
-
-	}
+    }
 }
Index: 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/BarsChartLegend.java
===================================================================
--- 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/BarsChartLegend.java	(revision 570)
+++ 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/BarsChartLegend.java	(revision 571)
@@ -27,7 +27,6 @@
 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.SymbologyLocator;
 import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
@@ -45,516 +44,527 @@
 import org.slf4j.LoggerFactory;
 
 public class BarsChartLegend extends VectorialUniqueValueLegend implements IBarsChartLegend {
-    final static private Logger LOG = LoggerFactory.getLogger(BarsChartLegend.class);
 
+    final static private Logger LOGGER = LoggerFactory.getLogger(BarsChartLegend.class);
 
-	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.BARSCHART_LEGEND_NAME,
                     BarsChartLegend.class);
 
-			return Boolean.TRUE;
-		}
+            return Boolean.TRUE;
+        }
 
-	}
+    }
 
+    public static final String BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "BarsChartLegend";
 
-	public static final String BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "BarsChartLegend";
+    private static final String FIELD_NAMES = "FieldLegendNames";
+    private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
+    private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
 
-	private static final String FIELD_NAMES = "FieldLegendNames";
-	private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
-	private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
+    protected ISymbol backgroundSymbol;
+    protected String[] fields;
+    protected String[] labels;
+    protected int size = 150;
+    protected boolean is3D;
 
-	protected ISymbol backgroundSymbol;
-	protected String[] fields;
-	protected String[] labels;
-	protected int size=150;
-	protected boolean is3D;
+    protected boolean isOutlineShow;
+    protected Color outlineColor;
+    protected int outlineWidth;
+    protected boolean onlySelection = false;
+    protected int referenceSystem = 0;
+    protected String fieldSize;
+    protected String fieldNormalize = "---";
+    protected int sizeFrom = 10;
+    protected int sizeTo = 1000;
+    protected int unit = -1;
+    protected int sizeOption = IChartSymbol.SIZEFIXED;
+    protected boolean isActiveLimits;
+    protected double minFeature;
+    protected double maxFeature;
+    protected Color[] colors = null;
+    protected IChartSymbol symbol;
+    private double maxField;
+    protected FeatureSelection featSelection;
 
-	protected boolean isOutlineShow;
-	protected Color outlineColor;
-	protected int outlineWidth;
-	protected boolean onlySelection=false;
-	protected int referenceSystem=0;
-	protected String fieldSize;
-	protected String fieldNormalize="---";
-	protected int sizeFrom=10;
-	protected int sizeTo=1000;
-	protected int unit=-1;
-	protected int sizeOption = IChartSymbol.SIZEFIXED;
-	protected ZSort zSort = null;
-	protected boolean isActiveLimits;
-	protected double minFeature;
-	protected double maxFeature;
-	protected Color[] colors= null;
-	protected IChartSymbol symbol;
-	private double maxField;
-	protected FeatureSelection featSelection;
+    public BarsChartLegend() {
+    }
 
-	public BarsChartLegend() {
-	}
+    public BarsChartLegend(int shapeType) {
+        super(shapeType);
+    }
 
-	public BarsChartLegend(int shapeType) {
-		super(shapeType);
-	}
+    @Override
+    public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
+            Cancellable cancel, double scale, Map queryParameters,
+            ICoordTrans coordTrans, FeatureStore featureStore,
+            FeatureQuery featureQuery) throws LegendException {
+        try {
+            this.featSelection = featureStore.getFeatureSelection();
+            System.out.println("CHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
+        } catch (DataException e) {
+            e.printStackTrace();
+        }
 
+        super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
+                featureStore, featureQuery);
+    }
 
-	@Override
-	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
-			Cancellable cancel, double scale, Map queryParameters,
-			ICoordTrans coordTrans, FeatureStore featureStore,
-			FeatureQuery featureQuery) throws LegendException {
-		try {
-			this.featSelection = featureStore.getFeatureSelection();
-			System.out.println("CHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
-		} catch (DataException e) {
-			e.printStackTrace();
-		}
+    @Override
+    public boolean is3D() {
+        return is3D;
+    }
 
+    @Override
+    public void setIs3D(boolean b) {
+        is3D = b;
+    }
 
-		super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
-				featureStore, featureQuery);
-	}
+    @Override
+    public int getSize() {
+        return size;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#is3D()
-	 */
-	public boolean is3D() {
-		return is3D;
-	}
+    @Override
+    public void setSize(int size) {
+        this.size = size;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setIs3D(boolean)
-	 */
-	public void setIs3D(boolean b){
-		is3D=b;
-	}
+    @Override
+    public boolean isOutlineShow() {
+        return isOutlineShow;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getSize()
-	 */
-	public int getSize() {
-		return size;
-	}
+    @Override
+    public void setOutlineShow(boolean isOutlineShow) {
+        this.isOutlineShow = isOutlineShow;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setSize(int)
-	 */
-	public void setSize(int size) {
-		this.size = size;
-	}
+    @Override
+    public Color getOutlineColor() {
+        return outlineColor;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOutlineShow()
-	 */
-	public boolean isOutlineShow() {
-		return isOutlineShow;
-	}
+    @Override
+    public void setOutlineColor(Color outlineColor) {
+        this.outlineColor = outlineColor;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineShow(boolean)
-	 */
-	public void setOutlineShow(boolean isOutlineShow) {
-		this.isOutlineShow = isOutlineShow;
-	}
+    @Override
+    public int getOutlineWidth() {
+        return outlineWidth;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineColor()
-	 */
-	public Color getOutlineColor() {
-		return outlineColor;
-	}
+    @Override
+    public void setOutlineWidth(int outlineWidth) {
+        this.outlineWidth = outlineWidth;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineColor(java.awt.Color)
-	 */
-	public void setOutlineColor(Color outlineColor) {
-		this.outlineColor = outlineColor;
-	}
+    @Override
+    public void setOnlySelection(boolean onlySelection) {
+        this.onlySelection = onlySelection;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineWidth()
-	 */
-	public int getOutlineWidth() {
-		return outlineWidth;
-	}
+    @Override
+    public boolean isOnlySelection() {
+        return onlySelection;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineWidth(int)
-	 */
-	public void setOutlineWidth(int outlineWidth) {
-		this.outlineWidth = outlineWidth;
-	}
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOnlySelection(boolean)
-	 */
-	public void setOnlySelection(boolean onlySelection) {
-		this.onlySelection=onlySelection;
-	}
+    @Override
+    public ISymbol getBackgroundSymbol() {
+        return backgroundSymbol;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOnlySelection()
-	 */
-	public boolean isOnlySelection() {
-		return onlySelection;
-	}
+    @Override
+    public void setBackgroundSymbol(ISymbol backgroundSymbol) {
+        this.backgroundSymbol = backgroundSymbol;
+    }
 
-	public ISymbol getBackgroundSymbol() {
-		return backgroundSymbol;
-	}
+    @Override
+    public int getSizeOption() {
+        return this.sizeOption;
+    }
 
-	public void setBackgroundSymbol(ISymbol backgroundSymbol) {
-		this.backgroundSymbol = backgroundSymbol;
-	}
+    @Override
+    public String getFieldSize() {
+        return this.fieldSize;
+    }
 
-	public int getSizeOption() {
-		return this.sizeOption;
-	}
+    @Override
+    public String getFieldNormalize() {
+        return this.fieldNormalize;
+    }
 
-	public String getFieldSize() {
-		return this.fieldSize;
-	}
+    @Override
+    public int getSizeFrom() {
+        return this.sizeFrom;
+    }
 
-	public String getFieldNormalize() {
-		return this.fieldNormalize;
-	}
+    @Override
+    public int getSizeTo() {
+        return this.sizeTo;
+    }
 
-	public int getSizeFrom() {
-		return this.sizeFrom;
-	}
+    @Override
+    public int getUnit() {
+        return unit;
+    }
 
-	public int getSizeTo() {
-		return this.sizeTo;
-	}
+    @Override
+    public void setSizeFrom(int s) {
+        this.sizeFrom = s;
+    }
 
-	public int getUnit() {
-		return unit;
-	}
+    @Override
+    public void setSizeTo(int s) {
+        this.sizeTo = s;
+    }
 
-	public void setSizeFrom(int s) {
-		this.sizeFrom = s;
-	}
+    @Override
+    public void setUnit(int unit) {
+        this.unit = unit;
+    }
 
-	public void setSizeTo(int s) {
-		this.sizeTo = s;
-	}
+    @Override
+    public void setFieldSize(String f) {
+        this.fieldSize = f;
+    }
 
-	public void setUnit(int unit) {
-		this.unit = unit;
-	}
+    @Override
+    public void setFieldNormalize(String f) {
+        this.fieldNormalize = f;
+    }
 
-	public void setFieldSize(String f) {
-		this.fieldSize = f;
-	}
+    @Override
+    public void setSizeOption(int option) {
+        this.sizeOption = option;
+    }
 
-	public void setFieldNormalize(String f) {
-		this.fieldNormalize = f;
-	}
+    @Override
+    public boolean isActiveLimits() {
+        return isActiveLimits;
+    }
 
-	public void setSizeOption(int option) {
-		this.sizeOption = option;
-	}
+    @Override
+    public void setActiveLimits(boolean b) {
+        this.isActiveLimits = b;
+    }
 
-	public boolean isActiveLimits() {
-		return isActiveLimits;
-	}
+    @Override
+    public Color[] getColors() {
+        return colors;
+    }
 
-	public void setActiveLimits(boolean b) {
-		this.isActiveLimits = b;
-	}
+    @Override
+    public void setColors(Color[] colors) {
+        this.colors = colors;
+        updateSymbols();
+    }
 
-	public Color[] getColors() {
-		return colors;
-	}
+    @Override
+    public int getReferenceSystem() {
+        return referenceSystem;
+    }
 
-	public void setColors(Color[] colors) {
-		this.colors = colors;
-		updateSymbols();
-	}
+    @Override
+    public void setReferenceSystem(int rs) {
+        this.referenceSystem = rs;
+    }
 
-	public int getReferenceSystem() {
-		return referenceSystem;
-	}
+    @Override
+    public void setMinFeature(double min) {
+        this.minFeature = min;
+    }
 
-	public void setReferenceSystem(int rs) {
-		this.referenceSystem = rs;
-	}
+    @Override
+    public void setMaxFeature(double max) {
+        this.maxFeature = max;
+    }
 
-	public void setMinFeature(double min) {
-		this.minFeature = min;
-	}
+    @Override
+    public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
+        Feature feat2 = feat.getCopy();
+        if (this.onlySelection) {
+            if (!featSelection.isSelected(feat)) {
+                return null;
+            }
+        }
 
-	public void setMaxFeature(double max) {
-		this.maxFeature = max;
-	}
+        // TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
+        symbol = (IChartSymbol) getDefaultSymbol();
+        if (symbol == null) {
+            symbol = (IChartSymbol) MapContextLocator
+                    .getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
 
-	@Override
-	public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
-		Feature feat2 = feat.getCopy();
-		if (this.onlySelection)
-			if (!featSelection.isSelected(feat))
-				return null;
+        }
+        symbol.setOnlySelection(onlySelection);
+        double size1 = 0d;
 
-		// TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
-		symbol = (IChartSymbol) getDefaultSymbol();
-		if (symbol==null){
-			symbol = (IChartSymbol) MapContextLocator
-				.getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
+        ChartDataSet dataSet = ChartLocator.getServiceManager()
+                .getChartManager().createChartDataSet();
 
-		}
-		symbol.setOnlySelection(onlySelection);
-		double size=0;
+        String[] names = getFieldNames();
 
-			ChartDataSet dataSet = ChartLocator.getServiceManager()
-				.getChartManager().createChartDataSet();
+        if (names != null) {
+            ArrayList groupedBy = new ArrayList();
+            ArrayList serie = new ArrayList();
+            ArrayList category = new ArrayList();
+            for (String name : names) {
+                double val = feat2.getDouble(name);
+                if (sizeOption == IChartSymbol.SIZESUM) {
+                    size1 += val;
+                }
+                groupedBy.add(name);
+                serie.add("default");
+                category.add(val);
+            }
+            dataSet.addData("groupby", groupedBy);
+            dataSet.addData("series", serie);
+            dataSet.addData("categories", category);
 
-		String[] names=getFieldNames();
+            symbol.getChart().setChartDataSet(dataSet);
+            ChartService cs = symbol.getChart();
+            cs.getChartProperties().setChartDimension(this.is3D);
 
-		if (names!=null){
-			ArrayList groupedBy = new ArrayList();
-			ArrayList serie = new ArrayList();
-			ArrayList category = new ArrayList();
-			for (int i = 0; i < names.length; i++) {
-				double val = feat2.getDouble(names[i]);
-				if (sizeOption==IChartSymbol.SIZESUM){
-					size+=val;
-				}
-				groupedBy.add(names[i]);
-				serie.add("default");
-				category.add(val);
-			}
-			dataSet.addData("groupby", groupedBy);
-			dataSet.addData("series", serie);
-			dataSet.addData("categories", category);
+            List<ChartSerieEntity> lst = cs.getChartLegendItems();
 
-			symbol.getChart().setChartDataSet(dataSet);
-			ChartService cs = symbol.getChart();
-			cs.getChartProperties().setChartDimension(this.is3D);
-//			cs.createChartLegendItems();
-			List<ChartSerieEntity> lst  = cs.getChartLegendItems();
-
-            for (int j=0; j < names.length; j++) {
+            for (int j = 0; j < names.length; j++) {
                 colors[j] = getSymbolByValue(names[j]).getColor();
                 LegendItem item = new LegendItem(names[j], colors[j]);
-				item.setSeriesKey(names[j]);
-				ChartSerieEntity e = cs.createNewChartSerieEntity(item);
-				if(e!=null)
-					lst.add(e);
-			}
+                item.setSeriesKey(names[j]);
+                ChartSerieEntity e = cs.createNewChartSerieEntity(item);
+                if (e != null) {
+                    lst.add(e);
+                }
+            }
             cs.setCategoriesPaint(Arrays.asList(colors));
-		}
-		double separation = sizeTo-sizeFrom;
+        }
+        double separation = sizeTo - sizeFrom;
 
-		if (sizeOption==IChartSymbol.SIZESUM){
-			if (isActiveLimits()){
-				double difFeat = maxFeature - minFeature;
-				double step = difFeat/separation;
-				size = sizeFrom + ((size - minFeature)/step);
-			}
-			symbol.setSize(size);
-		}else if (sizeOption==IChartSymbol.SIZEFIELD){
-			if(separation == 0)
-				separation = 1;
-			double value=feat2.getDouble(getFieldSize());
+        switch (sizeOption) {
+            case IChartSymbol.SIZESUM:
+                if (isActiveLimits()) {
+                    double difFeat = maxFeature - minFeature;
+                    double step = difFeat / separation;
+                    size1 = sizeFrom + ((size1 - minFeature) / step);
+                }
+                symbol.setSize(size1);
+                break;
+            case IChartSymbol.SIZEFIELD:
+                if (separation == 0) {
+                    separation = 1;
+                }
+                double value = feat2.getDouble(getFieldSize());
+                if (!getFieldNormalize().equals("---")) {
+                    double normalize = feat2.getDouble(getFieldNormalize());
+                    if (normalize != 0) {
+                        value = value / normalize;
+                    }
+                    if (isActiveLimits()) {
+                        size1 = sizeFrom + (value * separation);
+                    } else {
+                        size1 = value;
+                    }
+                } else {
+                    if (isActiveLimits()) {
+                        double difFeat = maxFeature - minFeature;
+                        double step = difFeat / separation;
+                        size1 = sizeFrom + ((value - minFeature) / step);
+                    } else {
+                        size1 = value;
+                    }
+                }
+                symbol.setSize(size1);
+                break;
+            default:
+                symbol.setSize(getSize());
+                break;
+        }
+        return symbol;
 
-			if (!getFieldNormalize().equals("---")){
-				double normalize=feat2.getDouble(getFieldNormalize());
-				if (normalize!=0){
-					value= value/normalize;
-				}
-				if (isActiveLimits())
-					size = sizeFrom + (value * separation) ;
-				else
-					size=value;
-			}else{
-				if (isActiveLimits()){
-					double difFeat = maxFeature - minFeature;
-					double step = difFeat/separation;
-					size = sizeFrom + ((value - minFeature)/step);
-				}else{
-					size=value;
-				}
-			}
-			symbol.setSize(size);
-		}else{
-			symbol.setSize(getSize());
-		}
-		return symbol;
+    }
 
-	}
+    public String[] getFieldNames() {
+        return fields;
+    }
 
-	public String[] getFieldNames() {
-		return fields;
-	}
+    @Override
+    public String[] getFieldLabels() {
+        if (labels == null) {
+            return new String[0];
+        }
+        return labels;
+    }
 
-	public String[] getFieldLabels() {
-		if(labels==null)
-			return new String[0];
-		return labels;
-	}
+    @Override
+    public void setFields(String[] fields) {
+        this.fields = fields;
+        updateSymbols();
+    }
 
-	public void setFields(String[] fields) {
-		this.fields = fields;
-		updateSymbols();
-	}
+    @Override
+    public void setLabels(String[] fields) {
+        this.labels = fields;
+        updateSymbols();
+    }
 
-	public void setLabels(String[] fields) {
-		this.labels = fields;
-		updateSymbols();
-	}
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    @Override
+    public void loadFromState(PersistentState state)
+            throws PersistenceException {
+        // Set parent properties
+        super.loadFromState(state);
 
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void loadFromState(PersistentState state)
-			throws PersistenceException {
-		// Set parent properties
-		super.loadFromState(state);
+        this.fields = state.getStringArray(FIELD_NAMES);
+        this.labels = state.getStringArray(FIELD_LABEL_NAMES);
+        this.colors = (Color[]) state.getArray(FIELD_LABEL_COLOR, Color.class);
+        // Set own properties
+        this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol");
+        this.size = state.getInt("size");
+        this.is3D = state.getBoolean("is3D");
 
-		this.fields = state.getStringArray(FIELD_NAMES);
-		this.labels = state.getStringArray(FIELD_LABEL_NAMES);
-		this.colors = (Color[]) state.getArray(FIELD_LABEL_COLOR,Color.class);
-		// Set own properties
-		this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol");
-		this.size = state.getInt("size");
-		this.is3D = state.getBoolean("is3D");
+        this.isOutlineShow = state.getBoolean("isOutlineShow");
+        this.onlySelection = state.getBoolean("onlySelection");
+        this.isActiveLimits = state.getBoolean("isActiveLimits");
 
-		this.isOutlineShow = state.getBoolean("isOutlineShow");
-		this.onlySelection = state.getBoolean("onlySelection");
-		this.isActiveLimits = state.getBoolean("isActiveLimits");
+        this.outlineWidth = state.getInt("outlineWidth");
+        this.referenceSystem = state.getInt("referenceSystem");
+        this.sizeFrom = state.getInt("sizeFrom");
+        this.sizeTo = state.getInt("sizeTo");
+        this.unit = state.getInt("unit");
+        this.sizeOption = state.getInt("sizeOption");
 
-		this.outlineWidth = state.getInt("outlineWidth");
-		this.referenceSystem = state.getInt("referenceSystem");
-		this.sizeFrom = state.getInt("sizeFrom");
-		this.sizeTo = state.getInt("sizeTo");
-		this.unit = state.getInt("unit");
-		this.sizeOption = state.getInt("sizeOption");
+        this.outlineColor = (Color) state.get("outlineColor");
+        this.symbol = (IChartSymbol) state.get("symbol");
+        this.featSelection = (FeatureSelection) state.get("featSelection");
 
-		this.outlineColor = (Color) state.get("outlineColor");
-		this.symbol = (IChartSymbol) state.get("symbol");
-		this.featSelection = (FeatureSelection) state.get("featSelection");
+        this.fieldSize = state.getString("fieldSize");
+        this.fieldNormalize = state.getString("fieldNormalize");
 
-		this.fieldSize = state.getString("fieldSize");
-		this.fieldNormalize = state.getString("fieldNormalize");
+        this.minFeature = state.getDouble("minFeature");
+        this.maxFeature = state.getDouble("maxFeature");
+        this.maxField = state.getDouble("maxField");
+    }
 
-		this.minFeature = state.getDouble("minFeature");
-		this.maxFeature = state.getDouble("maxFeature");
-		this.maxField = state.getDouble("maxField");
-	}
+    @Override
+    public void saveToState(PersistentState state) throws PersistenceException {
+        // Save parent properties
+        super.saveToState(state);
+        // Save own properties
+        state.set(FIELD_NAMES, this.fields);
+        state.set(FIELD_LABEL_NAMES, this.labels);
+        state.set(FIELD_LABEL_COLOR, this.colors);
 
-	public void saveToState(PersistentState state) throws PersistenceException {
-		// Save parent properties
-		super.saveToState(state);
-		// Save own properties
-		state.set(FIELD_NAMES, this.fields);
-		state.set(FIELD_LABEL_NAMES, this.labels);
-		state.set(FIELD_LABEL_COLOR, this.colors);
+        state.set("backgroundSymbol", this.backgroundSymbol);
+        state.set("size", this.size);
+        state.set("is3D", this.is3D);
 
-		state.set("backgroundSymbol", this.backgroundSymbol);
-		state.set("size", this.size);
-		state.set("is3D", this.is3D);
+        state.set("isOutlineShow", this.isOutlineShow);
+        state.set("onlySelection", this.onlySelection);
+        state.set("isActiveLimits", this.isActiveLimits);
 
-		state.set("isOutlineShow", this.isOutlineShow);
-		state.set("onlySelection", this.onlySelection);
-		state.set("isActiveLimits", this.isActiveLimits);
+        state.set("outlineWidth", this.outlineWidth);
+        state.set("referenceSystem", this.referenceSystem);
+        state.set("sizeFrom", this.sizeFrom);
+        state.set("sizeTo", this.sizeTo);
+        state.set("unit", this.unit);
+        state.set("sizeOption", this.sizeOption);
 
-		state.set("outlineWidth", this.outlineWidth);
-		state.set("referenceSystem", this.referenceSystem);
-		state.set("sizeFrom", this.sizeFrom);
-		state.set("sizeTo", this.sizeTo);
-		state.set("unit", this.unit);
-		state.set("sizeOption", this.sizeOption);
+        state.set("outlineColor", this.outlineColor);
+        state.set("symbol", this.symbol);
+        state.set("featSelection", this.featSelection);
 
-		state.set("outlineColor", this.outlineColor);
-		state.set("symbol", this.symbol);
-		state.set("featSelection", this.featSelection);
+        state.set("fieldSize", this.fieldSize);
+        state.set("fieldNormalize", this.fieldNormalize);
 
-		state.set("fieldSize", this.fieldSize);
-		state.set("fieldNormalize", this.fieldNormalize);
+        state.set("minFeature", this.minFeature);
+        state.set("maxFeature", this.maxFeature);
+        state.set("maxField", this.maxField);
 
-		state.set("minFeature", this.minFeature);
-		state.set("maxFeature", this.maxFeature);
-		state.set("maxField", this.maxField);
+    }
 
-	}
+    public static class RegisterPersistence implements Callable {
 
-	public static class RegisterPersistence implements Callable {
+        @Override
+        public Object call() throws Exception {
+            PersistenceManager manager = ToolsLocator.getPersistenceManager();
+            if (manager.getDefinition(BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) {
+                DynStruct definition = manager.addDefinition(
+                        BarsChartLegend.class,
+                        BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
+                        BARS_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));
 
-		public Object call() throws Exception {
-			PersistenceManager manager = ToolsLocator.getPersistenceManager();
-			if( manager.getDefinition(BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
-				DynStruct definition = manager.addDefinition(
-						BarsChartLegend.class,
-						BARS_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
-						BARS_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);
 
-				// 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.addDynField("backgroundSymbol").setClassOfValue(ISymbol.class);
-				definition.addDynFieldInt("size");
-				definition.addDynFieldBoolean("is3D");
+                definition.addDynFieldBoolean("isOutlineShow");
+                definition.addDynFieldBoolean("onlySelection");
+                definition.addDynFieldBoolean("isActiveLimits");
 
-				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.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.addDynFieldObject("outlineColor").setClassOfValue(Color.class);
-				definition.addDynFieldObject("symbol").setClassOfValue(IChartSymbol.class);
-				definition.addDynFieldObject("featSelection").setClassOfValue(FeatureSelection.class);
+                definition.addDynFieldString("fieldSize");
+                definition.addDynFieldString("fieldNormalize");
 
-				definition.addDynFieldString("fieldSize");
-				definition.addDynFieldString("fieldNormalize");
+                definition.addDynFieldDouble("minFeature");
+                definition.addDynFieldDouble("maxFeature");
+                definition.addDynFieldDouble("maxField");
+            }
+            return Boolean.TRUE;
+        }
 
-				definition.addDynFieldDouble("minFeature");
-				definition.addDynFieldDouble("maxFeature");
-				definition.addDynFieldDouble("maxField");
-			}
-			return Boolean.TRUE;
-		}
+    }
 
-	}
-
     protected void updateSymbols() {
         ISymbol[] symbols = getSymbols();
-        for (int i = 0; i < symbols.length; i++) {
-            delSymbol(getSymbolKey(symbols[i]));
+        for (ISymbol symbol1 : symbols) {
+            delSymbol(getSymbolKey(symbol1));
         }
         if (fields != null && colors != null && labels != null) {
 
             if (fields.length != colors.length) {
-                LOG.warn("The length of fields and colors isn't the same: fields.length = " + fields.length
-                    + " colors.length = " + colors.length);
+                LOGGER.warn("The length of fields and colors isn't the same: fields.length = " + fields.length
+                        + " colors.length = " + colors.length);
             }
 
             if (fields.length != labels.length) {
-                LOG.warn("The length of fields and labels isn't the same: fields.length = " + fields.length
-                    + " labels.length = " + labels.length);
+                LOGGER.warn("The length of fields and labels isn't the same: fields.length = " + fields.length
+                        + " labels.length = " + labels.length);
             }
 
             for (int i = 0; i < Math.min(fields.length, Math.min(labels.length, colors.length)); i++) {
-                ISimpleFillSymbol symbol = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol();
-                symbol.setColor(colors[i]);
-                symbol.setDescription(labels[i]);
-                addSymbol(fields[i], symbol);
+                ISimpleFillSymbol symbol1 = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol();
+                symbol1.setColor(colors[i]);
+                symbol1.setDescription(labels[i]);
+                addSymbol(fields[i], symbol1);
             }
         }
     }
Index: 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
===================================================================
--- 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	(revision 570)
+++ 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	(revision 571)
@@ -31,13 +31,9 @@
 import org.gvsig.symbology.SymbologyLocator;
 import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
 import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol;
-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;
 
 /**
  * @author Fjp
@@ -46,499 +42,508 @@
  * ESTA SE USA PARA TODO TIPO DE CHARTS. (BarsChartLegend no se usa, borrarla)
  */
 public class BasePieChartLegend extends VectorialUniqueValueLegend {
+
     final static private Logger LOG = LoggerFactory.getLogger(BasePieChartLegend.class);
 
-	public static final String PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "PieChartLegend";
+    public static final String BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME = "BasePieChartLegend";
 
-	private static final String FIELD_NAMES = "FieldLegendNames";
-	private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
-	private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
+    private static final String FIELD_NAMES = "FieldLegendNames";
+    private static final String FIELD_LABEL_NAMES = "FieldLabelNames";
+    private static final String FIELD_LABEL_COLOR = "FieldLabelColor";
 
-	protected ISymbol backgroundSymbol;
-	protected String[] fields;
-	protected String[] labels;
-	protected int size=150;
-	protected boolean is3D;
+    protected ISymbol backgroundSymbol;
+    protected String[] fields;
+    protected String[] labels;
+    protected int size = 150;
+    protected boolean is3D;
 
-	protected boolean isOutlineShow;
-	protected Color outlineColor;
-	protected int outlineWidth;
-	protected boolean onlySelection=false;
-	protected int referenceSystem=0;
-	protected String fieldSize;
-	protected String fieldNormalize="---";
-	protected int sizeFrom=10;
-	protected int sizeTo=1000;
-	protected int unit=-1;
-	protected int sizeOption = IChartSymbol.SIZEFIXED;
-	protected ZSort zSort = null;
-	protected boolean isActiveLimits;
-	protected double minFeature;
-	protected double maxFeature;
-	protected Color[] colors= null;
-	protected IChartSymbol symbol;
-	private double maxField;
-	protected FeatureSelection featSelection;
+    protected boolean isOutlineShow;
+    protected Color outlineColor;
+    protected int outlineWidth;
+    protected boolean onlySelection = false;
+    protected int referenceSystem = 0;
+    protected String fieldSize;
+    protected String fieldNormalize = "---";
+    protected int sizeFrom = 10;
+    protected int sizeTo = 1000;
+    protected int unit = -1;
+    protected int sizeOption = IChartSymbol.SIZEFIXED;
+    protected ZSort zSort = null;
+    protected boolean isActiveLimits;
+    protected double minFeature;
+    protected double maxFeature;
+    protected Color[] colors = null;
+    protected IChartSymbol symbol;
+    private double maxField;
+    protected FeatureSelection featSelection;
 
-	public BasePieChartLegend() {
-	}
+    public BasePieChartLegend() {
+    }
 
-	public BasePieChartLegend(int shapeType) {
-		super(shapeType);
-	}
+    public BasePieChartLegend(int shapeType) {
+        super(shapeType);
+    }
 
+    @Override
+    public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
+            Cancellable cancel, double scale, Map queryParameters,
+            ICoordTrans coordTrans, FeatureStore featureStore,
+            FeatureQuery featureQuery) throws LegendException {
+        try {
+            this.featSelection = featureStore.getFeatureSelection();
+            System.out.println("CHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
+        } catch (DataException e) {
+            e.printStackTrace();
+        }
 
-	@Override
-	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
-			Cancellable cancel, double scale, Map queryParameters,
-			ICoordTrans coordTrans, FeatureStore featureStore,
-			FeatureQuery featureQuery) throws LegendException {
-		try {
-			this.featSelection = featureStore.getFeatureSelection();
-			System.out.println("CHARTLEGEND: " + featSelection.getSelectedCount() + " seleccionados.");
-		} catch (DataException e) {
-			e.printStackTrace();
-		}
+        super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
+                featureStore, featureQuery);
+    }
 
-		super.draw(image, g, viewPort, cancel, scale, queryParameters, coordTrans,
-				featureStore, featureQuery);
-	}
-
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#is3D()
-	 */
-	public boolean is3D() {
-		return is3D;
-	}
+     */
+    public boolean is3D() {
+        return is3D;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setIs3D(boolean)
-	 */
-	public void setIs3D(boolean b){
-		is3D=b;
-	}
+     */
+    public void setIs3D(boolean b) {
+        is3D = b;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getSize()
-	 */
-	public int getSize() {
-		return size;
-	}
+     */
+    public int getSize() {
+        return size;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setSize(int)
-	 */
-	public void setSize(int size) {
-		this.size = size;
-	}
+     */
+    public void setSize(int size) {
+        this.size = size;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOutlineShow()
-	 */
-	public boolean isOutlineShow() {
-		return isOutlineShow;
-	}
+     */
+    public boolean isOutlineShow() {
+        return isOutlineShow;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineShow(boolean)
-	 */
-	public void setOutlineShow(boolean isOutlineShow) {
-		this.isOutlineShow = isOutlineShow;
-	}
+     */
+    public void setOutlineShow(boolean isOutlineShow) {
+        this.isOutlineShow = isOutlineShow;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineColor()
-	 */
-	public Color getOutlineColor() {
-		return outlineColor;
-	}
+     */
+    public Color getOutlineColor() {
+        return outlineColor;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineColor(java.awt.Color)
-	 */
-	public void setOutlineColor(Color outlineColor) {
-		this.outlineColor = outlineColor;
-	}
+     */
+    public void setOutlineColor(Color outlineColor) {
+        this.outlineColor = outlineColor;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#getOutlineWidth()
-	 */
-	public int getOutlineWidth() {
-		return outlineWidth;
-	}
+     */
+    public int getOutlineWidth() {
+        return outlineWidth;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOutlineWidth(int)
-	 */
-	public void setOutlineWidth(int outlineWidth) {
-		this.outlineWidth = outlineWidth;
-	}
-	/* (non-Javadoc)
+     */
+    public void setOutlineWidth(int outlineWidth) {
+        this.outlineWidth = outlineWidth;
+    }
+
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#setOnlySelection(boolean)
-	 */
-	public void setOnlySelection(boolean onlySelection) {
-		this.onlySelection=onlySelection;
-	}
+     */
+    public void setOnlySelection(boolean onlySelection) {
+        this.onlySelection = onlySelection;
+    }
 
-	/* (non-Javadoc)
+    /* (non-Javadoc)
 	 * @see org.gvsig.symbology.fmap.mapcontext.rendering.legend.IChartLegend#isOnlySelection()
-	 */
-	public boolean isOnlySelection() {
-		return onlySelection;
-	}
+     */
+    public boolean isOnlySelection() {
+        return onlySelection;
+    }
 
-	public ISymbol getBackgroundSymbol() {
-		return backgroundSymbol;
-	}
+    public ISymbol getBackgroundSymbol() {
+        return backgroundSymbol;
+    }
 
-	public void setBackgroundSymbol(ISymbol backgroundSymbol) {
-		this.backgroundSymbol = backgroundSymbol;
-	}
+    public void setBackgroundSymbol(ISymbol backgroundSymbol) {
+        this.backgroundSymbol = backgroundSymbol;
+    }
 
-	public int getSizeOption() {
-		return this.sizeOption;
-	}
+    public int getSizeOption() {
+        return this.sizeOption;
+    }
 
-	public String getFieldSize() {
-		return this.fieldSize;
-	}
+    public String getFieldSize() {
+        return this.fieldSize;
+    }
 
-	public String getFieldNormalize() {
-		return this.fieldNormalize;
-	}
+    public String getFieldNormalize() {
+        return this.fieldNormalize;
+    }
 
-	public int getSizeFrom() {
-		return this.sizeFrom;
-	}
+    public int getSizeFrom() {
+        return this.sizeFrom;
+    }
 
-	public int getSizeTo() {
-		return this.sizeTo;
-	}
+    public int getSizeTo() {
+        return this.sizeTo;
+    }
 
-	public int getUnit() {
-		return unit;
-	}
+    public int getUnit() {
+        return unit;
+    }
 
-	public void setSizeFrom(int s) {
-		this.sizeFrom = s;
-	}
+    public void setSizeFrom(int s) {
+        this.sizeFrom = s;
+    }
 
-	public void setSizeTo(int s) {
-		this.sizeTo = s;
-	}
+    public void setSizeTo(int s) {
+        this.sizeTo = s;
+    }
 
-	public void setUnit(int unit) {
-		this.unit = unit;
-	}
+    public void setUnit(int unit) {
+        this.unit = unit;
+    }
 
-	public void setFieldSize(String f) {
-		this.fieldSize = f;
-	}
+    public void setFieldSize(String f) {
+        this.fieldSize = f;
+    }
 
-	public void setFieldNormalize(String f) {
-		this.fieldNormalize = f;
-	}
+    public void setFieldNormalize(String f) {
+        this.fieldNormalize = f;
+    }
 
-	public void setSizeOption(int option) {
-		this.sizeOption = option;
-	}
+    public void setSizeOption(int option) {
+        this.sizeOption = option;
+    }
 
-	public boolean isActiveLimits() {
-		return isActiveLimits;
-	}
+    public boolean isActiveLimits() {
+        return isActiveLimits;
+    }
 
-	public void setActiveLimits(boolean b) {
-		this.isActiveLimits = b;
-	}
+    public void setActiveLimits(boolean b) {
+        this.isActiveLimits = b;
+    }
 
-	public Color[] getColors() {
-		return colors;
-	}
+    public Color[] getColors() {
+        return colors;
+    }
 
-	public void setColors(Color[] colors) {
-		this.colors = colors;
-		updateSymbols();
-	}
+    public void setColors(Color[] colors) {
+        this.colors = colors;
+        updateSymbols();
+    }
 
-	public int getReferenceSystem() {
-		return referenceSystem;
-	}
+    public int getReferenceSystem() {
+        return referenceSystem;
+    }
 
-	public void setReferenceSystem(int rs) {
-		this.referenceSystem = rs;
-	}
+    public void setReferenceSystem(int rs) {
+        this.referenceSystem = rs;
+    }
 
-	public void setMinFeature(double min) {
-		this.minFeature = min;
-	}
+    public void setMinFeature(double min) {
+        this.minFeature = min;
+    }
 
-	public void setMaxFeature(double max) {
-		this.maxFeature = max;
-	}
+    public void setMaxFeature(double max) {
+        this.maxFeature = max;
+    }
 
-	@Override
-	public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
+    @Override
+    public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
 
-		if (this.onlySelection)
-			if (!featSelection.isSelected(feat))
-				return null;
+        if (this.onlySelection) {
+            if (!featSelection.isSelected(feat)) {
+                return null;
+            }
+        }
 
-		// TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
-		symbol = (IChartSymbol) getDefaultSymbol();
-		if (symbol==null){
-			symbol = (IChartSymbol) MapContextLocator
-				.getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
+        // TODO: AQUÍ PRODRÍAMOS RECUPERAR VARIOS SIMBOLOS. POR AHORA, SUPONEMOS QUE EL DEFAULTSYMBOL ES EL QUE TIENE EL CHARTSYMBOL
+        symbol = (IChartSymbol) getDefaultSymbol();
+        if (symbol == null) {
+            symbol = (IChartSymbol) MapContextLocator
+                    .getSymbolManager().createSymbol(IChartSymbol.SYMBOL_NAME);
 
-		}
-		symbol.setOnlySelection(onlySelection);
-		double size=0;
+        }
+        symbol.setOnlySelection(onlySelection);
+        double size = 0;
 
-			ChartDataSet dataSet = ChartLocator.getServiceManager()
-				.getChartManager().createChartDataSet();
+        ChartDataSet dataSet = ChartLocator.getServiceManager()
+                .getChartManager().createChartDataSet();
 
-		String[] names=getFieldNames();
-		String[] labels=getFieldLabels();
-		if (names!=null && labels != null && labels.length == names.length){
+        String[] names = getFieldNames();
+        String[] labels = getFieldLabels();
+        if (names != null && labels != null && labels.length == names.length) {
 
-			ArrayList serie = new ArrayList();
-			ArrayList category = new ArrayList();
-			for (int i = 0; i < names.length; i++) {
-				double val = feat.getDouble(names[i]);
-				if (sizeOption==IChartSymbol.SIZESUM){
-					size+=val;
-				}
-				if(!this.onlySelection || featSelection.isSelected(feat)){
-					serie.add(labels[i]);
-					category.add(val);
-				}
-			}
-			dataSet.addData("series", serie);
-			dataSet.addData("categories", category);
+            ArrayList serie = new ArrayList();
+            ArrayList category = new ArrayList();
+            for (int i = 0; i < names.length; i++) {
+                double val = feat.getDouble(names[i]);
+                if (sizeOption == IChartSymbol.SIZESUM) {
+                    size += val;
+                }
+                if (!this.onlySelection || featSelection.isSelected(feat)) {
+                    serie.add(labels[i]);
+                    category.add(val);
+                }
+            }
+            dataSet.addData("series", serie);
+            dataSet.addData("categories", category);
 
-			if(!this.onlySelection || featSelection.isSelected(feat)){
-				symbol.getChart().setChartDataSet(dataSet);
-			}
-			ChartService cs = symbol.getChart();
-//			cs.createChartLegendItems();
-			List<ChartSerieEntity> lst  = cs.getChartLegendItems();
+            if (!this.onlySelection || featSelection.isSelected(feat)) {
+                symbol.getChart().setChartDataSet(dataSet);
+            }
+            ChartService cs = symbol.getChart();
 
-			for (int j=0; j < names.length; j++) {
-				LegendItem item = new LegendItem(names[j], getSymbolByValue(names[j]).getColor());
-				item.setSeriesKey(names[j]);
-				ChartSerieEntity e = cs.createNewChartSerieEntity(item);
-				if(e!=null)
-					lst.add(e);
-			}
-		}
-		double separation = sizeTo-sizeFrom;
+            List<ChartSerieEntity> lst = cs.getChartLegendItems();
 
-		if (sizeOption==IChartSymbol.SIZESUM){
-			if (isActiveLimits()){
-				double difFeat = maxFeature - minFeature;
-				double step = difFeat/separation;
-				size = sizeFrom + ((size - minFeature)/step);
-			}
-			symbol.setSize(size);
-		}else if (sizeOption==IChartSymbol.SIZEFIELD){
-			if(separation == 0)
-				separation = 1;
-			double value=feat.getDouble(getFieldSize());
+            for (int j = 0; j < names.length; j++) {
+                LegendItem item = new LegendItem(names[j], getSymbolByValue(names[j]).getColor());
+                item.setSeriesKey(names[j]);
+                ChartSerieEntity e = cs.createNewChartSerieEntity(item);
+                if (e != null) {
+                    lst.add(e);
+                }
+            }
+        }
+        double separation = sizeTo - sizeFrom;
 
-			if (!getFieldNormalize().equals("---")){
-				double normalize=feat.getDouble(getFieldNormalize());
-				if (normalize!=0){
-					value= value/normalize;
-				}
-				if (isActiveLimits())
-					size = sizeFrom + (value * separation) ;
-				else
-					size=value;
-			}else{
-				if (isActiveLimits()){
-					double difFeat = maxFeature - minFeature;
-					double step = difFeat/separation;
-					size = sizeFrom + ((value - minFeature)/step);
-				}else{
-					size=value;
-				}
-			}
+        switch (sizeOption) {
+            case IChartSymbol.SIZESUM:
+                if (isActiveLimits()) {
+                    double difFeat = maxFeature - minFeature;
+                    double step = difFeat / separation;
+                    size = sizeFrom + ((size - minFeature) / step);
+                }
+                symbol.setSize(size);
+                break;
+            case IChartSymbol.SIZEFIELD:
+                if (separation == 0) {
+                    separation = 1;
+                }
+                double value = feat.getDouble(getFieldSize());
+                if (!getFieldNormalize().equals("---")) {
+                    double normalize = feat.getDouble(getFieldNormalize());
+                    if (normalize != 0) {
+                        value = value / normalize;
+                    }
+                    if (isActiveLimits()) {
+                        size = sizeFrom + (value * separation);
+                    } else {
+                        size = value;
+                    }
+                } else {
+                    if (isActiveLimits()) {
+                        double difFeat = maxFeature - minFeature;
+                        double step = difFeat / separation;
+                        size = sizeFrom + ((value - minFeature) / step);
+                    } else {
+                        size = value;
+                    }
+                }
+                symbol.setSize(size);
+                break;
+            default:
+                symbol.setSize(getSize());
+                break;
+        }
+        return symbol;
 
-		}else{
-				symbol.setSize(getSize());
-		}
-		return symbol;
+    }
 
-	}
+    public String[] getFieldNames() {
+        return fields;
+    }
 
-	public String[] getFieldNames() {
-		return fields;
-	}
+    public String[] getFieldLabels() {
+        if (labels == null) {
+            return new String[0];
+        }
+        return labels;
+    }
 
-	public String[] getFieldLabels() {
-		if(labels==null)
-			return new String[0];
-		return labels;
-	}
+    public void setFields(String[] fields) {
+        this.fields = fields;
+        updateSymbols();
+    }
 
-	public void setFields(String[] fields) {
-		this.fields = fields;
-		updateSymbols();
-	}
+    public void setLabels(String[] fields) {
+        this.labels = fields;
+        updateSymbols();
+    }
 
-	public void setLabels(String[] fields) {
-		this.labels = fields;
-		updateSymbols();
-	}
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public void loadFromState(PersistentState state)
+            throws PersistenceException {
+        // Set parent properties
+        super.loadFromState(state);
 
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void loadFromState(PersistentState state)
-			throws PersistenceException {
-		// Set parent properties
-		super.loadFromState(state);
+        this.fields = state.getStringArray(FIELD_NAMES);
+        this.labels = state.getStringArray(FIELD_LABEL_NAMES);
+        this.colors = (Color[]) state.getArray(FIELD_LABEL_COLOR, Color.class);
+        // Set own properties
+        this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol");
+        this.size = state.getInt("size");
+        this.is3D = state.getBoolean("is3D");
 
-		this.fields = state.getStringArray(FIELD_NAMES);
-		this.labels = state.getStringArray(FIELD_LABEL_NAMES);
-		this.colors = (Color[]) state.getArray(FIELD_LABEL_COLOR,Color.class);
-		// Set own properties
-		this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol");
-		this.size = state.getInt("size");
-		this.is3D = state.getBoolean("is3D");
+        this.isOutlineShow = state.getBoolean("isOutlineShow");
+        this.onlySelection = state.getBoolean("onlySelection");
+        this.isActiveLimits = state.getBoolean("isActiveLimits");
 
-		this.isOutlineShow = state.getBoolean("isOutlineShow");
-		this.onlySelection = state.getBoolean("onlySelection");
-		this.isActiveLimits = state.getBoolean("isActiveLimits");
+        this.outlineWidth = state.getInt("outlineWidth");
+        this.referenceSystem = state.getInt("referenceSystem");
+        this.sizeFrom = state.getInt("sizeFrom");
+        this.sizeTo = state.getInt("sizeTo");
+        this.unit = state.getInt("unit");
+        this.sizeOption = state.getInt("sizeOption");
 
-		this.outlineWidth = state.getInt("outlineWidth");
-		this.referenceSystem = state.getInt("referenceSystem");
-		this.sizeFrom = state.getInt("sizeFrom");
-		this.sizeTo = state.getInt("sizeTo");
-		this.unit = state.getInt("unit");
-		this.sizeOption = state.getInt("sizeOption");
+        this.outlineColor = (Color) state.get("outlineColor");
+        this.symbol = (IChartSymbol) state.get("symbol");
+        this.featSelection = (FeatureSelection) state.get("featSelection");
 
-		this.outlineColor = (Color) state.get("outlineColor");
-		this.symbol = (IChartSymbol) state.get("symbol");
-		this.featSelection = (FeatureSelection) state.get("featSelection");
+        this.fieldSize = state.getString("fieldSize");
+        this.fieldNormalize = state.getString("fieldNormalize");
 
-		this.fieldSize = state.getString("fieldSize");
-		this.fieldNormalize = state.getString("fieldNormalize");
+        this.minFeature = state.getDouble("minFeature");
+        this.maxFeature = state.getDouble("maxFeature");
+        this.maxField = state.getDouble("maxField");
+    }
 
-		this.minFeature = state.getDouble("minFeature");
-		this.maxFeature = state.getDouble("maxFeature");
-		this.maxField = state.getDouble("maxField");
-	}
+    public void saveToState(PersistentState state) throws PersistenceException {
+        // Save parent properties
+        super.saveToState(state);
+        // Save own properties
+        state.set(FIELD_NAMES, this.fields);
+        state.set(FIELD_LABEL_NAMES, this.labels);
+        state.set(FIELD_LABEL_COLOR, this.colors);
 
-	public void saveToState(PersistentState state) throws PersistenceException {
-		// Save parent properties
-		super.saveToState(state);
-		// Save own properties
-		state.set(FIELD_NAMES, this.fields);
-		state.set(FIELD_LABEL_NAMES, this.labels);
-		state.set(FIELD_LABEL_COLOR, this.colors);
+        state.set("backgroundSymbol", this.backgroundSymbol);
+        state.set("size", this.size);
+        state.set("is3D", this.is3D);
 
-		state.set("backgroundSymbol", this.backgroundSymbol);
-		state.set("size", this.size);
-		state.set("is3D", this.is3D);
+        state.set("isOutlineShow", this.isOutlineShow);
+        state.set("onlySelection", this.onlySelection);
+        state.set("isActiveLimits", this.isActiveLimits);
 
-		state.set("isOutlineShow", this.isOutlineShow);
-		state.set("onlySelection", this.onlySelection);
-		state.set("isActiveLimits", this.isActiveLimits);
+        state.set("outlineWidth", this.outlineWidth);
+        state.set("referenceSystem", this.referenceSystem);
+        state.set("sizeFrom", this.sizeFrom);
+        state.set("sizeTo", this.sizeTo);
+        state.set("unit", this.unit);
+        state.set("sizeOption", this.sizeOption);
 
-		state.set("outlineWidth", this.outlineWidth);
-		state.set("referenceSystem", this.referenceSystem);
-		state.set("sizeFrom", this.sizeFrom);
-		state.set("sizeTo", this.sizeTo);
-		state.set("unit", this.unit);
-		state.set("sizeOption", this.sizeOption);
+        state.set("outlineColor", this.outlineColor);
+        state.set("symbol", this.symbol);
+        state.set("featSelection", this.featSelection);
 
-		state.set("outlineColor", this.outlineColor);
-		state.set("symbol", this.symbol);
-		state.set("featSelection", this.featSelection);
+        state.set("fieldSize", this.fieldSize);
+        state.set("fieldNormalize", this.fieldNormalize);
 
-		state.set("fieldSize", this.fieldSize);
-		state.set("fieldNormalize", this.fieldNormalize);
+        state.set("minFeature", this.minFeature);
+        state.set("maxFeature", this.maxFeature);
+        state.set("maxField", this.maxField);
 
-		state.set("minFeature", this.minFeature);
-		state.set("maxFeature", this.maxFeature);
-		state.set("maxField", this.maxField);
+    }
 
-	}
-
-	public static class RegisterPersistence implements Callable {
-
-		public Object call() throws Exception {
-			PersistenceManager manager = ToolsLocator.getPersistenceManager();
-			if( manager.getDefinition(PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
-				DynStruct definition = manager.addDefinition(
-						BasePieChartLegend.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;
-		}
-
-	}
-
+//	public static class RegisterPersistence implements Callable {
+//
+//		public Object call() throws Exception {
+//			PersistenceManager manager = ToolsLocator.getPersistenceManager();
+//			if( manager.getDefinition(BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME)==null ) {
+//				DynStruct definition = manager.addDefinition(
+//						BasePieChartLegend.class,
+//						BASE_PIE_CHART_LEGEND_PERSISTENCE_DEFINITION_NAME,
+//						BASE_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;
+//		}
+//
+//	}
     protected void updateSymbols() {
         ISymbol[] symbols = getSymbols();
-        for (int i = 0; i < symbols.length; i++) {
-            delSymbol(getSymbolKey(symbols[i]));
+        for (ISymbol symbol1 : symbols) {
+            delSymbol(getSymbolKey(symbol1));
         }
         if (fields != null && colors != null && labels != null) {
 
             if (fields.length != colors.length) {
                 LOG.warn("The length of fields and colors isn't the same: fields.length = " + fields.length
-                    + " fields.length = " + colors.length);
+                        + " fields.length = " + colors.length);
             }
 
             if (fields.length != labels.length) {
                 LOG.warn("The length of fields and labels isn't the same: fields.length = " + fields.length
-                    + " labels.length = " + labels.length);
+                        + " labels.length = " + labels.length);
             }
 
             for (int i = 0; i < Math.min(fields.length, Math.min(labels.length, colors.length)); i++) {
-                ISimpleFillSymbol symbol = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol();
-                symbol.setColor(colors[i]);
-                symbol.setDescription(labels[i]);
-                addSymbol(fields[i], symbol);
+                ISimpleFillSymbol symbol1 = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol();
+                symbol1.setColor(colors[i]);
+                symbol1.setDescription(labels[i]);
+                addSymbol(fields[i], symbol1);
             }
         }
     }
Index: 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
===================================================================
--- 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	(revision 570)
+++ 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	(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;
+        }
+
+    }
+
 }
