root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / SelectorsPanel.java @ 20947
History | View | Annotate | Download (7.71 KB)
1 | 19173 | nbrodin | /* 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 | 20057 | bsanchez | import java.awt.event.ActionListener; |
25 | 19205 | nbrodin | import java.util.ArrayList; |
26 | 19173 | nbrodin | |
27 | 19516 | bsanchez | import javax.swing.BorderFactory; |
28 | 19205 | nbrodin | import javax.swing.JLabel; |
29 | 19173 | nbrodin | import javax.swing.JPanel; |
30 | 19516 | bsanchez | import javax.swing.border.TitledBorder; |
31 | 19173 | nbrodin | |
32 | 19205 | nbrodin | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
33 | import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
||
34 | 20947 | nbrodin | import org.gvsig.raster.util.RasterToolsUtil; |
35 | 19205 | nbrodin | |
36 | 19173 | nbrodin | 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 | 19516 | bsanchez | 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 | 19173 | nbrodin | |
51 | /**
|
||
52 | * Crea una instancia del panel GraphicsPanel
|
||
53 | */
|
||
54 | 19205 | nbrodin | public SelectorsPanel(FLyrRasterSE lyr, ArrayList list) { |
55 | init(lyr, list); |
||
56 | 19173 | nbrodin | } |
57 | |||
58 | /**
|
||
59 | * Inicializaci?n de los controles gr?ficos.
|
||
60 | */
|
||
61 | 19205 | nbrodin | private void init(FLyrRasterSE lyr, ArrayList list) { |
62 | 19516 | bsanchez | GridBagConstraints gridBagConstraints = null; |
63 | |||
64 | setBorder(BorderFactory.createTitledBorder(null, null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
||
65 | |||
66 | 19173 | nbrodin | setLayout(new GridBagLayout()); |
67 | 19205 | nbrodin | |
68 | 19516 | bsanchez | 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 | 20947 | nbrodin | add(new JLabel(RasterToolsUtil.getText(this, "operation")), gridBagConstraints); |
75 | 19516 | bsanchez | |
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 | 19205 | nbrodin | |
83 | 19516 | bsanchez | 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 | 20947 | nbrodin | add(new JLabel(RasterToolsUtil.getText(this, "band")), gridBagConstraints); |
90 | 19516 | bsanchez | |
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 | 20947 | nbrodin | add(new JLabel(RasterToolsUtil.getText(this, "drawing_type")), gridBagConstraints); |
105 | 19516 | bsanchez | |
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 | 20947 | nbrodin | add(new JLabel(RasterToolsUtil.getText(this, "histogram_type")), gridBagConstraints); |
120 | 19516 | bsanchez | |
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 | 20947 | nbrodin | //add(getSourcesMatchingPanel(list), gridBagConstraints);
|
137 | 19173 | nbrodin | } |
138 | 19205 | nbrodin | |
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 | 19516 | bsanchez | if (sourcesMatchingPanel == null) { |
146 | 19205 | nbrodin | sourcesMatchingPanel = new JComboBox(); |
147 | 19516 | bsanchez | for (int i = 0; i < list.size(); i++) |
148 | sourcesMatchingPanel.addItem(((FLyrRasterSE) list.get(i)).getName()); |
||
149 | 19205 | nbrodin | } |
150 | return sourcesMatchingPanel;
|
||
151 | } |
||
152 | |||
153 | /**
|
||
154 | 19173 | nbrodin | * Obtiene el tipo de histograma
|
155 | * @return JComboBox
|
||
156 | */
|
||
157 | 19205 | nbrodin | public JComboBox getHistogramType() { |
158 | 19516 | bsanchez | if (histogramType == null) { |
159 | 19173 | nbrodin | histogramType = new JComboBox(); |
160 | 19205 | nbrodin | histogramType.addItem("Standard");
|
161 | histogramType.addItem("Cumulative");
|
||
162 | 19516 | bsanchez | histogramType.addItem("Logarithmic");
|
163 | histogramType.addItem("Cumulative Logarithmic");
|
||
164 | 19205 | nbrodin | } |
165 | 19173 | nbrodin | return histogramType;
|
166 | } |
||
167 | 19205 | nbrodin | |
168 | /**
|
||
169 | 19173 | nbrodin | * Obtiene el tipo de dibujado de histograma (lineas, barras, ...)
|
170 | * @return JComboBox
|
||
171 | */
|
||
172 | 19205 | nbrodin | public JComboBox getDrawType() { |
173 | 19516 | bsanchez | if (drawType == null) { |
174 | 19173 | nbrodin | drawType = new JComboBox(); |
175 | 19205 | nbrodin | drawType.addItem("Line");
|
176 | drawType.addItem("Fill");
|
||
177 | } |
||
178 | 19173 | nbrodin | return drawType;
|
179 | } |
||
180 | 19205 | nbrodin | |
181 | /**
|
||
182 | 19173 | nbrodin | * Obtiene la banda que representa el histograma
|
183 | * @return JComboBox
|
||
184 | */
|
||
185 | 19205 | nbrodin | public JComboBox getBand(FLyrRasterSE lyr) { |
186 | 19516 | bsanchez | if (band == null) { |
187 | 19173 | nbrodin | band = new JComboBox(); |
188 | 19516 | bsanchez | if (lyr.getBandCount() == 1) |
189 | 19205 | nbrodin | band.addItem(DatasetColorInterpretation.GRAY_BAND); |
190 | 19362 | nbrodin | else {
|
191 | 19205 | nbrodin | band.addItem(DatasetColorInterpretation.RED_BAND); |
192 | band.addItem(DatasetColorInterpretation.GREEN_BAND); |
||
193 | band.addItem(DatasetColorInterpretation.BLUE_BAND); |
||
194 | 19362 | nbrodin | } |
195 | 19205 | nbrodin | } |
196 | 19173 | nbrodin | return band;
|
197 | } |
||
198 | |||
199 | /**
|
||
200 | * Obtiene el tipo de funci?n a aplicar (ecualizaci?n, realce lineal, ...)
|
||
201 | * @return JComboBox
|
||
202 | */
|
||
203 | 19205 | nbrodin | public JComboBox getEnhancedType() { |
204 | 19516 | bsanchez | if (enhancedType == null) { |
205 | 19173 | nbrodin | enhancedType = new JComboBox(); |
206 | 19205 | nbrodin | enhancedType.addItem("Lineal");
|
207 | 19957 | bsanchez | enhancedType.addItem("Square-root");
|
208 | 19205 | nbrodin | enhancedType.addItem("Logaritmic");
|
209 | enhancedType.addItem("Exponential");
|
||
210 | enhancedType.addItem("Level-slice");
|
||
211 | 19957 | bsanchez | // enhancedType.addItem("Gaussian");
|
212 | // enhancedType.addItem("Equalization");
|
||
213 | 19205 | nbrodin | } |
214 | 19173 | nbrodin | return enhancedType;
|
215 | } |
||
216 | 20057 | bsanchez | |
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 | 19516 | bsanchez | } |