Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / fmap / rendering / EditionManagerLegend.java @ 30335

History | View | Annotate | Download (3.51 KB)

1
package org.gvsig.editing.fmap.rendering;
2

    
3
import java.util.ArrayList;
4

    
5
import org.gvsig.andami.PluginServices;
6
import org.gvsig.fmap.geom.Geometry;
7
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
8
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
9
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
10
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
11
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend;
12

    
13
public class EditionManagerLegend implements EditionLegend{
14
        private ArrayList rules=new ArrayList();
15
        private IVectorLegend vectorialLegend;
16
        private IVectorLegend originalVectorialLegend;
17
        private LegendControl lc = new LegendControl(Geometry.TYPES.GEOMETRY);
18

    
19
        public EditionManagerLegend(IVectorLegend vl) {
20
                originalVectorialLegend=vl;
21
                vectorialLegend=vl;//(VectorialLegend)vl.cloneLegend();
22
        }
23
        public Object getValue(int i) {
24
                Object value=null;
25
                if (vectorialLegend instanceof VectorialUniqueValueLegend) {
26
                        value=((VectorialUniqueValueLegend)vectorialLegend).getValues()[i];
27
                }else if (vectorialLegend instanceof VectorialIntervalLegend) {
28
                        value=((VectorialIntervalLegend)vectorialLegend).getValues()[i];
29
                }else {
30
                        value=new String(PluginServices.getText(this,"todos_los_valores"));
31
                }
32
                return value;
33
        }
34
        public ISymbol getSymbol(int i) {
35
                ISymbol symbol=null;
36
                        symbol=((IVectorialUniqueValueLegend)vectorialLegend).getSymbolByValue(getValue(i));
37
                return symbol;
38
        }
39
        public boolean isActived(int i) {
40
                return lc.isActivated(i);
41
        }
42
        public boolean isBlocked(int i) {
43
                return lc.isBlocked(i);
44
        }
45
        public boolean isDisable(int i) {
46
                return lc.isDisabled(i);
47
        }
48
        public boolean isFilled(int i) {
49
                return lc.isFilled(i);
50
        }
51
        public boolean isPresent(int i) {
52
                return (i==getPresent());
53
        }
54
        private int getPresent() {
55
                return lc.getPresent();
56
        }
57
        public void setActived(int i,boolean b) {
58
                lc.setActivated(i,b);
59
        }
60
        public void setBlocked(int i,boolean b) {
61
                lc.setBlocked(i,b);
62
        }
63
        public void setDisable(int i, boolean b) {
64
                lc.setDisabled(i,b);
65
        }
66
        public void setFilled(int i,boolean b) {
67
                lc.setFilled(i,b);
68
        }
69
        public void setPresent(int i) {
70
                lc.setPresent(i);
71
        }
72
        public int getRowCount() {
73
                if (vectorialLegend instanceof VectorialUniqueValueLegend || vectorialLegend instanceof VectorialIntervalLegend) {
74
                    VectorialUniqueValueLegend vuvl=(VectorialUniqueValueLegend)vectorialLegend;
75
                    return vuvl.getValues().length;
76
            }
77
        return 1;
78
        }
79
        public void setValue(int i, Object value) {
80
                Object previousValue=getValue(i);
81
                ISymbol previousSymbol=getSymbol(i);
82
                Object clave;
83
            ISymbol theSymbol=null;
84
            int numRow=getRowCount();
85
            // Borramos las anteriores listas:
86
            //((UniqueValueLegend)vectorialLegend).clear();
87

    
88
            boolean bRestoValores = false; // PONERLO EN UN CHECKBOX
89
            int hasta;
90
            hasta = getRowCount();
91
//            for (int row = 0; row < numRow; row++) {
92
//                clave = getValue(row);
93
//                    if (row==i)
94
            if (!value.equals(previousValue)) {
95
                    ((IVectorialUniqueValueLegend)vectorialLegend).delSymbol(previousValue);
96
                    clave=value;
97
                ((IVectorialUniqueValueLegend)vectorialLegend).addSymbol(value, previousSymbol);
98
                System.out.println(value);
99
//            }
100
            }
101
            if (bRestoValores) {
102
                      theSymbol = getSymbol(hasta);
103
                       vectorialLegend.setDefaultSymbol(theSymbol);
104
            }
105
        }
106
        public void setSymbol(int row, Object value) {
107
        }
108
        public String getPresentSubLayer() {
109
                return getValue(getPresent()).toString();
110
        }
111
}