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