svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / fmap / rendering / EditionManagerLegend.java @ 40557
History | View | Annotate | Download (4.12 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.editing.fmap.rendering; |
25 |
|
26 |
import java.util.ArrayList; |
27 |
|
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.fmap.geom.Geometry; |
30 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
31 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
32 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
33 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
34 |
|
35 |
public class EditionManagerLegend implements EditionLegend{ |
36 |
private ArrayList rules=new ArrayList(); |
37 |
private IVectorLegend vectorialLegend;
|
38 |
private IVectorLegend originalVectorialLegend;
|
39 |
private LegendControl lc = new LegendControl(Geometry.TYPES.GEOMETRY); |
40 |
|
41 |
public EditionManagerLegend(IVectorLegend vl) {
|
42 |
originalVectorialLegend=vl; |
43 |
vectorialLegend=vl;//(VectorialLegend)vl.cloneLegend();
|
44 |
} |
45 |
public Object getValue(int i) { |
46 |
Object value=null; |
47 |
if (vectorialLegend instanceof IClassifiedLegend) { |
48 |
value = ((IClassifiedLegend) vectorialLegend).getValues()[i]; |
49 |
}else {
|
50 |
value=new String(PluginServices.getText(this,"todos_los_valores")); |
51 |
} |
52 |
return value;
|
53 |
} |
54 |
public ISymbol getSymbol(int i) { |
55 |
ISymbol symbol=null;
|
56 |
symbol=((IVectorialUniqueValueLegend)vectorialLegend).getSymbolByValue(getValue(i)); |
57 |
return symbol;
|
58 |
} |
59 |
public boolean isActived(int i) { |
60 |
return lc.isActivated(i);
|
61 |
} |
62 |
public boolean isBlocked(int i) { |
63 |
return lc.isBlocked(i);
|
64 |
} |
65 |
public boolean isDisable(int i) { |
66 |
return lc.isDisabled(i);
|
67 |
} |
68 |
public boolean isFilled(int i) { |
69 |
return lc.isFilled(i);
|
70 |
} |
71 |
public boolean isPresent(int i) { |
72 |
return (i==getPresent());
|
73 |
} |
74 |
private int getPresent() { |
75 |
return lc.getPresent();
|
76 |
} |
77 |
public void setActived(int i,boolean b) { |
78 |
lc.setActivated(i,b); |
79 |
} |
80 |
public void setBlocked(int i,boolean b) { |
81 |
lc.setBlocked(i,b); |
82 |
} |
83 |
public void setDisable(int i, boolean b) { |
84 |
lc.setDisabled(i,b); |
85 |
} |
86 |
public void setFilled(int i,boolean b) { |
87 |
lc.setFilled(i,b); |
88 |
} |
89 |
public void setPresent(int i) { |
90 |
lc.setPresent(i); |
91 |
} |
92 |
public int getRowCount() { |
93 |
if (vectorialLegend instanceof IClassifiedLegend) { |
94 |
IClassifiedLegend classifiedLegend = |
95 |
(IClassifiedLegend) vectorialLegend; |
96 |
return classifiedLegend.getValues().length;
|
97 |
} |
98 |
return 1; |
99 |
} |
100 |
public void setValue(int i, Object value) { |
101 |
Object previousValue=getValue(i);
|
102 |
ISymbol previousSymbol=getSymbol(i); |
103 |
Object clave;
|
104 |
ISymbol theSymbol=null;
|
105 |
int numRow=getRowCount();
|
106 |
// Borramos las anteriores listas:
|
107 |
//((UniqueValueLegend)vectorialLegend).clear();
|
108 |
|
109 |
boolean bRestoValores = false; // PONERLO EN UN CHECKBOX |
110 |
int hasta;
|
111 |
hasta = getRowCount(); |
112 |
// for (int row = 0; row < numRow; row++) {
|
113 |
// clave = getValue(row);
|
114 |
// if (row==i)
|
115 |
if (!value.equals(previousValue)) {
|
116 |
((IVectorialUniqueValueLegend)vectorialLegend).delSymbol(previousValue); |
117 |
clave=value; |
118 |
((IVectorialUniqueValueLegend)vectorialLegend).addSymbol(value, previousSymbol); |
119 |
System.out.println(value);
|
120 |
// }
|
121 |
} |
122 |
if (bRestoValores) {
|
123 |
theSymbol = getSymbol(hasta); |
124 |
vectorialLegend.setDefaultSymbol(theSymbol); |
125 |
} |
126 |
} |
127 |
public void setSymbol(int row, Object value) { |
128 |
} |
129 |
public String getPresentSubLayer() { |
130 |
return getValue(getPresent()).toString();
|
131 |
} |
132 |
} |