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 / OperationMaskThresholdImpl.java @ 2480
History | View | Annotate | Download (4.82 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.ButtonGroup; |
31 |
import javax.swing.JPanel; |
32 |
import javax.swing.JRadioButton; |
33 |
|
34 |
import org.gvsig.i18n.Messages; |
35 |
import org.gvsig.raster.swing.listener.PanelChangeEvent; |
36 |
import org.gvsig.raster.swing.listener.PanelChangeListener; |
37 |
import org.gvsig.raster.tools.algorithm.swing.impl.bean.combotext.ComboTextImpl; |
38 |
import org.gvsig.raster.tools.algorithm.swing.impl.bean.inputlayer.InputLayerImpl; |
39 |
|
40 |
/**
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class OperationMaskThresholdImpl extends JPanel implements ActionListener { |
44 |
private static final long serialVersionUID = 1L; |
45 |
private JRadioButton valueRadio = null; |
46 |
private JRadioButton layerRadio = null; |
47 |
private InputLayerImpl layerSelection = null; |
48 |
private ComboTextImpl comboText = null; |
49 |
private PanelChangeListener listener = null; |
50 |
|
51 |
public OperationMaskThresholdImpl() {
|
52 |
init(); |
53 |
} |
54 |
|
55 |
private void init() { |
56 |
ButtonGroup group = new ButtonGroup(); |
57 |
group.add(getValueRadio()); |
58 |
group.add(getLayerRadio()); |
59 |
|
60 |
this.setLayout(new GridBagLayout()); |
61 |
setBorder(BorderFactory.createTitledBorder(Messages.getText("operation"))); |
62 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
63 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
64 |
gridBagConstraints1.weightx = 1;
|
65 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0); |
66 |
gridBagConstraints1.gridwidth = 2;
|
67 |
|
68 |
gridBagConstraints1.gridx = 0;
|
69 |
gridBagConstraints1.gridy = 0;
|
70 |
this.add(getValueRadio(), gridBagConstraints1);
|
71 |
|
72 |
gridBagConstraints1.gridx = 0;
|
73 |
gridBagConstraints1.gridy = 1;
|
74 |
this.add(getLayerRadio(), gridBagConstraints1);
|
75 |
|
76 |
gridBagConstraints1.gridwidth = 1;
|
77 |
gridBagConstraints1.gridx = 0;
|
78 |
gridBagConstraints1.gridy = 2;
|
79 |
this.add(getComboText(), gridBagConstraints1);
|
80 |
|
81 |
gridBagConstraints1.gridwidth = 2;
|
82 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
83 |
gridBagConstraints1.weightx = 1;
|
84 |
gridBagConstraints1.gridx = 0;
|
85 |
gridBagConstraints1.gridy = 3;
|
86 |
this.add(getLayerSelection(), gridBagConstraints1);
|
87 |
|
88 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
89 |
gridBagConstraints1.weightx = 1;
|
90 |
gridBagConstraints1.weighty = 1;
|
91 |
gridBagConstraints1.gridx = 0;
|
92 |
gridBagConstraints1.gridy = 4;
|
93 |
this.add(new JPanel(), gridBagConstraints1); |
94 |
} |
95 |
|
96 |
public JRadioButton getValueRadio() { |
97 |
if(valueRadio == null) { |
98 |
valueRadio = new JRadioButton(Messages.getText("value")); |
99 |
valueRadio.setSelected(true);
|
100 |
valueRadio.addActionListener(this);
|
101 |
} |
102 |
return valueRadio;
|
103 |
} |
104 |
|
105 |
public JRadioButton getLayerRadio() { |
106 |
if(layerRadio == null) { |
107 |
layerRadio = new JRadioButton(Messages.getText("layer")); |
108 |
layerRadio.addActionListener(this);
|
109 |
} |
110 |
return layerRadio;
|
111 |
} |
112 |
|
113 |
public InputLayerImpl getLayerSelection() {
|
114 |
if(layerSelection == null) { |
115 |
layerSelection = new InputLayerImpl(null, false, true); |
116 |
layerSelection.setEnabled(false);
|
117 |
} |
118 |
return layerSelection;
|
119 |
} |
120 |
|
121 |
public ComboTextImpl getComboText() {
|
122 |
if(comboText == null) { |
123 |
comboText = new ComboTextImpl(null, false, false); |
124 |
comboText.getTextField().setEnabled(true);
|
125 |
} |
126 |
return comboText;
|
127 |
} |
128 |
|
129 |
public void addPanelChangeEvent(PanelChangeListener listener) { |
130 |
this.listener = listener;
|
131 |
getLayerSelection().addPanelChangeEvent(listener); |
132 |
getComboText().addPanelChangeEvent(listener); |
133 |
} |
134 |
|
135 |
public void actionPerformed(ActionEvent e) { |
136 |
if(listener != null) |
137 |
listener.panelHasChanged(new PanelChangeEvent(e));
|
138 |
|
139 |
if(e.getSource() == getValueRadio()) {
|
140 |
getLayerSelection().setEnabled(false);
|
141 |
getComboText().getTextField().setEnabled(true);
|
142 |
} |
143 |
if(e.getSource() == getLayerRadio()) {
|
144 |
getLayerSelection().setEnabled(true);
|
145 |
getComboText().getTextField().setEnabled(false);
|
146 |
} |
147 |
} |
148 |
|
149 |
} |