Statistics
| Revision:

gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.algorithm / org.gvsig.raster.tools.algorithm.swing / org.gvsig.raster.tools.algorithm.swing.impl / src / main / java / org / gvsig / raster / tools / algorithm / swing / impl / maskthreshold / MaskThresholdDataImpl.java @ 1319

History | View | Annotate | Download (3.39 KB)

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.raster.tools.algorithm.swing.impl.maskthreshold;
23

    
24
import org.gvsig.raster.tools.algorithm.swing.maskthreshold.MaskThresholdData;
25

    
26
/**
27
 * Data model for the mask threshold user interface
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public class MaskThresholdDataImpl implements MaskThresholdData {
31
        private MaskThresholdPanelImpl panel = null;
32
        
33
        public MaskThresholdDataImpl(MaskThresholdPanelImpl panel) {
34
                this.panel = panel;
35
        }
36
        
37
        public Object getInputLayer() {
38
                Object obj = panel.getLayerSelection().getInputLayerCombo()
39
                        .getSelectedItem();
40
                if(obj == null)
41
                        return panel.getLayerSelection().getInputLayerCombo().getItemAt(0);
42
                else
43
                        return obj;
44
        }
45
        
46
        public Object getOperationLayer() {
47
                Object obj = panel.getOperationMaskThresholdPanel().getLayerSelection()
48
                        .getInputLayerCombo().getSelectedItem();
49
                if(obj == null)
50
                        return panel.getOperationMaskThresholdPanel().getLayerSelection()
51
                                .getInputLayerCombo().getItemAt(0);
52
                else
53
                        return obj;
54
        }
55
        
56
        public Object getOutputInputLayer() {
57
                Object obj = panel.getOutputMaskThresholdPanel().getLayerSelection()
58
                        .getInputLayerCombo().getSelectedItem();
59
                if(obj == null)
60
                        return panel.getOutputMaskThresholdPanel().getLayerSelection()
61
                                .getInputLayerCombo().getItemAt(0);
62
                else
63
                        return obj;
64
        }
65
        
66
        public int getBandInputLayer() {
67
                return panel.getLayerSelection().getBandsSelectorCombo()
68
                        .getSelectedIndex() - 1;
69
        }
70
        
71
        public int getOperation() {
72
                return panel.getOperationMaskThresholdPanel().getComboText()
73
                        .getCombo().getSelectedIndex();
74
        }
75
        
76
        public int getOperationMethod() {
77
                return panel.getOperationMaskThresholdPanel().getLayerRadio()
78
                        .isSelected() ? 1 : 0;
79
        }
80
        
81
        public double getThresholdValue() {
82
                try {
83
                return new Double(panel.getOperationMaskThresholdPanel().getComboText()
84
                        .getTextField().getText());
85
                } catch (NumberFormatException e) {
86
                        return 0;
87
                }
88
        }
89
        
90
        public int getBandOperationLayer() {
91
                return panel.getOperationMaskThresholdPanel().getLayerSelection()
92
                        .getBandsSelectorCombo().getSelectedIndex() - 1;
93
        }
94
        
95
        public int getBandOutputLayer() {
96
                return panel.getOutputMaskThresholdPanel().getLayerSelection()
97
                        .getBandsSelectorCombo().getSelectedIndex() - 1;
98
        }
99
        
100
    public int getMethodOutput() {
101
            return panel.getOutputMaskThresholdPanel().getMethodOutput()
102
                    .getCombo().getSelectedIndex();
103
    }
104
        
105
        public double getFixedValue() {
106
                try {
107
                        return new Double(panel.getOutputMaskThresholdPanel().getMethodOutput()
108
                                        .getTextField().getText());
109
                } catch (NumberFormatException e) {
110
                        return 0;
111
                }
112
        }
113

    
114
}