Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/FilterRasterDialogPanel.java
FilterRasterDialogPanel.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
5 | 3 |
* |
4 |
* Copyright (C) 2004-5. |
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
... | ... | |
18 | 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
19 | 19 |
* |
20 | 20 |
* For more information, contact: |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* cresques@gmail.com |
23 | 23 |
*/ |
24 | 24 |
package org.cresques.ui.raster; |
25 | 25 |
|
26 |
import org.cresques.ui.DefaultTabPanel; |
|
27 |
|
|
26 | 28 |
import java.awt.event.ActionEvent; |
27 | 29 |
import java.awt.event.ActionListener; |
28 | 30 |
import java.awt.event.FocusEvent; |
... | ... | |
31 | 33 |
import java.awt.event.KeyListener; |
32 | 34 |
import java.awt.event.MouseEvent; |
33 | 35 |
import java.awt.event.MouseListener; |
36 |
|
|
34 | 37 |
import java.io.IOException; |
35 | 38 |
|
36 | 39 |
import javax.swing.event.ChangeEvent; |
37 | 40 |
import javax.swing.event.ChangeListener; |
38 | 41 |
|
39 |
import org.cresques.ui.DefaultTabPanel; |
|
40 | 42 |
|
41 | 43 |
/** |
42 |
* Panel que contiene todos los paneles de los tabs del cuadro de dialogo
|
|
44 |
* Panel que contiene todos los paneles de los tabs del cuadro de dialogo |
|
43 | 45 |
* de bandas y transparencias |
44 |
*
|
|
46 |
* |
|
45 | 47 |
* @author Nacho Brodin <brodin_ign@gva.es> |
46 | 48 |
*/ |
47 |
public class FilterRasterDialogPanel extends DefaultTabPanel implements ActionListener, ChangeListener, MouseListener, FocusListener, KeyListener{ |
|
48 |
|
|
49 |
final private static long serialVersionUID = -3370601314380922368L; |
|
50 |
//Tama?o de panel interior. El tab de dentro es proporcional |
|
51 |
protected int sizePanelX = 450; |
|
52 |
protected int sizePanelY = 260; |
|
53 |
private RasterTransparencyPanel pTrans = null; |
|
54 |
protected BandSetupPanel pSetup = null; |
|
55 |
private EnhancedPanel pEnhan = null; |
|
56 |
private InfoPanel pInfo = null; |
|
57 |
private int[][] rangeRed = null; |
|
58 |
private int[][] rangeGreen = null; |
|
59 |
private int[][] rangeBlue = null; |
|
60 |
|
|
61 |
/** |
|
62 |
* Propiedades guardadas en una matriz Nx2 con la forma proiedad/valor |
|
63 |
*/ |
|
64 |
public Object[][] props = null; |
|
65 |
protected int nbands = 0; |
|
66 |
|
|
67 |
/** |
|
68 |
* Constructor. Inicializa los paneles y propiedades |
|
69 |
* @param props Propiedades |
|
70 |
*/ |
|
71 |
public FilterRasterDialogPanel(Object[][] props) { |
|
72 |
super(); |
|
73 |
init(props); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Constructor |
|
78 |
*/ |
|
79 |
public FilterRasterDialogPanel(){ |
|
80 |
super(); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Inicializa las propiedades |
|
85 |
* @param props Propiedades. Guardadas en una matriz Nx2 con la forma proiedad/valor |
|
86 |
*/ |
|
87 |
public void init(Object[][] props){ |
|
88 |
contentPane.setPreferredSize(new java.awt.Dimension(sizePanelX, sizePanelY)); |
|
89 |
this.tabbedPane.setPreferredSize(new java.awt.Dimension(sizePanelX, sizePanelY-5)); |
|
90 |
this.props = props; |
|
91 |
initPanels(); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* This method initializes this |
|
96 |
* |
|
97 |
* @return void |
|
98 |
*/ |
|
99 |
protected void initPanels() { |
|
49 |
public class FilterRasterDialogPanel extends DefaultTabPanel |
|
50 |
implements ActionListener, ChangeListener, MouseListener, FocusListener, |
|
51 |
KeyListener { |
|
52 |
final private static long serialVersionUID = -3370601314380922368L; |
|
100 | 53 |
|
101 |
this.setBounds(0, 0, 355, 230); |
|
102 |
pTrans = new RasterTransparencyPanel(this); |
|
103 |
pSetup = new BandSetupPanel(); |
|
104 |
pEnhan = new EnhancedPanel(this); |
|
105 |
pInfo = new InfoPanel(this); |
|
106 |
this.addTab(pInfo.nom,pInfo); |
|
107 |
this.addTab(pSetup.nom, pSetup); |
|
108 |
this.addTab(pTrans.nom, pTrans); |
|
109 |
this.addTab(pEnhan.nom, pEnhan); |
|
54 |
//Tama?o de panel interior. El tab de dentro es proporcional |
|
55 |
protected int sizePanelX = 450; |
|
56 |
protected int sizePanelY = 260; |
|
57 |
private RasterTransparencyPanel pTrans = null; |
|
58 |
protected BandSetupPanel pSetup = null; |
|
59 |
private EnhancedPanel pEnhan = null; |
|
60 |
private InfoPanel pInfo = null; |
|
61 |
private int[][] rangeRed = null; |
|
62 |
private int[][] rangeGreen = null; |
|
63 |
private int[][] rangeBlue = null; |
|
110 | 64 |
|
111 |
pTrans.getOpacityCheck().addActionListener(this); |
|
112 |
pTrans.getTransparencyCheck().addActionListener(this); |
|
113 |
pTrans.getTRojo().addActionListener(this); |
|
114 |
pTrans.getTVerde().addActionListener(this); |
|
115 |
pTrans.getTAzul().addActionListener(this); |
|
116 |
pTrans.getOpacitySlider().addChangeListener(this); |
|
117 |
pTrans.getOpacityText().addActionListener(this); |
|
118 |
pTrans.getOpacityText().addFocusListener(this); |
|
119 |
pTrans.getTRojo().addFocusListener(this); |
|
120 |
pTrans.getTVerde().addFocusListener(this); |
|
121 |
pTrans.getTAzul().addFocusListener(this); |
|
122 |
pTrans.getTRojo().addMouseListener(this); |
|
123 |
pTrans.getTVerde().addMouseListener(this); |
|
124 |
pTrans.getTAzul().addMouseListener(this); |
|
125 |
pTrans.addFocusListener(this); |
|
126 |
this.getTab().addFocusListener(this); |
|
127 |
|
|
128 |
pEnhan.getTailCheck().addActionListener(this); |
|
129 |
pEnhan.getTailSlider().addChangeListener(this); |
|
130 |
pEnhan.getSinRealceRadioButton().addMouseListener(this); |
|
131 |
pEnhan.getLinealDirectoRadioButton().addMouseListener(this); |
|
132 |
pEnhan.getTailText().addActionListener(this); |
|
133 |
pEnhan.getTailText().addFocusListener(this); |
|
134 |
|
|
135 |
//Ocultamos el bot?n de aplicar |
|
65 |
/** |
|
66 |
* Propiedades guardadas en una matriz Nx2 con la forma proiedad/valor |
|
67 |
*/ |
|
68 |
public Object[][] props = null; |
|
69 |
protected int nbands = 0; |
|
136 | 70 |
|
137 |
//this.getApplyButton().setVisible(false); |
|
71 |
/** |
|
72 |
* Constructor. Inicializa los paneles y propiedades |
|
73 |
* @param props Propiedades |
|
74 |
*/ |
|
75 |
public FilterRasterDialogPanel(Object[][] props) { |
|
76 |
super(); |
|
77 |
init(props); |
|
78 |
} |
|
138 | 79 |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Selecciona el panel indicado por index |
|
143 |
* @param index panel seleccionado |
|
144 |
*/ |
|
145 |
public void setSelectedIndex(int index){ |
|
146 |
tabbedPane.setSelectedIndex(index); |
|
147 |
} |
|
148 |
|
|
149 |
/** |
|
150 |
* Obtiene el panel que corresponde a la selecci?n de bandas |
|
151 |
* @return Panel de selecci?n de bandas |
|
152 |
*/ |
|
153 |
public BandSetupPanel getBandSetup(){ |
|
154 |
return this.pSetup; |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Obtiene el panel que corresponde a la selecci?n de transparencia y opacidad |
|
159 |
* @return Panel de transparencia y opacidad |
|
160 |
*/ |
|
161 |
public RasterTransparencyPanel getTransparencyPanel(){ |
|
162 |
return this.pTrans; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Obtiene el panel que corresponde al filtro de realce |
|
167 |
* @return Panel del filtro de realce |
|
168 |
*/ |
|
169 |
public EnhancedPanel getEnhancedPanel(){ |
|
170 |
return this.pEnhan; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Obtiene el panel Info |
|
175 |
* @return InfoPanel |
|
176 |
*/ |
|
177 |
public InfoPanel getInfoPanel(){ |
|
178 |
return this.pInfo; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* Eventos sobre TextField y CheckBox. Controla eventos de checkbox de opacidad, transparencia, |
|
183 |
* recorte de colas y los textfield de opacidad, valores de transparencia por banda y |
|
184 |
* porcentaje de recorte. |
|
185 |
*/ |
|
186 |
public void actionPerformed(ActionEvent e){ |
|
187 |
|
|
188 |
//Evento sobre el checkbox de opacidad |
|
189 |
|
|
190 |
if( e.getSource().equals(pTrans.getOpacityCheck())){ |
|
191 |
|
|
192 |
//Check de opacidad activado -> Activar controles de opacidad |
|
193 |
if(pTrans.getOpacityCheck().isSelected()){ |
|
194 |
pTrans.getOpacitySlider().setEnabled(true); |
|
195 |
pTrans.getOpacityText().setEnabled(true); |
|
196 |
}else{ |
|
197 |
pTrans.getOpacitySlider().setEnabled(false); |
|
198 |
pTrans.getOpacityText().setEnabled(false); |
|
199 |
} |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
//Evento sobre el checkbox de transparencia |
|
204 |
|
|
205 |
if( e.getSource().equals(pTrans.getTransparencyCheck())){ |
|
206 |
|
|
207 |
//Check de opacidad activado -> Activar controles de opacidad |
|
208 |
if(pTrans.getTransparencyCheck().isSelected()){ |
|
209 |
if(nbands==1){ |
|
210 |
pTrans.getTRojo().setEnabled(true); |
|
211 |
pTrans.getTVerde().setEnabled(false); |
|
212 |
pTrans.getTAzul().setEnabled(false); |
|
213 |
} |
|
214 |
|
|
215 |
if(nbands==2){ |
|
216 |
pTrans.getTRojo().setEnabled(true); |
|
217 |
pTrans.getTVerde().setEnabled(true); |
|
218 |
pTrans.getTAzul().setEnabled(false); |
|
219 |
} |
|
220 |
|
|
221 |
if(nbands>=3){ |
|
222 |
pTrans.getTRojo().setEnabled(true); |
|
223 |
pTrans.getTVerde().setEnabled(true); |
|
224 |
pTrans.getTAzul().setEnabled(true); |
|
225 |
} |
|
226 |
|
|
227 |
}else{ |
|
228 |
pTrans.getTRojo().setEnabled(false); |
|
229 |
pTrans.getTVerde().setEnabled(false); |
|
230 |
pTrans.getTAzul().setEnabled(false); |
|
231 |
} |
|
232 |
|
|
233 |
} |
|
234 |
|
|
235 |
//Evento sobre el textfield de opacidad |
|
236 |
|
|
237 |
if( e.getSource().equals(pTrans.getOpacityText())){ |
|
238 |
checkOpacityText(); |
|
239 |
} |
|
240 |
|
|
241 |
//Evento sobre el textfield de valor para el Rojo |
|
242 |
|
|
243 |
if( e.getSource().equals(pTrans.getTRojo())){ |
|
244 |
try{ |
|
245 |
rangeRed = getTransparencyValues(pTrans.getTRojo().getText()); |
|
246 |
}catch(IOException exc){ |
|
247 |
pTrans.getTRojo().setText(""); |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
//Evento sobre el textfield de valor para el Verde |
|
252 |
|
|
253 |
if( e.getSource().equals(pTrans.getTVerde())){ |
|
254 |
try{ |
|
255 |
rangeGreen = getTransparencyValues(pTrans.getTVerde().getText()); |
|
256 |
}catch(IOException exc){ |
|
257 |
pTrans.getTVerde().setText(""); |
|
258 |
} |
|
259 |
} |
|
260 |
|
|
261 |
//Evento sobre el textfield de valor para el Azul |
|
262 |
|
|
263 |
if( e.getSource().equals(pTrans.getTAzul())){ |
|
264 |
try{ |
|
265 |
rangeBlue = getTransparencyValues(pTrans.getTAzul().getText()); |
|
266 |
}catch(IOException exc){ |
|
267 |
pTrans.getTAzul().setText(""); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
//Evento sobre el checkbox de Recorte de colas |
|
272 |
|
|
273 |
if( e.getSource().equals(pEnhan.getTailCheck())){ |
|
274 |
if(pEnhan.getTailCheck().isSelected()) |
|
275 |
pEnhan.setActiveTailControl(true); |
|
276 |
else |
|
277 |
pEnhan.setActiveTailControl(false); |
|
278 |
|
|
279 |
} |
|
280 |
|
|
281 |
//Evento sobre el textfield de porcentaje de recorte |
|
282 |
|
|
283 |
if( e.getSource().equals(pEnhan.getTailText())){ |
|
284 |
checkTailText(); |
|
285 |
} |
|
286 |
|
|
287 |
} |
|
288 |
|
|
289 |
/** |
|
290 |
* Obtiene el rango de valores a partir de la cadena de |
|
291 |
* texto introducida por el usuario. |
|
292 |
* @param values |
|
293 |
*/ |
|
294 |
private int[][] getTransparencyValues(String values)throws IOException{ |
|
295 |
|
|
296 |
int[][] rangeTransparency = null; |
|
297 |
|
|
298 |
for(int i=0;i<values.length();i++){ |
|
299 |
char c = values.charAt(i); |
|
300 |
|
|
301 |
//Control de caracter valido |
|
302 |
if(c != ':' && c != ','){ |
|
303 |
try{ |
|
304 |
Integer.parseInt(String.valueOf(c)); |
|
305 |
}catch(Exception exp){ |
|
306 |
System.err.println("Caracteres incorrectos en la cadena:"+c); |
|
307 |
throw new IOException("Caracteres incorrectos en la cadena."); |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
//Control de comienzo por un simbolo |
|
312 |
if( values.startsWith(",") || values.startsWith(":") || |
|
313 |
values.endsWith(",") || values.endsWith(":")){ |
|
314 |
System.err.println("La cadena empieza o acaba con simbolos incorrectos"); |
|
315 |
throw new IOException(); |
|
316 |
} |
|
317 |
|
|
318 |
//Control de signos consecutivos |
|
319 |
if(i<values.length()-1){ |
|
320 |
|
|
321 |
char cmas = values.charAt(i+1); |
|
322 |
if((c == ',' || c == ':') && (cmas == ',' || cmas == ':')){ |
|
323 |
System.err.println("Signos consecutivos"); |
|
324 |
throw new IOException(); |
|
325 |
} |
|
326 |
|
|
327 |
} |
|
328 |
|
|
329 |
//Control de dos : seguidos con un n?mero en el medio |
|
330 |
if(i<values.length()-3 && c==':'){ |
|
331 |
int n=i+1; |
|
332 |
while(n<values.length()-1 && values.charAt(n) != ',' && values.charAt(n) != ':') |
|
333 |
n++; |
|
334 |
|
|
335 |
char signoSgte = values.charAt(n); |
|
336 |
if(signoSgte == ':'){ |
|
337 |
System.err.println("Dos separadores de rango consecutivos"); |
|
338 |
throw new IOException(); |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
} |
|
343 |
|
|
344 |
//Obtenemos los valores de los intervalos |
|
345 |
|
|
346 |
if(!values.equals("")){ |
|
347 |
String[] t1 = null; |
|
348 |
t1 = values.split("\\,"); |
|
349 |
rangeTransparency = new int[t1.length][2]; |
|
350 |
for(int i=0;i<t1.length;i++){ |
|
351 |
if(t1[i].indexOf(":")==-1){ |
|
352 |
rangeTransparency[i][0] = rangeTransparency[i][1] = Integer.parseInt(t1[i]); |
|
353 |
}else{ |
|
354 |
String[] t2 = null; |
|
355 |
t2 = t1[i].split("\\:"); |
|
356 |
if(Integer.parseInt(t2[1])>Integer.parseInt(t2[0])){ |
|
357 |
rangeTransparency[i][0] = Integer.parseInt(t2[0]); |
|
358 |
rangeTransparency[i][1] = Integer.parseInt(t2[1]); |
|
359 |
}else{ |
|
360 |
rangeTransparency[i][0] = Integer.parseInt(t2[1]); |
|
361 |
rangeTransparency[i][1] = Integer.parseInt(t2[0]); |
|
362 |
} |
|
363 |
} |
|
364 |
if( rangeTransparency[i][0]<0 || rangeTransparency[i][0]>255 || |
|
365 |
rangeTransparency[i][1]<0 || rangeTransparency[i][1]>255){ |
|
366 |
System.err.println("Valores fuera de rango (0-255)"); |
|
367 |
throw new IOException(); |
|
368 |
} |
|
369 |
} |
|
370 |
return rangeTransparency; |
|
371 |
//for(int i=0;i<rangeTransparency.length;i++) |
|
372 |
// System.out.println("("+rangeTransparency[i][0]+":"+rangeTransparency[i][1]+")"); |
|
373 |
} |
|
374 |
|
|
375 |
return null; |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Devuelve el rango de valores para poner transparencia en el Rojo |
|
380 |
* @return |
|
381 |
*/ |
|
382 |
public int[][] getRangeRed(){ |
|
383 |
return rangeRed; |
|
384 |
} |
|
385 |
|
|
386 |
/** |
|
387 |
* Devuelve el rango de valores para poner transparencia en el Verde |
|
388 |
* @return |
|
389 |
*/ |
|
390 |
public int[][] getRangeGreen(){ |
|
391 |
return rangeGreen; |
|
392 |
} |
|
393 |
|
|
394 |
/** |
|
395 |
* Devuelve el rango de valores para poner transparencia en el Azul |
|
396 |
* @return |
|
397 |
*/ |
|
398 |
public int[][] getRangeBlue(){ |
|
399 |
return rangeBlue; |
|
400 |
} |
|
401 |
|
|
402 |
/** |
|
403 |
* Asigna valore para los rangos |
|
404 |
* @param red |
|
405 |
* @param green |
|
406 |
* @param blue |
|
407 |
*/ |
|
408 |
public void setRanges(int[][] red, int[][] green, int[][] blue){ |
|
409 |
rangeRed = red; |
|
410 |
rangeGreen = green; |
|
411 |
rangeBlue = blue; |
|
412 |
if(pTrans!=null){ |
|
413 |
StringBuffer rango = new StringBuffer(); |
|
414 |
if(red!=null){ |
|
415 |
for(int i=0;i<red.length;i++){ |
|
416 |
if(red[i][0] == red[i][1]) |
|
417 |
rango.append(String.valueOf(red[i][0])+","); |
|
418 |
else |
|
419 |
rango.append(String.valueOf(red[i][0])+":"+String.valueOf(red[i][1])+","); |
|
420 |
} |
|
421 |
String t = rango.toString(); |
|
422 |
if(t.endsWith(",")) |
|
423 |
t = t.substring(0, t.length()-1); |
|
424 |
pTrans.getTRojo().setText(t); |
|
425 |
pTrans.setActiveTransparencyControl(true); |
|
426 |
} |
|
427 |
|
|
428 |
if(green!=null){ |
|
429 |
rango = new StringBuffer(); |
|
430 |
for(int i=0;i<green.length;i++){ |
|
431 |
if(green[i][0] == green[i][1]) |
|
432 |
rango.append(String.valueOf(green[i][0])+","); |
|
433 |
else |
|
434 |
rango.append(String.valueOf(green[i][0])+":"+String.valueOf(green[i][1])+","); |
|
435 |
} |
|
436 |
String t = rango.toString(); |
|
437 |
if(t.endsWith(",")) |
|
438 |
t = t.substring(0, t.length()-1); |
|
439 |
pTrans.getTVerde().setText(t); |
|
440 |
pTrans.setActiveTransparencyControl(true); |
|
441 |
} |
|
442 |
|
|
443 |
if(blue!=null){ |
|
444 |
rango = new StringBuffer(); |
|
445 |
for(int i=0;i<blue.length;i++){ |
|
446 |
if(blue[i][0] == blue[i][1]) |
|
447 |
rango.append(String.valueOf(blue[i][0])+","); |
|
448 |
else |
|
449 |
rango.append(String.valueOf(blue[i][0])+":"+String.valueOf(blue[i][1])+","); |
|
450 |
} |
|
451 |
String t = rango.toString(); |
|
452 |
if(t.endsWith(",")) |
|
453 |
t = t.substring(0, t.length()-1); |
|
454 |
pTrans.setActiveTransparencyControl(true); |
|
455 |
pTrans.getTAzul().setText(t); |
|
456 |
} |
|
457 |
|
|
458 |
} |
|
459 |
|
|
460 |
} |
|
461 |
|
|
462 |
/** |
|
463 |
* Controla que si el formato introducido en el textfield |
|
464 |
* de opacidad es numerico se actualiza la posici?n del |
|
465 |
* slider. |
|
466 |
*/ |
|
467 |
private void checkOpacityText(){ |
|
468 |
String op = pTrans.getOpacityText().getText(); |
|
469 |
int value = 0; |
|
470 |
try{ |
|
471 |
if(!op.equals("")) |
|
472 |
value = Integer.parseInt(op); |
|
473 |
pTrans.getOpacitySlider().setValue(value); |
|
474 |
}catch(NumberFormatException exc){ |
|
475 |
System.err.println("Formato no numerico"); |
|
476 |
pTrans.getOpacityText().setText("100"); |
|
477 |
pTrans.getOpacitySlider().setValue(100); |
|
478 |
} |
|
479 |
} |
|
480 |
|
|
481 |
/** |
|
482 |
* Controla que si el formato introducido en el textfield |
|
483 |
* de Recorte de colas es numerico se actualiza la posici?n del |
|
484 |
* slider |
|
485 |
*/ |
|
486 |
private void checkTailText(){ |
|
487 |
String op = pEnhan.getTailText().getText(); |
|
488 |
double value = 0; |
|
489 |
try{ |
|
490 |
if(!op.equals("")) |
|
491 |
value = (Double.parseDouble(op)*100)/50; |
|
492 |
pEnhan.getTailSlider().setValue((int)Math.round(value)); |
|
493 |
pEnhan.getTailText().setText(op); |
|
494 |
}catch(NumberFormatException exc){ |
|
495 |
System.err.println("Formato no numerico"); |
|
496 |
pEnhan.getTailText().setText("0.0"); |
|
497 |
pEnhan.getTailSlider().setValue(0); |
|
498 |
} |
|
499 |
} |
|
500 |
|
|
501 |
/** |
|
502 |
* Llama a las funciones que obtienen los valores de los pixels a los que se |
|
503 |
* quiere aplicar transparencia desde las cajas de texto. |
|
504 |
*/ |
|
505 |
public void checkTransparencyValues(){ |
|
506 |
|
|
507 |
if(!pTrans.getTRojo().getText().equals("")){ |
|
508 |
try{ |
|
509 |
rangeRed = getTransparencyValues(pTrans.getTRojo().getText()); |
|
510 |
}catch(IOException exc){ |
|
511 |
pTrans.getTRojo().setText(""); |
|
512 |
} |
|
513 |
} |
|
514 |
if(!pTrans.getTVerde().getText().equals("")){ |
|
515 |
try{ |
|
516 |
rangeGreen = getTransparencyValues(pTrans.getTVerde().getText()); |
|
517 |
}catch(IOException exc){ |
|
518 |
pTrans.getTVerde().setText(""); |
|
519 |
} |
|
520 |
} |
|
521 |
if(!pTrans.getTAzul().getText().equals("")){ |
|
522 |
try{ |
|
523 |
rangeBlue = getTransparencyValues(pTrans.getTAzul().getText()); |
|
524 |
}catch(IOException exc){ |
|
525 |
pTrans.getTAzul().setText(""); |
|
526 |
} |
|
527 |
} |
|
528 |
} |
|
529 |
|
|
530 |
/* |
|
531 |
* |
|
532 |
*/ |
|
533 |
public void stateChanged(ChangeEvent e){ |
|
534 |
|
|
535 |
//Ponemos el valor del texto de la opacidad de pendiendo de la posici?n del Slider |
|
536 |
if(e.getSource().equals(pTrans.getOpacitySlider())) |
|
537 |
pTrans.getOpacityText().setText(String.valueOf(pTrans.getOpacitySlider().getValue())); |
|
538 |
|
|
539 |
if(e.getSource().equals(pEnhan.getTailSlider())) |
|
540 |
pEnhan.getTailText().setText(String.valueOf((pEnhan.getTailSlider().getValue()>>1))+".0"); |
|
541 |
} |
|
542 |
|
|
543 |
public void focusGained(FocusEvent e) { |
|
544 |
//pTrans.updateTextBox(); |
|
545 |
} |
|
80 |
/** |
|
81 |
* Constructor |
|
82 |
*/ |
|
83 |
public FilterRasterDialogPanel() { |
|
84 |
super(); |
|
85 |
} |
|
546 | 86 |
|
547 |
public void focusLost(FocusEvent e) { |
|
548 |
checkOpacityText(); |
|
549 |
checkTailText(); |
|
550 |
checkTransparencyValues(); |
|
551 |
} |
|
552 |
|
|
553 |
public void mouseExited(MouseEvent e){} |
|
554 |
public void mouseReleased(MouseEvent e){} |
|
555 |
public void mouseEntered(MouseEvent e){} |
|
556 |
|
|
557 |
public void mouseClicked(MouseEvent e){} |
|
558 |
|
|
559 |
public void mousePressed(MouseEvent e){ |
|
560 |
checkTransparencyValues(); |
|
561 |
|
|
562 |
//Evento sobre los radio button de Realce |
|
563 |
|
|
564 |
if(e.getSource().equals(pEnhan.getSinRealceRadioButton())){ |
|
565 |
if(pEnhan.getSinRealceRadioButton().isEnabled()){ |
|
566 |
pEnhan.getTailCheck().setEnabled(false); |
|
567 |
pEnhan.setActiveTailControl(false); |
|
568 |
pEnhan.getSinRealceRadioButton().setSelected(true); |
|
569 |
pEnhan.setActiveRemoveCheck(false); |
|
570 |
} |
|
571 |
} |
|
572 |
|
|
573 |
if(e.getSource().equals(pEnhan.getLinealDirectoRadioButton())){ |
|
574 |
pEnhan.getTailCheck().setEnabled(true); |
|
575 |
pEnhan.setActiveRemoveCheck(true); |
|
576 |
if(pEnhan.getTailCheck().isSelected()){ |
|
577 |
pEnhan.setActiveTailControl(true); |
|
578 |
} |
|
579 |
} |
|
580 |
} |
|
581 |
|
|
582 |
public void keyTyped(KeyEvent e){ |
|
583 |
} |
|
584 |
public void keyPressed(KeyEvent e){ |
|
585 |
} |
|
586 |
public void keyReleased(KeyEvent e){} |
|
587 |
|
|
588 |
} |
|
87 |
/** |
|
88 |
* Inicializa las propiedades |
|
89 |
* @param props Propiedades. Guardadas en una matriz Nx2 con la forma proiedad/valor |
|
90 |
*/ |
|
91 |
public void init(Object[][] props) { |
|
92 |
contentPane.setPreferredSize(new java.awt.Dimension(sizePanelX, |
|
93 |
sizePanelY)); |
|
94 |
this.tabbedPane.setPreferredSize(new java.awt.Dimension(sizePanelX, |
|
95 |
sizePanelY - 5)); |
|
96 |
this.props = props; |
|
97 |
initPanels(); |
|
98 |
} |
|
589 | 99 |
|
100 |
/** |
|
101 |
* This method initializes this |
|
102 |
* |
|
103 |
* @return void |
|
104 |
*/ |
|
105 |
protected void initPanels() { |
|
106 |
this.setBounds(0, 0, 355, 230); |
|
107 |
pTrans = new RasterTransparencyPanel(this); |
|
108 |
pSetup = new BandSetupPanel(); |
|
109 |
pEnhan = new EnhancedPanel(this); |
|
110 |
pInfo = new InfoPanel(this); |
|
111 |
this.addTab(pInfo.nom, pInfo); |
|
112 |
this.addTab(pSetup.nom, pSetup); |
|
113 |
this.addTab(pTrans.nom, pTrans); |
|
114 |
this.addTab(pEnhan.nom, pEnhan); |
|
590 | 115 |
|
116 |
pTrans.getOpacityCheck().addActionListener(this); |
|
117 |
pTrans.getTransparencyCheck().addActionListener(this); |
|
118 |
pTrans.getTRojo().addActionListener(this); |
|
119 |
pTrans.getTVerde().addActionListener(this); |
|
120 |
pTrans.getTAzul().addActionListener(this); |
|
121 |
pTrans.getOpacitySlider().addChangeListener(this); |
|
122 |
pTrans.getOpacityText().addActionListener(this); |
|
123 |
pTrans.getOpacityText().addFocusListener(this); |
|
124 |
pTrans.getTRojo().addFocusListener(this); |
|
125 |
pTrans.getTVerde().addFocusListener(this); |
|
126 |
pTrans.getTAzul().addFocusListener(this); |
|
127 |
pTrans.getTRojo().addMouseListener(this); |
|
128 |
pTrans.getTVerde().addMouseListener(this); |
|
129 |
pTrans.getTAzul().addMouseListener(this); |
|
130 |
pTrans.addFocusListener(this); |
|
131 |
this.getTab().addFocusListener(this); |
|
591 | 132 |
|
133 |
pEnhan.getTailCheck().addActionListener(this); |
|
134 |
pEnhan.getTailSlider().addChangeListener(this); |
|
135 |
pEnhan.getSinRealceRadioButton().addMouseListener(this); |
|
136 |
pEnhan.getLinealDirectoRadioButton().addMouseListener(this); |
|
137 |
pEnhan.getTailText().addActionListener(this); |
|
138 |
pEnhan.getTailText().addFocusListener(this); |
|
592 | 139 |
|
140 |
//Ocultamos el bot?n de aplicar |
|
141 |
//this.getApplyButton().setVisible(false); |
|
142 |
} |
|
593 | 143 |
|
144 |
/** |
|
145 |
* Selecciona el panel indicado por index |
|
146 |
* @param index panel seleccionado |
|
147 |
*/ |
|
148 |
public void setSelectedIndex(int index) { |
|
149 |
tabbedPane.setSelectedIndex(index); |
|
150 |
} |
|
594 | 151 |
|
152 |
/** |
|
153 |
* Obtiene el panel que corresponde a la selecci?n de bandas |
|
154 |
* @return Panel de selecci?n de bandas |
|
155 |
*/ |
|
156 |
public BandSetupPanel getBandSetup() { |
|
157 |
return this.pSetup; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Obtiene el panel que corresponde a la selecci?n de transparencia y opacidad |
|
162 |
* @return Panel de transparencia y opacidad |
|
163 |
*/ |
|
164 |
public RasterTransparencyPanel getTransparencyPanel() { |
|
165 |
return this.pTrans; |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* Obtiene el panel que corresponde al filtro de realce |
|
170 |
* @return Panel del filtro de realce |
|
171 |
*/ |
|
172 |
public EnhancedPanel getEnhancedPanel() { |
|
173 |
return this.pEnhan; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Obtiene el panel Info |
|
178 |
* @return InfoPanel |
|
179 |
*/ |
|
180 |
public InfoPanel getInfoPanel() { |
|
181 |
return this.pInfo; |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* Eventos sobre TextField y CheckBox. Controla eventos de checkbox de opacidad, transparencia, |
|
186 |
* recorte de colas y los textfield de opacidad, valores de transparencia por banda y |
|
187 |
* porcentaje de recorte. |
|
188 |
*/ |
|
189 |
public void actionPerformed(ActionEvent e) { |
|
190 |
//Evento sobre el checkbox de opacidad |
|
191 |
if (e.getSource().equals(pTrans.getOpacityCheck())) { |
|
192 |
//Check de opacidad activado -> Activar controles de opacidad |
|
193 |
if (pTrans.getOpacityCheck().isSelected()) { |
|
194 |
pTrans.getOpacitySlider().setEnabled(true); |
|
195 |
pTrans.getOpacityText().setEnabled(true); |
|
196 |
} else { |
|
197 |
pTrans.getOpacitySlider().setEnabled(false); |
|
198 |
pTrans.getOpacityText().setEnabled(false); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
//Evento sobre el checkbox de transparencia |
|
203 |
if (e.getSource().equals(pTrans.getTransparencyCheck())) { |
|
204 |
//Check de opacidad activado -> Activar controles de opacidad |
|
205 |
if (pTrans.getTransparencyCheck().isSelected()) { |
|
206 |
if (nbands == 1) { |
|
207 |
pTrans.getTRojo().setEnabled(true); |
|
208 |
pTrans.getTVerde().setEnabled(false); |
|
209 |
pTrans.getTAzul().setEnabled(false); |
|
210 |
} |
|
211 |
|
|
212 |
if (nbands == 2) { |
|
213 |
pTrans.getTRojo().setEnabled(true); |
|
214 |
pTrans.getTVerde().setEnabled(true); |
|
215 |
pTrans.getTAzul().setEnabled(false); |
|
216 |
} |
|
217 |
|
|
218 |
if (nbands >= 3) { |
|
219 |
pTrans.getTRojo().setEnabled(true); |
|
220 |
pTrans.getTVerde().setEnabled(true); |
|
221 |
pTrans.getTAzul().setEnabled(true); |
|
222 |
} |
|
223 |
} else { |
|
224 |
pTrans.getTRojo().setEnabled(false); |
|
225 |
pTrans.getTVerde().setEnabled(false); |
|
226 |
pTrans.getTAzul().setEnabled(false); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
//Evento sobre el textfield de opacidad |
|
231 |
if (e.getSource().equals(pTrans.getOpacityText())) { |
|
232 |
checkOpacityText(); |
|
233 |
} |
|
234 |
|
|
235 |
//Evento sobre el textfield de valor para el Rojo |
|
236 |
if (e.getSource().equals(pTrans.getTRojo())) { |
|
237 |
try { |
|
238 |
rangeRed = getTransparencyValues(pTrans.getTRojo().getText()); |
|
239 |
} catch (IOException exc) { |
|
240 |
pTrans.getTRojo().setText(""); |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
//Evento sobre el textfield de valor para el Verde |
|
245 |
if (e.getSource().equals(pTrans.getTVerde())) { |
|
246 |
try { |
|
247 |
rangeGreen = getTransparencyValues(pTrans.getTVerde().getText()); |
|
248 |
} catch (IOException exc) { |
|
249 |
pTrans.getTVerde().setText(""); |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
253 |
//Evento sobre el textfield de valor para el Azul |
|
254 |
if (e.getSource().equals(pTrans.getTAzul())) { |
|
255 |
try { |
|
256 |
rangeBlue = getTransparencyValues(pTrans.getTAzul().getText()); |
|
257 |
} catch (IOException exc) { |
|
258 |
pTrans.getTAzul().setText(""); |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
//Evento sobre el checkbox de Recorte de colas |
|
263 |
if (e.getSource().equals(pEnhan.getTailCheck())) { |
|
264 |
if (pEnhan.getTailCheck().isSelected()) { |
|
265 |
pEnhan.setActiveTailControl(true); |
|
266 |
} else { |
|
267 |
pEnhan.setActiveTailControl(false); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
//Evento sobre el textfield de porcentaje de recorte |
|
272 |
if (e.getSource().equals(pEnhan.getTailText())) { |
|
273 |
checkTailText(); |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 |
/** |
|
278 |
* Obtiene el rango de valores a partir de la cadena de |
|
279 |
* texto introducida por el usuario. |
|
280 |
* @param values |
|
281 |
*/ |
|
282 |
private int[][] getTransparencyValues(String values) |
|
283 |
throws IOException { |
|
284 |
int[][] rangeTransparency = null; |
|
285 |
|
|
286 |
for (int i = 0; i < values.length(); i++) { |
|
287 |
char c = values.charAt(i); |
|
288 |
|
|
289 |
//Control de caracter valido |
|
290 |
if ((c != ':') && (c != ',')) { |
|
291 |
try { |
|
292 |
Integer.parseInt(String.valueOf(c)); |
|
293 |
} catch (Exception exp) { |
|
294 |
System.err.println("Caracteres incorrectos en la cadena:" + |
|
295 |
c); |
|
296 |
throw new IOException("Caracteres incorrectos en la cadena."); |
|
297 |
} |
|
298 |
} |
|
299 |
|
|
300 |
//Control de comienzo por un simbolo |
|
301 |
if (values.startsWith(",") || values.startsWith(":") || |
|
302 |
values.endsWith(",") || values.endsWith(":")) { |
|
303 |
System.err.println("La cadena empieza o acaba con simbolos incorrectos"); |
|
304 |
throw new IOException(); |
|
305 |
} |
|
306 |
|
|
307 |
//Control de signos consecutivos |
|
308 |
if (i < (values.length() - 1)) { |
|
309 |
char cmas = values.charAt(i + 1); |
|
310 |
|
|
311 |
if (((c == ',') || (c == ':')) && |
|
312 |
((cmas == ',') || (cmas == ':'))) { |
|
313 |
System.err.println("Signos consecutivos"); |
|
314 |
throw new IOException(); |
|
315 |
} |
|
316 |
} |
|
317 |
|
|
318 |
//Control de dos : seguidos con un n?mero en el medio |
|
319 |
if ((i < (values.length() - 3)) && (c == ':')) { |
|
320 |
int n = i + 1; |
|
321 |
|
|
322 |
while ((n < (values.length() - 1)) && |
|
323 |
(values.charAt(n) != ',') && |
|
324 |
(values.charAt(n) != ':')) |
|
325 |
n++; |
|
326 |
|
|
327 |
char signoSgte = values.charAt(n); |
|
328 |
|
|
329 |
if (signoSgte == ':') { |
|
330 |
System.err.println("Dos separadores de rango consecutivos"); |
|
331 |
throw new IOException(); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
|
|
336 |
//Obtenemos los valores de los intervalos |
|
337 |
if (!values.equals("")) { |
|
338 |
String[] t1 = null; |
|
339 |
t1 = values.split("\\,"); |
|
340 |
rangeTransparency = new int[t1.length][2]; |
|
341 |
|
|
342 |
for (int i = 0; i < t1.length; i++) { |
|
343 |
if (t1[i].indexOf(":") == -1) { |
|
344 |
rangeTransparency[i][0] = rangeTransparency[i][1] = Integer.parseInt(t1[i]); |
|
345 |
} else { |
|
346 |
String[] t2 = null; |
|
347 |
t2 = t1[i].split("\\:"); |
|
348 |
|
|
349 |
if (Integer.parseInt(t2[1]) > Integer.parseInt(t2[0])) { |
|
350 |
rangeTransparency[i][0] = Integer.parseInt(t2[0]); |
|
351 |
rangeTransparency[i][1] = Integer.parseInt(t2[1]); |
|
352 |
} else { |
|
353 |
rangeTransparency[i][0] = Integer.parseInt(t2[1]); |
|
354 |
rangeTransparency[i][1] = Integer.parseInt(t2[0]); |
|
355 |
} |
|
356 |
} |
|
357 |
|
|
358 |
if ((rangeTransparency[i][0] < 0) || |
|
359 |
(rangeTransparency[i][0] > 255) || |
|
360 |
(rangeTransparency[i][1] < 0) || |
|
361 |
(rangeTransparency[i][1] > 255)) { |
|
362 |
System.err.println("Valores fuera de rango (0-255)"); |
|
363 |
throw new IOException(); |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
367 |
return rangeTransparency; |
|
368 |
|
|
369 |
//for(int i=0;i<rangeTransparency.length;i++) |
|
370 |
// System.out.println("("+rangeTransparency[i][0]+":"+rangeTransparency[i][1]+")"); |
|
371 |
} |
|
372 |
|
|
373 |
return null; |
|
374 |
} |
|
375 |
|
|
376 |
/** |
|
377 |
* Devuelve el rango de valores para poner transparencia en el Rojo |
|
378 |
* @return |
|
379 |
*/ |
|
380 |
public int[][] getRangeRed() { |
|
381 |
return rangeRed; |
|
382 |
} |
|
383 |
|
|
384 |
/** |
|
385 |
* Devuelve el rango de valores para poner transparencia en el Verde |
|
386 |
* @return |
|
387 |
*/ |
|
388 |
public int[][] getRangeGreen() { |
|
389 |
return rangeGreen; |
|
390 |
} |
|
391 |
|
|
392 |
/** |
|
393 |
* Devuelve el rango de valores para poner transparencia en el Azul |
|
394 |
* @return |
|
395 |
*/ |
|
396 |
public int[][] getRangeBlue() { |
|
397 |
return rangeBlue; |
|
398 |
} |
|
399 |
|
|
400 |
/** |
|
401 |
* Asigna valore para los rangos |
|
402 |
* @param red |
|
403 |
* @param green |
|
404 |
* @param blue |
|
405 |
*/ |
|
406 |
public void setRanges(int[][] red, int[][] green, int[][] blue) { |
|
407 |
rangeRed = red; |
|
408 |
rangeGreen = green; |
|
409 |
rangeBlue = blue; |
|
410 |
|
|
411 |
if (pTrans != null) { |
|
412 |
StringBuffer rango = new StringBuffer(); |
|
413 |
|
|
414 |
if (red != null) { |
|
415 |
for (int i = 0; i < red.length; i++) { |
|
416 |
if (red[i][0] == red[i][1]) { |
|
417 |
rango.append(String.valueOf(red[i][0]) + ","); |
|
418 |
} else { |
|
419 |
rango.append(String.valueOf(red[i][0]) + ":" + |
|
420 |
String.valueOf(red[i][1]) + ","); |
|
421 |
} |
|
422 |
} |
|
423 |
|
|
424 |
String t = rango.toString(); |
|
425 |
|
|
426 |
if (t.endsWith(",")) { |
|
427 |
t = t.substring(0, t.length() - 1); |
|
428 |
} |
|
429 |
|
|
430 |
pTrans.getTRojo().setText(t); |
|
431 |
pTrans.setActiveTransparencyControl(true); |
|
432 |
} |
|
433 |
|
|
434 |
if (green != null) { |
|
435 |
rango = new StringBuffer(); |
|
436 |
|
|
437 |
for (int i = 0; i < green.length; i++) { |
|
438 |
if (green[i][0] == green[i][1]) { |
|
439 |
rango.append(String.valueOf(green[i][0]) + ","); |
|
440 |
} else { |
|
441 |
rango.append(String.valueOf(green[i][0]) + ":" + |
|
442 |
String.valueOf(green[i][1]) + ","); |
|
443 |
} |
|
444 |
} |
|
445 |
|
|
446 |
String t = rango.toString(); |
|
447 |
|
|
448 |
if (t.endsWith(",")) { |
|
449 |
t = t.substring(0, t.length() - 1); |
|
450 |
} |
|
451 |
|
|
452 |
pTrans.getTVerde().setText(t); |
|
453 |
pTrans.setActiveTransparencyControl(true); |
|
454 |
} |
|
455 |
|
|
456 |
if (blue != null) { |
|
457 |
rango = new StringBuffer(); |
|
458 |
|
|
459 |
for (int i = 0; i < blue.length; i++) { |
|
460 |
if (blue[i][0] == blue[i][1]) { |
|
461 |
rango.append(String.valueOf(blue[i][0]) + ","); |
|
462 |
} else { |
|
463 |
rango.append(String.valueOf(blue[i][0]) + ":" + |
|
464 |
String.valueOf(blue[i][1]) + ","); |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
String t = rango.toString(); |
|
469 |
|
|
470 |
if (t.endsWith(",")) { |
|
471 |
t = t.substring(0, t.length() - 1); |
|
472 |
} |
|
473 |
|
|
474 |
pTrans.setActiveTransparencyControl(true); |
|
475 |
pTrans.getTAzul().setText(t); |
|
476 |
} |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
* Controla que si el formato introducido en el textfield |
|
482 |
* de opacidad es numerico se actualiza la posici?n del |
|
483 |
* slider. |
|
484 |
*/ |
|
485 |
private void checkOpacityText() { |
|
486 |
String op = pTrans.getOpacityText().getText(); |
|
487 |
int value = 0; |
|
488 |
|
|
489 |
try { |
|
490 |
if (!op.equals("")) { |
|
491 |
value = Integer.parseInt(op); |
|
492 |
} |
|
493 |
|
|
494 |
pTrans.getOpacitySlider().setValue(value); |
|
495 |
} catch (NumberFormatException exc) { |
|
496 |
System.err.println("Formato no numerico"); |
|
497 |
pTrans.getOpacityText().setText("100"); |
|
498 |
pTrans.getOpacitySlider().setValue(100); |
|
499 |
} |
|
500 |
} |
|
501 |
|
|
502 |
/** |
|
503 |
* Controla que si el formato introducido en el textfield |
|
504 |
* de Recorte de colas es numerico se actualiza la posici?n del |
|
505 |
* slider |
|
506 |
*/ |
|
507 |
private void checkTailText() { |
|
508 |
String op = pEnhan.getTailText().getText(); |
|
509 |
double value = 0; |
|
510 |
|
|
511 |
try { |
|
512 |
if (!op.equals("")) { |
|
513 |
value = (Double.parseDouble(op) * 100) / 50; |
|
514 |
} |
|
515 |
|
|
516 |
pEnhan.getTailSlider().setValue((int) Math.round(value)); |
|
517 |
pEnhan.getTailText().setText(op); |
|
518 |
} catch (NumberFormatException exc) { |
|
519 |
System.err.println("Formato no numerico"); |
|
520 |
pEnhan.getTailText().setText("0.0"); |
|
521 |
pEnhan.getTailSlider().setValue(0); |
|
522 |
} |
|
523 |
} |
|
524 |
|
|
525 |
/** |
|
526 |
* Llama a las funciones que obtienen los valores de los pixels a los que se |
|
527 |
* quiere aplicar transparencia desde las cajas de texto. |
|
528 |
*/ |
|
529 |
public void checkTransparencyValues() { |
|
530 |
if (!pTrans.getTRojo().getText().equals("")) { |
|
531 |
try { |
|
532 |
rangeRed = getTransparencyValues(pTrans.getTRojo().getText()); |
|
533 |
} catch (IOException exc) { |
|
534 |
pTrans.getTRojo().setText(""); |
|
535 |
} |
|
536 |
} |
|
537 |
|
|
538 |
if (!pTrans.getTVerde().getText().equals("")) { |
|
539 |
try { |
|
540 |
rangeGreen = getTransparencyValues(pTrans.getTVerde().getText()); |
|
541 |
} catch (IOException exc) { |
|
542 |
pTrans.getTVerde().setText(""); |
|
543 |
} |
|
544 |
} |
|
545 |
|
|
546 |
if (!pTrans.getTAzul().getText().equals("")) { |
|
547 |
try { |
|
548 |
rangeBlue = getTransparencyValues(pTrans.getTAzul().getText()); |
|
549 |
} catch (IOException exc) { |
|
550 |
pTrans.getTAzul().setText(""); |
|
551 |
} |
|
552 |
} |
|
553 |
} |
|
554 |
|
|
555 |
/* |
|
556 |
* |
|
557 |
*/ |
|
558 |
public void stateChanged(ChangeEvent e) { |
|
559 |
//Ponemos el valor del texto de la opacidad de pendiendo de la posici?n del Slider |
|
560 |
if (e.getSource().equals(pTrans.getOpacitySlider())) { |
|
561 |
pTrans.getOpacityText().setText(String.valueOf(pTrans.getOpacitySlider() |
|
562 |
.getValue())); |
|
563 |
} |
|
564 |
|
|
565 |
if (e.getSource().equals(pEnhan.getTailSlider())) { |
|
566 |
pEnhan.getTailText().setText(String.valueOf((pEnhan.getTailSlider() |
|
567 |
.getValue() >> 1)) + |
|
568 |
".0"); |
|
569 |
} |
|
570 |
} |
|
571 |
|
|
572 |
public void focusGained(FocusEvent e) { |
|
573 |
//pTrans.updateTextBox(); |
|
574 |
} |
|
575 |
|
|
576 |
public void focusLost(FocusEvent e) { |
|
577 |
checkOpacityText(); |
|
578 |
checkTailText(); |
|
579 |
checkTransparencyValues(); |
|
580 |
} |
|
581 |
|
|
582 |
public void mouseExited(MouseEvent e) { |
|
583 |
} |
|
584 |
|
|
585 |
public void mouseReleased(MouseEvent e) { |
|
586 |
} |
|
587 |
|
|
588 |
public void mouseEntered(MouseEvent e) { |
|
589 |
} |
|
590 |
|
|
591 |
public void mouseClicked(MouseEvent e) { |
|
592 |
} |
|
593 |
|
|
594 |
public void mousePressed(MouseEvent e) { |
|
595 |
checkTransparencyValues(); |
|
596 |
|
|
597 |
//Evento sobre los radio button de Realce |
|
598 |
if (e.getSource().equals(pEnhan.getSinRealceRadioButton())) { |
|
599 |
if (pEnhan.getSinRealceRadioButton().isEnabled()) { |
|
600 |
pEnhan.getTailCheck().setEnabled(false); |
|
601 |
pEnhan.setActiveTailControl(false); |
|
602 |
pEnhan.getSinRealceRadioButton().setSelected(true); |
|
603 |
pEnhan.setActiveRemoveCheck(false); |
|
604 |
} |
|
605 |
} |
|
606 |
|
|
607 |
if (e.getSource().equals(pEnhan.getLinealDirectoRadioButton())) { |
|
608 |
pEnhan.getTailCheck().setEnabled(true); |
|
609 |
pEnhan.setActiveRemoveCheck(true); |
|
610 |
|
|
611 |
if (pEnhan.getTailCheck().isSelected()) { |
|
612 |
pEnhan.setActiveTailControl(true); |
|
613 |
} |
|
614 |
} |
|
615 |
} |
|
616 |
|
|
617 |
public void keyTyped(KeyEvent e) { |
|
618 |
} |
|
619 |
|
|
620 |
public void keyPressed(KeyEvent e) { |
|
621 |
} |
|
622 |
|
|
623 |
public void keyReleased(KeyEvent e) { |
|
624 |
} |
|
625 |
} |
Also available in: Unified diff