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 / OutputMaskThresholdImpl.java @ 1319

History | View | Annotate | Download (3.56 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 java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28

    
29
import javax.swing.BorderFactory;
30
import javax.swing.JPanel;
31

    
32
import org.gvsig.i18n.Messages;
33
import org.gvsig.raster.swing.listener.PanelChangeListener;
34
import org.gvsig.raster.tools.algorithm.swing.impl.bean.combotext.ComboTextImpl;
35
import org.gvsig.raster.tools.algorithm.swing.impl.bean.inputlayer.InputLayerImpl;
36

    
37
/**
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class OutputMaskThresholdImpl extends JPanel implements ActionListener {
41
        private static final long   serialVersionUID    = 1L;
42
        private ComboTextImpl       satisfyCombo        = null;
43
        private InputLayerImpl      layerSelection      = null;
44
        
45
        public OutputMaskThresholdImpl() {
46
                init();
47
        }
48
        
49
        private void init() {        
50
                this.setLayout(new GridBagLayout());
51
                setBorder(BorderFactory.createTitledBorder(Messages.getText("output")));
52
                GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
53
                gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
54
                gridBagConstraints1.weightx = 1;
55
                gridBagConstraints1.insets = new java.awt.Insets(0, 0, 4, 0);
56
                
57
                gridBagConstraints1.gridx = 0;
58
                gridBagConstraints1.gridy = 0;
59
                this.add(getMethodOutput(), gridBagConstraints1);
60
                
61
                gridBagConstraints1.gridx = 0;
62
                gridBagConstraints1.gridy = 1;
63
                this.add(getLayerSelection(), gridBagConstraints1);
64
                
65
                gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
66
                gridBagConstraints1.weightx = 1;
67
                gridBagConstraints1.weighty = 1;
68
                gridBagConstraints1.gridx = 0;
69
                gridBagConstraints1.gridy = 2;
70
                this.add(new JPanel(), gridBagConstraints1);
71
        }
72

    
73
        public ComboTextImpl getMethodOutput() {
74
                if(satisfyCombo == null){
75
                        satisfyCombo = new ComboTextImpl(
76
                                        new String[]{Messages.getText("method_output"), ""}, false, true);
77
                        satisfyCombo.getTextField().setEnabled(false);
78
                        satisfyCombo.getCombo().addActionListener(this);
79
                }
80
                return satisfyCombo;
81
        }
82

    
83
        public InputLayerImpl getLayerSelection() {
84
                if(layerSelection == null) {
85
                        layerSelection = new InputLayerImpl(null, false, true);
86
                        layerSelection.setEnabled(false);
87
                }
88
                return layerSelection;
89
        }
90
        
91
        public void addPanelChangeEvent(PanelChangeListener listener) {
92
                getLayerSelection().addPanelChangeEvent(listener);
93
                getMethodOutput().addPanelChangeEvent(listener);
94
        }
95

    
96
        public void actionPerformed(ActionEvent e) {
97
                if(e.getSource() == getMethodOutput().getCombo()) {
98
                        if(getMethodOutput().getCombo().getSelectedIndex() == 1) {
99
                                getMethodOutput().getTextField().setEnabled(true);
100
                        } else {
101
                                getMethodOutput().getTextField().setEnabled(false);
102
                        }
103
                }
104
        }
105
}