root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / ui / SelectorsPanel.java @ 19516
History | View | Annotate | Download (6.93 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.util.ArrayList; |
25 |
|
26 |
import javax.swing.BorderFactory; |
27 |
import javax.swing.JLabel; |
28 |
import javax.swing.JPanel; |
29 |
import javax.swing.border.TitledBorder; |
30 |
|
31 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
32 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
33 |
|
34 |
import com.iver.utiles.swing.JComboBox; |
35 |
/**
|
36 |
* Panel con las selecci?n de opciones.
|
37 |
*
|
38 |
* 20/02/2008
|
39 |
* @author Nacho Brodin nachobrodin@gmail.com
|
40 |
*/
|
41 |
public class SelectorsPanel extends JPanel { |
42 |
private static final long serialVersionUID = 3453973982901626644L; |
43 |
private JComboBox enhancedType = null; |
44 |
private JComboBox histogramType = null; |
45 |
private JComboBox drawType = null; |
46 |
private JComboBox band = null; |
47 |
private JComboBox sourcesMatchingPanel = null; |
48 |
|
49 |
/**
|
50 |
* Crea una instancia del panel GraphicsPanel
|
51 |
*/
|
52 |
public SelectorsPanel(FLyrRasterSE lyr, ArrayList list) { |
53 |
init(lyr, list); |
54 |
} |
55 |
|
56 |
/**
|
57 |
* Inicializaci?n de los controles gr?ficos.
|
58 |
*/
|
59 |
private void init(FLyrRasterSE lyr, ArrayList list) { |
60 |
GridBagConstraints gridBagConstraints = null; |
61 |
|
62 |
setBorder(BorderFactory.createTitledBorder(null, null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
63 |
|
64 |
setLayout(new GridBagLayout()); |
65 |
|
66 |
gridBagConstraints = new GridBagConstraints(); |
67 |
gridBagConstraints.gridx = 0;
|
68 |
gridBagConstraints.gridy = 0;
|
69 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
70 |
gridBagConstraints.weightx = 1.0;
|
71 |
gridBagConstraints.insets = new Insets(5, 5, 2, 2); |
72 |
add(new JLabel("operation"), gridBagConstraints); |
73 |
|
74 |
gridBagConstraints = new GridBagConstraints(); |
75 |
gridBagConstraints.gridx = 1;
|
76 |
gridBagConstraints.gridy = 0;
|
77 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
78 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
79 |
add(getEnhancedType(), gridBagConstraints); |
80 |
|
81 |
gridBagConstraints = new GridBagConstraints(); |
82 |
gridBagConstraints.gridx = 0;
|
83 |
gridBagConstraints.gridy = 1;
|
84 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
85 |
gridBagConstraints.weightx = 1.0;
|
86 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
87 |
add(new JLabel("band"), gridBagConstraints); |
88 |
|
89 |
gridBagConstraints = new GridBagConstraints(); |
90 |
gridBagConstraints.gridx = 1;
|
91 |
gridBagConstraints.gridy = 1;
|
92 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
93 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
94 |
add(getBand(lyr), gridBagConstraints); |
95 |
|
96 |
gridBagConstraints = new GridBagConstraints(); |
97 |
gridBagConstraints.gridx = 2;
|
98 |
gridBagConstraints.gridy = 0;
|
99 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
100 |
gridBagConstraints.weightx = 1.0;
|
101 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
102 |
add(new JLabel("drawing_type"), gridBagConstraints); |
103 |
|
104 |
gridBagConstraints = new GridBagConstraints(); |
105 |
gridBagConstraints.gridx = 3;
|
106 |
gridBagConstraints.gridy = 0;
|
107 |
gridBagConstraints.insets = new Insets(5, 2, 2, 5); |
108 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
109 |
add(getDrawType(), gridBagConstraints); |
110 |
|
111 |
gridBagConstraints = new GridBagConstraints(); |
112 |
gridBagConstraints.gridx = 2;
|
113 |
gridBagConstraints.gridy = 1;
|
114 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
115 |
gridBagConstraints.weightx = 1.0;
|
116 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
117 |
add(new JLabel("histogram_type"), gridBagConstraints); |
118 |
|
119 |
gridBagConstraints = new GridBagConstraints(); |
120 |
gridBagConstraints.gridx = 3;
|
121 |
gridBagConstraints.gridy = 1;
|
122 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
123 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
124 |
add(getHistogramType(), gridBagConstraints); |
125 |
|
126 |
gridBagConstraints = new GridBagConstraints(); |
127 |
gridBagConstraints.gridx = 0;
|
128 |
gridBagConstraints.gridy = 2;
|
129 |
gridBagConstraints.gridwidth = 4;
|
130 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
131 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
132 |
gridBagConstraints.weighty = 1.0;
|
133 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
134 |
add(getSourcesMatchingPanel(list), gridBagConstraints); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* Obtiene la lista con las capas cargadas en el TOC para la selecci?n de la
|
139 |
* que necesitemos en la funcionalidad de histogram matching
|
140 |
* @return JPanel
|
141 |
*/
|
142 |
public JComboBox getSourcesMatchingPanel(ArrayList list) { |
143 |
if (sourcesMatchingPanel == null) { |
144 |
sourcesMatchingPanel = new JComboBox(); |
145 |
for (int i = 0; i < list.size(); i++) |
146 |
sourcesMatchingPanel.addItem(((FLyrRasterSE) list.get(i)).getName()); |
147 |
} |
148 |
return sourcesMatchingPanel;
|
149 |
} |
150 |
|
151 |
/**
|
152 |
* Obtiene el tipo de histograma
|
153 |
* @return JComboBox
|
154 |
*/
|
155 |
public JComboBox getHistogramType() { |
156 |
if (histogramType == null) { |
157 |
histogramType = new JComboBox(); |
158 |
histogramType.addItem("Standard");
|
159 |
histogramType.addItem("Cumulative");
|
160 |
histogramType.addItem("Logarithmic");
|
161 |
histogramType.addItem("Cumulative Logarithmic");
|
162 |
} |
163 |
return histogramType;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* Obtiene el tipo de dibujado de histograma (lineas, barras, ...)
|
168 |
* @return JComboBox
|
169 |
*/
|
170 |
public JComboBox getDrawType() { |
171 |
if (drawType == null) { |
172 |
drawType = new JComboBox(); |
173 |
drawType.addItem("Line");
|
174 |
drawType.addItem("Fill");
|
175 |
} |
176 |
return drawType;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* Obtiene la banda que representa el histograma
|
181 |
* @return JComboBox
|
182 |
*/
|
183 |
public JComboBox getBand(FLyrRasterSE lyr) { |
184 |
if (band == null) { |
185 |
band = new JComboBox(); |
186 |
if (lyr.getBandCount() == 1) |
187 |
band.addItem(DatasetColorInterpretation.GRAY_BAND); |
188 |
else {
|
189 |
band.addItem(DatasetColorInterpretation.RED_BAND); |
190 |
band.addItem(DatasetColorInterpretation.GREEN_BAND); |
191 |
band.addItem(DatasetColorInterpretation.BLUE_BAND); |
192 |
} |
193 |
} |
194 |
return band;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Obtiene el tipo de funci?n a aplicar (ecualizaci?n, realce lineal, ...)
|
199 |
* @return JComboBox
|
200 |
*/
|
201 |
public JComboBox getEnhancedType() { |
202 |
if (enhancedType == null) { |
203 |
enhancedType = new JComboBox(); |
204 |
enhancedType.addItem("Lineal");
|
205 |
enhancedType.addItem("Gaussian");
|
206 |
enhancedType.addItem("Logaritmic");
|
207 |
enhancedType.addItem("Exponential");
|
208 |
enhancedType.addItem("Equalization");
|
209 |
enhancedType.addItem("Square-root");
|
210 |
enhancedType.addItem("Level-slice");
|
211 |
} |
212 |
return enhancedType;
|
213 |
} |
214 |
} |