svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / vectorizacion / filter / ui / GrayConversionPanel.java @ 24004
History | View | Annotate | Download (5.98 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.vectorizacion.filter.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
import java.awt.Insets; |
25 |
import java.util.Observable; |
26 |
import java.util.Observer; |
27 |
|
28 |
import javax.swing.BorderFactory; |
29 |
import javax.swing.JLabel; |
30 |
import javax.swing.JPanel; |
31 |
|
32 |
import org.gvsig.raster.beans.previewbase.IUserPanelInterface; |
33 |
import org.gvsig.raster.filter.grayscale.GrayScaleFilter; |
34 |
import org.gvsig.raster.util.BasePanel; |
35 |
import org.gvsig.raster.util.RasterToolsUtil; |
36 |
import org.gvsig.rastertools.vectorizacion.filter.GrayConversionData; |
37 |
|
38 |
import com.iver.utiles.swing.JComboBox; |
39 |
|
40 |
/**
|
41 |
* Panel para la conversi?n a escala de grises.
|
42 |
*
|
43 |
* 09/06/2008
|
44 |
* @author Nacho Brodin nachobrodin@gmail.com
|
45 |
*/
|
46 |
public class GrayConversionPanel extends BasePanel implements IUserPanelInterface, Observer { |
47 |
private static final long serialVersionUID = -1; |
48 |
|
49 |
private NoisePanel noisePanel = null; |
50 |
//private HighPassPanel highPassPanel = null;
|
51 |
private PosterizationPanel posterizationPanel = null; |
52 |
private ModePanel modePanel = null; |
53 |
|
54 |
private JComboBox comboBands = null; |
55 |
private JPanel levelsPanel = null; |
56 |
|
57 |
/**
|
58 |
*Inicializa componentes gr?ficos y traduce
|
59 |
*/
|
60 |
public GrayConversionPanel() {
|
61 |
init(); |
62 |
translate(); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Inicializa los componentes gr?ficos
|
67 |
*/
|
68 |
protected void init() { |
69 |
setBorder(BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "grayescaleconversion"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
70 |
setLayout(new GridBagLayout()); |
71 |
GridBagConstraints gbc = new GridBagConstraints(); |
72 |
gbc.weightx = 1;
|
73 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
74 |
gbc.insets = new Insets(0, 2, 2, 2); |
75 |
|
76 |
gbc.gridy = 0;
|
77 |
add(getLevelPanel(), gbc); |
78 |
|
79 |
gbc.fill = GridBagConstraints.BOTH;
|
80 |
gbc.weighty = 1;
|
81 |
gbc.insets = new Insets(0, 0, 0, 0); |
82 |
gbc.gridy = 1;
|
83 |
add(getPosterizationPanel(), gbc); |
84 |
|
85 |
/*gbc.gridy = 2;
|
86 |
add(getHighPassPanel(), gbc);*/
|
87 |
|
88 |
gbc.gridy = 3;
|
89 |
add(getModePanel(), gbc); |
90 |
|
91 |
gbc.gridy = 4;
|
92 |
add(getNoisePanel(), gbc); |
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see org.gvsig.raster.util.BasePanel#translate()
|
98 |
*/
|
99 |
protected void translate() { |
100 |
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* Obtiene el panel con los niveles
|
105 |
* @return
|
106 |
*/
|
107 |
public JPanel getLevelPanel() { |
108 |
if(levelsPanel == null) { |
109 |
levelsPanel = new JPanel(); |
110 |
levelsPanel.setLayout(new BorderLayout()); |
111 |
levelsPanel.add(new JLabel(RasterToolsUtil.getText(this, "bands")), BorderLayout.WEST); |
112 |
levelsPanel.add(getComboBands(), BorderLayout.CENTER);
|
113 |
} |
114 |
return levelsPanel;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Obtiene el panel con el panel de posterizaci?n
|
119 |
* @return PosterizationPanel
|
120 |
*/
|
121 |
public PosterizationPanel getPosterizationPanel() {
|
122 |
if(posterizationPanel == null) { |
123 |
posterizationPanel = new PosterizationPanel();
|
124 |
} |
125 |
return posterizationPanel;
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* Obtiene el panel con el fitro de paso alto
|
130 |
* @return HighPassPanel
|
131 |
*/
|
132 |
/*public HighPassPanel getHighPassPanel() {
|
133 |
if(highPassPanel == null) {
|
134 |
highPassPanel = new HighPassPanel();
|
135 |
}
|
136 |
return highPassPanel;
|
137 |
}*/
|
138 |
|
139 |
/**
|
140 |
* Obtiene el panel con el fitro de moda
|
141 |
* @return HighPassPanel
|
142 |
*/
|
143 |
public ModePanel getModePanel() {
|
144 |
if(modePanel == null) { |
145 |
modePanel = new ModePanel();
|
146 |
} |
147 |
return modePanel;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* Obtiene el panel con el fitro de ruido
|
152 |
* @return HighPassPanel
|
153 |
*/
|
154 |
public NoisePanel getNoisePanel() {
|
155 |
if(noisePanel == null) { |
156 |
noisePanel = new NoisePanel();
|
157 |
} |
158 |
return noisePanel;
|
159 |
} |
160 |
|
161 |
/**
|
162 |
* Obtiene el combo con los niveles
|
163 |
* @return
|
164 |
*/
|
165 |
public JComboBox getComboBands() { |
166 |
if(comboBands == null) { |
167 |
comboBands = new JComboBox(); |
168 |
} |
169 |
return comboBands;
|
170 |
} |
171 |
|
172 |
/*
|
173 |
* (non-Javadoc)
|
174 |
* @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getTitle()
|
175 |
*/
|
176 |
public String getTitle() { |
177 |
return getText(this, "grayscaleconversion"); |
178 |
} |
179 |
|
180 |
/*
|
181 |
* (non-Javadoc)
|
182 |
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
183 |
*/
|
184 |
public void update(Observable o, Object arg) { |
185 |
if(!(o instanceof GrayConversionData)) |
186 |
return;
|
187 |
GrayConversionData data = (GrayConversionData)o; |
188 |
|
189 |
setEnableValueChangedEvent(false);
|
190 |
|
191 |
String[] bands = data.getBands(); |
192 |
getComboBands().removeAllItems(); |
193 |
for (int i = 0; i < bands.length; i++) |
194 |
getComboBands().addItem(bands[i]); |
195 |
|
196 |
switch (data.getBandType()) {
|
197 |
case GrayScaleFilter.R:
|
198 |
case GrayScaleFilter.GRAY: getComboBands().setSelectedIndex(0); |
199 |
break;
|
200 |
case GrayScaleFilter.G: getComboBands().setSelectedIndex(1); |
201 |
break;
|
202 |
case GrayScaleFilter.B: getComboBands().setSelectedIndex(2); |
203 |
break;
|
204 |
case GrayScaleFilter.RGB: getComboBands().setSelectedIndex(3); |
205 |
break;
|
206 |
} |
207 |
|
208 |
getPosterizationPanel().getLevels().setValue(data.getPosterizationLevels() + "");
|
209 |
getNoisePanel().getThreshold().setValue(data.getNoiseThreshold()); |
210 |
getModePanel().getThreshold().setValue(data.getModeThreshold()); |
211 |
|
212 |
setEnableValueChangedEvent(true);
|
213 |
} |
214 |
|
215 |
/*
|
216 |
* (non-Javadoc)
|
217 |
* @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getPanel()
|
218 |
*/
|
219 |
public JPanel getPanel() { |
220 |
return this; |
221 |
} |
222 |
} |