Revision 31631

View differences:

branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/gui/styling/SymbolLevelsWindow.java
78 78
import org.gvsig.andami.ui.mdiManager.WindowInfo;
79 79
import org.gvsig.app.project.documents.gui.TableSymbolCellRenderer;
80 80
import org.gvsig.fmap.mapcontext.MapContextLocator;
81
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
81 82
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
82 83
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
83 84
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
......
87 88
import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor;
88 89
import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer;
89 90
import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer;
90
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ZSort;
91 91

  
92 92

  
93 93
/**
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/layout/fframes/FFrameLegend.java
66 66
import org.gvsig.fmap.mapcontext.layers.FLayers;
67 67
import org.gvsig.fmap.mapcontext.layers.operations.Classifiable;
68 68
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
69
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
69 70
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
70 71
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
71 72
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
72
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IClassifiedLegend;
73 73
import org.gvsig.utils.XMLEntity;
74 74

  
75 75

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/edition/gui/PanelEditInterval.java
56 56
import org.gvsig.andami.PluginServices;
57 57
import org.gvsig.andami.ui.mdiManager.IWindow;
58 58
import org.gvsig.andami.ui.mdiManager.WindowInfo;
59
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IInterval;
59
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
60 60
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
61 61

  
62 62

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/edition/gui/IntervalCellEditor.java
57 57
import javax.swing.table.TableCellEditor;
58 58

  
59 59
import org.gvsig.andami.PluginServices;
60
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IInterval;
60
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
61 61
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
62 62

  
63 63

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/VectorialUniqueValue.java
76 76
import org.gvsig.fmap.mapcontext.layers.operations.ClassifiableVectorial;
77 77
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
78 78
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
79
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
80
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
79 81
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
80 82
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
81 83
import org.gvsig.gui.beans.swing.JBlank;
82 84
import org.gvsig.gui.beans.swing.JButton;
83 85
import org.gvsig.raster.datastruct.ColorItem;
84
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
85
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ZSort;
86 86
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractClassifiedVectorLegend;
87 87
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
88 88
import org.slf4j.Logger;
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/LegendManager.java
76 76
import org.gvsig.fmap.mapcontext.layers.operations.Classifiable;
77 77
import org.gvsig.fmap.mapcontext.layers.operations.ClassifiableVectorial;
78 78
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
79
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
79 80
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
81
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
80 82
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
81 83
import org.gvsig.gui.beans.swing.JButton;
82
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
83
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
84 84

  
85 85
/**
86 86
 * Implements the panel which allows the user to control all the information about the
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/VectorialInterval.java
74 74
import org.gvsig.fmap.mapcontext.layers.FLayer;
75 75
import org.gvsig.fmap.mapcontext.layers.operations.ClassifiableVectorial;
76 76
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
77
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
77 78
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
79
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialIntervalLegend;
78 80
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
79 81
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
80 82
import org.gvsig.gui.beans.swing.JButton;
81
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IInterval;
82
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IVectorialIntervalLegend;
83 83
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
84 84
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
85 85
import org.slf4j.Logger;
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/SingleSymbol.java
68 68
import org.gvsig.fmap.mapcontext.layers.FLayer;
69 69
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
70 70
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
71
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
71 72
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
72 73
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
73 74
import org.gvsig.gui.beans.swing.JButton;
74
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ZSort;
75 75
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend;
76 76
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.SingleSymbolLegend;
77 77

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toc/actions/ChangeSymbolTocMenuEntry.java
13 13
import org.gvsig.fmap.mapcontext.MapContext;
14 14
import org.gvsig.fmap.mapcontext.layers.FLayer;
15 15
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
16
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
16 17
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
18
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
17 19
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
18 20
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
19
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
20
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
21 21
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MultiLayerFillSymbol;
22 22
import org.slf4j.Logger;
23 23
import org.slf4j.LoggerFactory;
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toc/gui/TOC.java
99 99
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
100 100
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection;
101 101
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
102
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
102 103
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
104
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
103 105
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
104 106
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent;
105 107
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener;
106 108
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
107
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IClassifiedLegend;
108
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
109 109

  
110 110

  
111

  
111 112
/**
112 113
 * DOCUMENT ME!
113 114
 *
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IClassifiedRasterLegend.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend;
42

  
43
import org.gvsig.fmap.mapcontext.rendering.legend.IRasterLegend;
44

  
45

  
46
/**
47
 * @author jaume dominguez faus - jaume.dominguez@iver.es
48
 */
49
public interface IClassifiedRasterLegend extends IRasterLegend,
50
		IClassifiedLegend {
51

  
52
	// The interface does not add any new methods.
53
}
0 54

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IClassifiedVectorLegend.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend;
42

  
43

  
44
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46

  
47
/**
48
 * Interface that offers the methods to classify the legend.
49
 */
50
public interface IClassifiedVectorLegend extends IClassifiedLegend, IVectorLegend{
51
	/**
52
	 * Deletes all the information of classification:
53
	 * intervals, values, or other classifying elements
54
	 */
55
	public abstract void clear();
56

  
57
	/**
58
	 * Returns the name of the field
59
	 *
60
	 * @return Name of the field.
61
	 *
62
	 * TODO refactor to allow more than one field name
63
	 */
64
	public abstract String[] getClassifyingFieldNames();
65

  
66
	/**
67
	 * Inserts the name of the field
68
	 *
69
	 * @param fieldNames Names of the fields.
70
	 * TODO refactor to allow more than one field name
71
	 */
72
	public abstract void setClassifyingFieldNames(String[] fieldNames);
73

  
74
	 /**
75
     * Inserts a symbol.
76
     *
77
     * @param key.
78
     * @param symbol.
79
     */
80
	public abstract void addSymbol(Object key, ISymbol symbol);
81

  
82
    /**
83
     * Deletes a symbol using for that its key which is the parameter of the
84
     * method.
85
     *
86
     * @param key clave.
87
     */
88
	public abstract void delSymbol(Object key);
89

  
90
	/**
91
	 * Removes <b>oldSymbol</b> from the Legend and substitutes it with the <b>newSymbol</b>
92
	 * @param oldSymbol
93
	 * @param newSymbol
94
	 */
95
	public abstract void replace(ISymbol oldSymbol, ISymbol newSymbol);
96

  
97
	public int[] getClassifyingFieldTypes();
98

  
99
	public void setClassifyingFieldTypes(int[] fieldTypes);
100
}
0 101

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/ZSort.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend;
42

  
43
import java.util.HashMap;
44
import java.util.Map;
45

  
46
import org.gvsig.fmap.mapcontext.MapContextException;
47
import org.gvsig.fmap.mapcontext.rendering.legend.events.IntervalLegendEvent;
48
import org.gvsig.fmap.mapcontext.rendering.legend.events.LabelLegendEvent;
49
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent;
50
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent;
51
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
52
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
53
import org.gvsig.fmap.mapcontext.rendering.legend.events.ValueLegendEvent;
54
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
55
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
56

  
57
/**
58
 * Class ZSort is used in order to store information about the symbols
59
 * which are placed in the Z axis (because a level of symbols has been
60
 * used).
61
 *
62
 * @author jaume dominguez faus - jaume.dominguez@iver.es
63
 */
64
public class ZSort implements LegendContentsChangedListener {
65
	// private static final String COLUMN_SEPARATOR = ",";
66
	// private static final String ROW_SEPARATOR = ";";
67
	private int[][] matrix;
68
	private boolean usingZSort;
69
	private Map symbols = new HashMap();
70

  
71
	public ZSort(ILegend legend) {
72
		initialize(legend);
73
	}
74

  
75
	private void initialize(ILegend legend) {
76
		ISymbol[] symbols;
77
		if (legend instanceof IClassifiedLegend) {
78
			symbols = ((IClassifiedLegend) legend).getSymbols();
79

  
80
		} else {
81
			symbols = new ISymbol[] {legend.getDefaultSymbol()};
82
		}
83
		matrix = new int[symbols.length][];
84

  
85
		for (int i = 0; i < symbols.length; i++) {
86
			this.symbols.put(symbols[i], new Integer(i));
87
			int rowLength =  symbols[i] instanceof IMultiLayerSymbol ?
88
                  	 ((IMultiLayerSymbol) symbols[i]).getLayerCount() :
89
	                 1;
90
			matrix[i] = new int[rowLength];
91
		}
92
		legend.addLegendListener(this);
93
	}
94

  
95
	private void addSymbol(ISymbol sym){
96
		if (!symbols.containsKey(sym)) {
97
			int rowLength =  sym instanceof IMultiLayerSymbol ?
98
					((IMultiLayerSymbol) sym).getLayerCount() : 1;
99
			int[][] auxMatrix = new int[matrix.length+1][];
100
			int newIndex = matrix.length;
101
			for (int i=0; i<newIndex; i++){
102
				auxMatrix[i] = matrix[i];
103
			}
104
			int[] row = new int[rowLength];
105
			for (int i=0; i<rowLength; i++){
106
				row[i] = 0;
107
			}
108
			auxMatrix[newIndex] = row;
109
			matrix = auxMatrix;
110
			this.symbols.put(sym, new Integer(newIndex));
111
		}
112
	}
113

  
114
	public void legendChanged(LegendChangedEvent e) throws MapContextException {
115
		symbols.clear();
116
		usingZSort = false;
117
		initialize(e.getNewLegend());
118

  
119
	}
120

  
121
	public String getClassName() {
122
		return getClass().getName();
123
	}
124

  
125
	public int getLevelCount() {
126
		int count = -1;
127
		for (int i = 0; i < matrix.length; i++) {
128
			for (int j = 0; j < matrix[i].length; j++) {
129
				count = Math.max(count, matrix[i][j]);
130
			}
131
		}
132
		return count + 1;
133
	}
134

  
135

  
136
	public void setUsingZSort(boolean usingZSort) {
137
		this.usingZSort = usingZSort;
138
	}
139

  
140
	public void setLevels(ISymbol sym, int[] values) {
141
		setLevels(((Integer)symbols.get(sym)).intValue(), values);
142
	}
143

  
144

  
145
	public void setLevels(int row, int[] values) {
146
		matrix[row] = values;
147
	}
148

  
149
	public int[] getLevels(ISymbol sym) {
150
		Integer row = (Integer) symbols.get(sym);
151
		if (row != null) {
152
			return getLevels(row.intValue());
153
		} else {
154
			ISymbol[] theSymbols = getSymbols();
155
			for (int i = 0; i < theSymbols.length; i++) {
156
				ISymbol auxSymbol = theSymbols[i];
157
				if (auxSymbol.equals(sym)){
158
					return getLevels(((Integer)symbols.get(auxSymbol)).intValue());
159
				}
160
			}
161
		}
162
		return null;
163
	}
164

  
165

  
166
	public int[] getLevels(int row) {
167
		return matrix[row];
168
	}
169

  
170

  
171
	public boolean isUsingZSort() {
172
		return usingZSort;
173
	}
174

  
175

  
176
	public ISymbol[] getSymbols() {
177
		return (ISymbol[])symbols.keySet().toArray(new ISymbol[0]);
178
	}
179

  
180

  
181
	public String[] getDescriptions() {
182
		ISymbol[] symbols = getSymbols();
183
		String[] descs = new String[symbols.length];
184
		for (int i = 0; i < descs.length; i++) {
185
			descs[i] = symbols[i].getDescription();
186
		}
187
		return descs;
188
	}
189

  
190
	/*
191
	 * [PACO] Comentarizado porque no hace lo que se esperar?a de ?l.
192
	 * Si tenemos una leyenda con un simbolo Multilayer compuesto
193
	 * por, entre otros, un simbolo simple que coincide con otro de
194
	 * los simbolos de la leyenda, este metodo devuelve el nivel
195
	 * del s?mbolo que encuentra primero.
196
	 *
197
	 * Se ha eliminado cualquier referencia a este metodo en el resto
198
	 * del workspace, sustituyendola convenientemente por
199
	 * referencias a getLevels.
200
	 */
201
//	public int getSymbolLevel(ISymbol layer) {
202
//		ISymbol[] theSymbols = getSymbols();
203
//
204
//		for (int i = 0; i < theSymbols.length; i++) {
205
//			ISymbol mySymbol = theSymbols[i];
206
//
207
//			if (mySymbol instanceof IMultiLayerSymbol) {
208
//				IMultiLayerSymbol multiSym = (IMultiLayerSymbol) mySymbol;
209
//				for (int j = 0; j < multiSym.getLayerCount(); j++) {
210
//					ISymbol myInnerSymbol = multiSym.getLayer(j);
211
//					if (myInnerSymbol.equals(layer)) {
212
//						int row = ((Integer)symbols.get(multiSym)).intValue();
213
//						return matrix[row][j];
214
//					}
215
//				}
216
//			} else {
217
//				if (mySymbol.equals(layer)) {
218
//					return matrix[((Integer)symbols.get(layer)).intValue()][0];
219
//				}
220
//			}
221
//		}
222
//
223
////		return 0;
224
//		return -1;
225
//	}
226

  
227
	public int getTopLevelIndexAllowed() {
228
		ISymbol[] symbols = getSymbols();
229
		int count=0;
230
		for (int i = 0; i < symbols.length; i++) {
231
			if (symbols[i] instanceof IMultiLayerSymbol) {
232
				IMultiLayerSymbol mSymbol = (IMultiLayerSymbol) symbols[i];
233
				count = Math.max(count, mSymbol.getLayerCount());
234
			} else
235
				count = Math.max(count, 1);
236
		}
237
		return count;
238
	}
239

  
240
	public String toString() {
241
		String out = "Symbols:\n---------\n\n";
242
		ISymbol[] syms = getSymbols();
243
		for (int i = 0; i < syms.length; i++) {
244
			out += syms.getClass()+":\t"+syms[i].getDescription();
245
		}
246
		out += "\nMatrix:\n--------\n\n";
247
		out += "    \t";
248
		for (int i = 0; i < getTopLevelIndexAllowed(); i++) {
249
			out += "column"+i+"\t\t";
250
		}
251
		out += "\n";
252
		for (int i = 0; i < matrix.length; i++) {
253
			out += "row "+i+":\t";
254
			for (int j = 0; j < matrix[i].length; j++) {
255
				out += matrix[i][j]+"\t\t";
256
			}
257
			out += "\n";
258
		}
259
		return out;
260
	}
261

  
262
	private void replaceSymbol(ISymbol oldSymbol, ISymbol newSymbol) {
263
		if (oldSymbol == newSymbol) return;
264

  
265
		if(oldSymbol != null){
266

  
267
			Integer value = (Integer)symbols.get(oldSymbol);
268
			if (value != null){
269

  
270
				int intValue=value.intValue();
271
				if (newSymbol == null) {
272
					// emptying
273
					symbols.remove(oldSymbol);
274
					matrix[intValue] = new int[1];
275
				} else {
276
					symbols.remove(oldSymbol);
277

  
278
					symbols.put(newSymbol, value);
279

  
280
					// update matrix values if need
281
					int newArrayLength = newSymbol instanceof IMultiLayerSymbol ?
282
							((IMultiLayerSymbol) newSymbol).getLayerCount() : 1;
283

  
284
							int[] newRow = new int[newArrayLength];
285
							if (matrix[intValue].length == newArrayLength) {
286
								/*
287
								 * the new row is exactly the same long than the
288
								 * old one. Will use the old values
289
								 */
290
								newRow = matrix[intValue];
291
							} else	if (matrix[intValue].length < newArrayLength) {
292
								/*
293
								 * the new row is larger than the old one,
294
								 * let's copy all the first values and fill
295
								 * the rest with the last copied value
296
								 */
297
								int val=0;
298
								for (int i = 0; i < newRow.length; i++) {
299
									if (i<matrix[intValue].length) {
300
										val = matrix[intValue][i];
301
									}
302

  
303
									newRow[i] = val;
304
								}
305
							} else if (matrix[intValue].length > newArrayLength) {
306
								/*
307
								 * the new row is smaller than the old one,
308
								 * let's copy the first values
309
								 */
310
								for (int i = 0; i < newRow.length; i++) {
311
									newRow[i] = matrix[intValue][i];
312
								}
313
							}
314
							matrix[intValue] = newRow;
315
				}
316
			}
317
		} else {
318
			addSymbol(newSymbol);
319
		}
320
	}
321

  
322
	public boolean symbolChanged(SymbolLegendEvent e) {
323
		replaceSymbol(e.getOldSymbol(), e.getNewSymbol());
324
		return true;
325
	}
326

  
327

  
328
	public boolean classifiedSymbolChange(SymbolLegendEvent e) {
329
		replaceSymbol(e.getOldSymbol(), e.getNewSymbol());
330
		return true;
331
	}
332

  
333
	public boolean intervalChange(IntervalLegendEvent e) {
334
		return false;
335
	}
336

  
337
	public boolean valueChange(ValueLegendEvent e) {
338
		System.out.println("log ValueLegendEvent:"+e.getOldValue()+"->"+e.getNewValue());
339
		return false;
340
	}
341

  
342
	// TODO should not exist here
343
	public boolean labelFieldChange(LabelLegendEvent e) {
344
		return false;
345
	}
346

  
347

  
348
	public void legendCleared(LegendClearEvent event) {
349
//		this.usingZSort = false;
350
//		symbols.clear();
351
//		matrix = null;
352
	}
353

  
354
}
0 355

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/events/IntervalLegendEvent.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend.events;
42

  
43
import org.gvsig.fmap.mapcontext.events.FMapEvent;
44
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
45

  
46

  
47
/**
48
 * <p>Event produced when changes the interval value of a classification legend.</p>
49
 * 
50
 * @see FMapEvent
51
 * 
52
 * @author jaume dominguez faus - jaume.dominguez@iver.es
53
 */
54
public class IntervalLegendEvent extends ClassificationLegendEvent {
55
	/**
56
	 * <p>Previous legend interval.</p> 
57
	 */
58
	private IInterval oldInterval;
59
	/**
60
	 * <p>Previous legend interval.</p> 
61
	 */
62
	private IInterval newInterval;
63

  
64
	/**
65
	 * <p>Creates a new legend interval event.</p>
66
	 *
67
	 * @param oldInterval previous legend interval
68
	 * @param newInterval new legend interval
69
	 */
70
	public IntervalLegendEvent(IInterval oldInterval, IInterval newInterval) {
71
		this.oldInterval = oldInterval;
72
		this.newInterval = newInterval;
73
	}
74

  
75
	/**
76
	 * <p>Gets the previous legend interval.</p>
77
	 *
78
	 * @return the previous legend interval
79
	 */
80
	public IInterval getOldInterval() {
81
		return oldInterval;
82
	}
83

  
84
	/**
85
	 * <p>Gets the new legend interval.</p>
86
	 *
87
	 * @return the new legend interval
88
	 */
89
	public IInterval getNewInterval() {
90
		return newInterval;
91
	}
92

  
93
	/**
94
	 * <p>Returns the type of this legend event.</p>
95
	 * 
96
	 * @return the type of this legend event
97
	 * 
98
	 * @see LegendEvent#LEGEND_INTERVAL_CHANGED
99
	 */
100
	public int getEventType() {
101
		return LegendEvent.LEGEND_INTERVAL_CHANGED;
102
	}
103
}
0 104

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/events/ValueLegendEvent.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend.events;
42

  
43
import org.gvsig.fmap.mapcontext.events.FMapEvent;
44
import org.gvsig.fmap.mapcontext.rendering.legend.events.ClassificationLegendEvent;
45
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendEvent;
46

  
47

  
48
/**
49
 * <p>Event produced when changes any value of a legend.</p>
50
 *
51
 * @see FMapEvent
52
 * @author Vicente Caballero Navarro
53
 */
54
public class ValueLegendEvent extends ClassificationLegendEvent {
55
	/**
56
	 * <p>Previous legend value.</p>
57
	 */
58
	private Object oldValue;
59

  
60
	/**
61
	 * <p>New legend value.</p>
62
	 */
63
	private Object newValue;
64

  
65
	/**
66
	 * <p>Creates a new value legend event.</p>
67
	 *
68
	 * @param oldValue previous legend value
69
	 * @param newValue new legend value
70
	 */
71
	public ValueLegendEvent(Object oldValue, Object newValue) {
72
		this.oldValue = oldValue;
73
		this.newValue = newValue;
74
	}
75

  
76
	/**
77
	 * <p>Gets the previous value.</p>
78
	 *
79
	 * @return the previous value
80
	 */
81
	public Object getOldValue() {
82
		return oldValue;
83
	}
84

  
85
	/**
86
	 * <p>Gets the new value.</p>
87
	 *
88
	 * @return the new value
89
	 */
90
	public Object getNewValue() {
91
		return newValue;
92
	}
93

  
94
	/**
95
	 * <p>Returns the type of this legend event.</p>
96
	 * 
97
	 * @return the type of this legend event
98
	 * 
99
	 * @see LegendEvent#LEGEND_VALUE_CHANGED
100
	 */
101
	public int getEventType() {
102
		return LegendEvent.LEGEND_VALUE_CHANGED;
103
	}
104
}
0 105

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/events/LabelLegendEvent.java
41 41
package org.gvsig.fmap.mapcontext.rendering.legend.events;
42 42

  
43 43
import org.gvsig.fmap.mapcontext.events.FMapEvent;
44
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendEvent;
44 45

  
45 46

  
46 47

  
47 48

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IVectorialIntervalLegend.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22
package org.gvsig.fmap.mapcontext.rendering.legend;
23

  
24
import java.awt.Color;
25

  
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.fmap.dal.feature.FeatureStore;
28
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
29

  
30

  
31
/**
32
 * Interface that allows the methods to classify the legend through intervals.
33
 *
34
 */
35
public interface IVectorialIntervalLegend extends IClassifiedVectorLegend {
36
	
37
	public static final String LEGEND_NAME = "VectorialInterval";
38

  
39
    public void setDefaultSymbol(ISymbol s);
40

  
41
    public IInterval getInterval(Object v) ;
42
    public int getIntervalType();
43

  
44
	/**
45
	 *
46
	 * Returns the symbol starting from an interval
47
	 *
48
	 * @param key interval.
49
	 *
50
	 * @return symbol.
51
	 */
52
    public ISymbol getSymbolByInterval(IInterval key);
53

  
54

  
55
    /**
56
     * Inserts the type of the classification of the intervals.
57
	 *
58
	 * @param tipoClasificacion type of the classification.
59
	 */
60
    public void setIntervalType(int tipoClasificacion);
61

  
62
    /**
63
	 * Inserts the initial color
64
	 * @param startColor initial color.
65
	 */
66
	public void setStartColor(Color startColor);
67

  
68
    /**
69
	 * Inserts the final color.
70
	 * @param endColor final color.
71
	 */
72
	public void setEndColor(Color endColor);
73

  
74
    /**
75
	 * Returns the initial color.
76
	 * @return  Color initial color.
77
	 */
78
	public Color getStartColor();
79

  
80
    /**
81
	 * Returns the final color
82
	 * @return Color  final color.
83
	 */
84
	public Color getEndColor();
85

  
86
	public IInterval[] calculateIntervals(FeatureStore featureStore,
87
			String selectedItem, int intervalCount, int shapeType)
88
			throws DataException;
89

  
90

  
91
//    public ISymbol getSymbol(FeatureReference id) throws DataException;
92

  
93
}
94

  
0 95

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IInterval.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22
package org.gvsig.fmap.mapcontext.rendering.legend;
23

  
24
import org.gvsig.tools.lang.Cloneable;
25
import org.gvsig.tools.persistence.Persistent;
26

  
27
public interface IInterval extends Persistent, Cloneable {
28

  
29
	/**
30
	 * Returns if the given value is included into the interval.
31
	 * 
32
	 * @param v
33
	 *            value to check. Must be instance of {@link Number}
34
	 * 
35
	 * @return if the given value is included into the interval
36
	 */
37
	boolean isInInterval(Object v);
38

  
39
	/**
40
	 * Returns the interval minimum included value.
41
	 * 
42
	 * @return the minimum value
43
	 */
44
	double getMin();
45

  
46
	/**
47
	 * Returns the interval maximum included value.
48
	 * 
49
	 * @return the maximum value
50
	 */
51
	double getMax();
52

  
53
}
0 54

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IClassifiedLegend.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend;
42

  
43

  
44
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46

  
47

  
48
/**
49
 * Information of the legend that allows to be represented graphically to the user
50
 * 
51
 */
52
public interface IClassifiedLegend extends ILegend {
53
	/**
54
	 * Obtains the descriptions of the classes that are in the classification
55
	 * @return DOCUMENT ME!
56
	 */
57
	String[] getDescriptions();
58

  
59
	/**
60
	 * Obtains the symbols of each class of the classification for the user.
61
	 *
62
	 * @return DOCUMENT ME!
63
	 */
64
	ISymbol[] getSymbols();
65

  
66
	/**
67
	 * Obtains the values in relation with each class of the classification
68
	 *
69
	 * @return DOCUMENT ME!
70
	 */
71
	Object[] getValues();
72
}
0 73

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/ISingleSymbolLegend.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {gvSIG}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.rendering.legend;
28

  
29
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
30

  
31
/**
32
 * Legend based on one single symbol to use while rendering.
33
 * 
34
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
35
 */
36
public interface ISingleSymbolLegend extends IVectorLegend {
37
	
38
	public static final String LEGEND_NAME = "SingleSymbol";
39
	
40
	ZSort getZSort();
41

  
42
	void setZSort(ZSort zSort);
43

  
44
}
0 45

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/IVectorialUniqueValueLegend.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.mapcontext.rendering.legend;
42

  
43

  
44
import java.awt.Color;
45

  
46
import org.gvsig.fmap.mapcontext.MapContextException;
47
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
48

  
49

  
50
/**
51
 * Interface for the legend with unique values.
52
 *
53
 */
54
public interface IVectorialUniqueValueLegend extends IClassifiedVectorLegend {
55
	
56
	public static final String LEGEND_NAME = "VectorialUniqueValue";
57
	
58
    /**
59
     * Establishes the symbol for the value which is the argument of the function.
60
     *
61
     * @param id index.
62
     * @param symbol symbol.
63
     */
64
    void setValueSymbolByID(int id, ISymbol symbol);
65

  
66

  
67
    /**
68
     * Returns the symbols starting from an ID. It looks in m_ArrayKeys for the
69
     * element ID and with this key obtains the FSymbol.
70

  
71
     * @param key ID.
72
     *
73
     * @return symbol associated with the ID
74
     */
75

  
76
    // public FSymbol getSymbolByID(int ID);
77

  
78
    /**
79
     * Returns the symbols starting from its key.
80
     *
81
     * @param key ID.
82
     *
83
     * @return symbol associated with the key.
84
     * @throws MapContextException 
85
     */
86
    public ISymbol getSymbolByValue(Object key);
87

  
88
	ZSort getZSort();
89

  
90
	void setZSort(ZSort zSort);
91

  
92
	Color[] getColorScheme();
93

  
94
	void setColorScheme(Color[] colors);
95
}
0 96

  
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/impl/DefaultGraphicLayer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
1 27
package org.gvsig.fmap.mapcontext.layers.vectorial.impl;
2 28

  
3
import java.util.Hashtable;
4
import java.util.Map;
5

  
6 29
import org.cresques.cts.IProjection;
7 30
import org.gvsig.fmap.dal.DALLocator;
8 31
import org.gvsig.fmap.dal.DataManager;
......
21 44
import org.gvsig.fmap.geom.Geometry;
22 45
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
23 46
import org.gvsig.fmap.geom.Geometry.TYPES;
47
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
24 48
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
25 49
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
26 50
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
51
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
52
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
27 53
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
28 54
import org.gvsig.tools.exception.BaseException;
29 55
import org.slf4j.Logger;
30 56
import org.slf4j.LoggerFactory;
31 57

  
58
/**
59
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
60
 */
32 61
public class DefaultGraphicLayer extends FLyrVect implements GraphicLayer{
33 62
	protected static final Logger logger = LoggerFactory.getLogger(DefaultGraphicLayer.class);
34 63
	private static DataManager dataManager = DALLocator.getDataManager();
35

  
64
	private IVectorialUniqueValueLegend legend = null;
65
	
36 66
	private FeatureStore store = null;
37 67
	private long ids = 0;
38 68

  
39
	private Map symbols = null;
40 69
	private int symbolId = -1;
41 70

  
42 71
	public DefaultGraphicLayer() {
43
		super();
44
		symbols = new Hashtable();
72
		super();	
45 73
	}
46 74

  
47 75
	public void initialize(IProjection projection) throws ValidateDataParametersException, DataException, LoadLayerException { 
......
130 158
		} catch (DataException e) {
131 159
			logger.error("Error adding a geometry to the graphic layer", e);
132 160
		}
133

  
134 161
	}
135 162

  
136 163
	public int addSymbol(ISymbol newSymbol) {
137 164
		symbolId++;
138
		symbols.put(new Integer(symbolId), newSymbol);
165
		legend.addSymbol(new Integer(symbolId), newSymbol);
139 166
		return symbolId;
140 167
	}
141 168

  
142 169
	public ISymbol getSymbol(int symbolPos) {
143
		return (ISymbol)symbols.get(new Integer(symbolPos));
170
		return legend.getSymbolByValue(new Integer(symbolPos));		
144 171
	}
145 172

  
146 173
	public void clearAllGraphics() {
......
169 196
	}
170 197

  
171 198
	public int clearAllSymbols() {
172
		symbols.clear();
199
		legend.clear();
173 200
		symbolId = -1;
174 201
		return symbolId;
175 202
	}
......
208 235
			store = null;
209 236
		}
210 237
	}
211
}
212 238

  
213

  
214
//package org.gvsig.fmap.mapcontext.layers;
215
//
216
//import java.awt.Graphics2D;
217
//import java.awt.geom.Rectangle2D;
218
//import java.awt.image.BufferedImage;
219
//import java.util.ArrayList;
220
//import java.util.Collection;
221
//import java.util.Set;
222
//
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff