Statistics
| Revision:

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

History | View | Annotate | Download (3.41 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.mapcontext.rendering.legend.IVectorLegend;
7
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
8
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialIntervalLegend;
9
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend;
10
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
11

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

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

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