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 @ 1306

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 int getBandInputLayer() {
47
                return panel.getLayerSelection().getBandsSelectorCombo()
48
                        .getSelectedIndex() - 1;
49
        }
50
        
51
        public int getOperation() {
52
                return panel.getOperationMaskThresholdPanel().getComboText()
53
                        .getCombo().getSelectedIndex();
54
        }
55
        
56
        public int getOperationMethod() {
57
                return panel.getOperationMaskThresholdPanel().getLayerRadio()
58
                        .isSelected() ? 1 : 0;
59
        }
60
        
61
        public double getThresholdValue() {
62
                try {
63
                return new Double(panel.getOperationMaskThresholdPanel().getComboText()
64
                        .getTextField().getText());
65
                } catch (NumberFormatException e) {
66
                        return 0;
67
                }
68
        }
69
        
70
        public Object getOperationLayer() {
71
                Object obj = panel.getOperationMaskThresholdPanel().getLayerSelection()
72
                        .getInputLayerCombo().getSelectedItem();
73
                if(obj == null)
74
                        return panel.getOperationMaskThresholdPanel().getLayerSelection()
75
                                .getInputLayerCombo().getItemAt(0);
76
                else
77
                        return obj;
78
        }
79
        
80
        public int getBandOperationLayer() {
81
                return panel.getOperationMaskThresholdPanel().getLayerSelection()
82
                        .getBandsSelectorCombo().getSelectedIndex() - 1;
83
        }
84
        
85
        public Object getOutputInputLayer() {
86
                Object obj = panel.getOutputMaskThresholdPanel().getLayerSelection()
87
                        .getInputLayerCombo().getSelectedItem();
88
                if(obj == null)
89
                        return panel.getOutputMaskThresholdPanel().getLayerSelection()
90
                                .getInputLayerCombo().getItemAt(0);
91
                else
92
                        return obj;
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
}