Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / fmap / rendering / EditionManagerLegend.java @ 11704

History | View | Annotate | Download (3.25 KB)

1
package com.iver.cit.gvsig.fmap.rendering;
2

    
3
import java.util.ArrayList;
4

    
5
import com.hardcode.gdbms.engine.values.Value;
6
import com.hardcode.gdbms.engine.values.ValueFactory;
7
import com.iver.andami.PluginServices;
8
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
9

    
10
public class EditionManagerLegend implements EditionLegend{
11
        private ArrayList rules=new ArrayList();
12
        private IVectorialLegend vectorialLegend;
13
        private IVectorialLegend originalVectorialLegend;
14
        private LegendControl lc=new LegendControl();
15

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

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