root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / SelectorsPanel.java @ 20947
History | View | Annotate | Download (7.71 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.enhanced.ui; |
20 |
|
21 |
import java.awt.GridBagConstraints; |
22 |
import java.awt.GridBagLayout; |
23 |
import java.awt.Insets; |
24 |
import java.awt.event.ActionListener; |
25 |
import java.util.ArrayList; |
26 |
|
27 |
import javax.swing.BorderFactory; |
28 |
import javax.swing.JLabel; |
29 |
import javax.swing.JPanel; |
30 |
import javax.swing.border.TitledBorder; |
31 |
|
32 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
33 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
34 |
import org.gvsig.raster.util.RasterToolsUtil; |
35 |
|
36 |
import com.iver.utiles.swing.JComboBox; |
37 |
/**
|
38 |
* Panel con las selecci?n de opciones.
|
39 |
*
|
40 |
* 20/02/2008
|
41 |
* @author Nacho Brodin nachobrodin@gmail.com
|
42 |
*/
|
43 |
public class SelectorsPanel extends JPanel { |
44 |
private static final long serialVersionUID = 3453973982901626644L; |
45 |
private JComboBox enhancedType = null; |
46 |
private JComboBox histogramType = null; |
47 |
private JComboBox drawType = null; |
48 |
private JComboBox band = null; |
49 |
private JComboBox sourcesMatchingPanel = null; |
50 |
|
51 |
/**
|
52 |
* Crea una instancia del panel GraphicsPanel
|
53 |
*/
|
54 |
public SelectorsPanel(FLyrRasterSE lyr, ArrayList list) { |
55 |
init(lyr, list); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* Inicializaci?n de los controles gr?ficos.
|
60 |
*/
|
61 |
private void init(FLyrRasterSE lyr, ArrayList list) { |
62 |
GridBagConstraints gridBagConstraints = null; |
63 |
|
64 |
setBorder(BorderFactory.createTitledBorder(null, null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
65 |
|
66 |
setLayout(new GridBagLayout()); |
67 |
|
68 |
gridBagConstraints = new GridBagConstraints(); |
69 |
gridBagConstraints.gridx = 0;
|
70 |
gridBagConstraints.gridy = 0;
|
71 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
72 |
gridBagConstraints.weightx = 1.0;
|
73 |
gridBagConstraints.insets = new Insets(5, 5, 2, 2); |
74 |
add(new JLabel(RasterToolsUtil.getText(this, "operation")), gridBagConstraints); |
75 |
|
76 |
gridBagConstraints = new GridBagConstraints(); |
77 |
gridBagConstraints.gridx = 1;
|
78 |
gridBagConstraints.gridy = 0;
|
79 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
80 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
81 |
add(getEnhancedType(), gridBagConstraints); |
82 |
|
83 |
gridBagConstraints = new GridBagConstraints(); |
84 |
gridBagConstraints.gridx = 0;
|
85 |
gridBagConstraints.gridy = 1;
|
86 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
87 |
gridBagConstraints.weightx = 1.0;
|
88 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
89 |
add(new JLabel(RasterToolsUtil.getText(this, "band")), gridBagConstraints); |
90 |
|
91 |
gridBagConstraints = new GridBagConstraints(); |
92 |
gridBagConstraints.gridx = 1;
|
93 |
gridBagConstraints.gridy = 1;
|
94 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
95 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
96 |
add(getBand(lyr), gridBagConstraints); |
97 |
|
98 |
gridBagConstraints = new GridBagConstraints(); |
99 |
gridBagConstraints.gridx = 2;
|
100 |
gridBagConstraints.gridy = 0;
|
101 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
102 |
gridBagConstraints.weightx = 1.0;
|
103 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
104 |
add(new JLabel(RasterToolsUtil.getText(this, "drawing_type")), gridBagConstraints); |
105 |
|
106 |
gridBagConstraints = new GridBagConstraints(); |
107 |
gridBagConstraints.gridx = 3;
|
108 |
gridBagConstraints.gridy = 0;
|
109 |
gridBagConstraints.insets = new Insets(5, 2, 2, 5); |
110 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
111 |
add(getDrawType(), gridBagConstraints); |
112 |
|
113 |
gridBagConstraints = new GridBagConstraints(); |
114 |
gridBagConstraints.gridx = 2;
|
115 |
gridBagConstraints.gridy = 1;
|
116 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
117 |
gridBagConstraints.weightx = 1.0;
|
118 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
119 |
add(new JLabel(RasterToolsUtil.getText(this, "histogram_type")), gridBagConstraints); |
120 |
|
121 |
gridBagConstraints = new GridBagConstraints(); |
122 |
gridBagConstraints.gridx = 3;
|
123 |
gridBagConstraints.gridy = 1;
|
124 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
125 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
126 |
add(getHistogramType(), gridBagConstraints); |
127 |
|
128 |
gridBagConstraints = new GridBagConstraints(); |
129 |
gridBagConstraints.gridx = 0;
|
130 |
gridBagConstraints.gridy = 2;
|
131 |
gridBagConstraints.gridwidth = 4;
|
132 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
133 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
134 |
gridBagConstraints.weighty = 1.0;
|
135 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
136 |
//add(getSourcesMatchingPanel(list), gridBagConstraints);
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* Obtiene la lista con las capas cargadas en el TOC para la selecci?n de la
|
141 |
* que necesitemos en la funcionalidad de histogram matching
|
142 |
* @return JPanel
|
143 |
*/
|
144 |
public JComboBox getSourcesMatchingPanel(ArrayList list) { |
145 |
if (sourcesMatchingPanel == null) { |
146 |
sourcesMatchingPanel = new JComboBox(); |
147 |
for (int i = 0; i < list.size(); i++) |
148 |
sourcesMatchingPanel.addItem(((FLyrRasterSE) list.get(i)).getName()); |
149 |
} |
150 |
return sourcesMatchingPanel;
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* Obtiene el tipo de histograma
|
155 |
* @return JComboBox
|
156 |
*/
|
157 |
public JComboBox getHistogramType() { |
158 |
if (histogramType == null) { |
159 |
histogramType = new JComboBox(); |
160 |
histogramType.addItem("Standard");
|
161 |
histogramType.addItem("Cumulative");
|
162 |
histogramType.addItem("Logarithmic");
|
163 |
histogramType.addItem("Cumulative Logarithmic");
|
164 |
} |
165 |
return histogramType;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* Obtiene el tipo de dibujado de histograma (lineas, barras, ...)
|
170 |
* @return JComboBox
|
171 |
*/
|
172 |
public JComboBox getDrawType() { |
173 |
if (drawType == null) { |
174 |
drawType = new JComboBox(); |
175 |
drawType.addItem("Line");
|
176 |
drawType.addItem("Fill");
|
177 |
} |
178 |
return drawType;
|
179 |
} |
180 |
|
181 |
/**
|
182 |
* Obtiene la banda que representa el histograma
|
183 |
* @return JComboBox
|
184 |
*/
|
185 |
public JComboBox getBand(FLyrRasterSE lyr) { |
186 |
if (band == null) { |
187 |
band = new JComboBox(); |
188 |
if (lyr.getBandCount() == 1) |
189 |
band.addItem(DatasetColorInterpretation.GRAY_BAND); |
190 |
else {
|
191 |
band.addItem(DatasetColorInterpretation.RED_BAND); |
192 |
band.addItem(DatasetColorInterpretation.GREEN_BAND); |
193 |
band.addItem(DatasetColorInterpretation.BLUE_BAND); |
194 |
} |
195 |
} |
196 |
return band;
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* Obtiene el tipo de funci?n a aplicar (ecualizaci?n, realce lineal, ...)
|
201 |
* @return JComboBox
|
202 |
*/
|
203 |
public JComboBox getEnhancedType() { |
204 |
if (enhancedType == null) { |
205 |
enhancedType = new JComboBox(); |
206 |
enhancedType.addItem("Lineal");
|
207 |
enhancedType.addItem("Square-root");
|
208 |
enhancedType.addItem("Logaritmic");
|
209 |
enhancedType.addItem("Exponential");
|
210 |
enhancedType.addItem("Level-slice");
|
211 |
// enhancedType.addItem("Gaussian");
|
212 |
// enhancedType.addItem("Equalization");
|
213 |
} |
214 |
return enhancedType;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* Selecciona un item del combo EnhancedType sin lanzar un evento
|
219 |
* @param type
|
220 |
*/
|
221 |
public void setSelectedEnhancedType(String type) { |
222 |
if (getEnhancedType().getSelectedItem() != type) {
|
223 |
ActionListener[] copyActionListeners = getEnhancedType().getActionListeners(); |
224 |
for (int i = 0; i < copyActionListeners.length; i++) |
225 |
getEnhancedType().removeActionListener(copyActionListeners[i]); |
226 |
|
227 |
getEnhancedType().setSelectedItem(type); |
228 |
|
229 |
for (int i = 0; i < copyActionListeners.length; i++) |
230 |
getEnhancedType().addActionListener(copyActionListeners[i]); |
231 |
} |
232 |
} |
233 |
} |