root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / PropertiesRasterDialog.java @ 6877
History | View | Annotate | Download (38.3 KB)
1 |
/*
|
---|---|
2 |
* Created on 17-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.gui.panels; |
48 |
|
49 |
import java.awt.Container; |
50 |
import java.awt.Event; |
51 |
import java.awt.event.ActionEvent; |
52 |
import java.awt.event.ActionListener; |
53 |
import java.awt.event.FocusEvent; |
54 |
import java.awt.event.FocusListener; |
55 |
import java.awt.event.MouseEvent; |
56 |
import java.awt.event.MouseListener; |
57 |
import java.awt.geom.Rectangle2D; |
58 |
import java.io.File; |
59 |
import java.util.ArrayList; |
60 |
import java.util.Vector; |
61 |
|
62 |
import javax.swing.JFileChooser; |
63 |
import javax.swing.JOptionPane; |
64 |
import javax.swing.JPanel; |
65 |
import javax.swing.filechooser.FileFilter; |
66 |
|
67 |
import org.cresques.cts.IProjection; |
68 |
import org.cresques.filter.RasterFilter; |
69 |
import org.cresques.filter.RasterFilterStackManager; |
70 |
import org.cresques.filter.BrightnessContrast.BrightnessContrastStackManager; |
71 |
import org.cresques.io.GeoRasterFile; |
72 |
import org.cresques.px.Extent; |
73 |
import org.cresques.ui.BrightnessContrast.EnhancedBrightnessContrastPanel; |
74 |
import org.cresques.ui.raster.BandSetupPanel; |
75 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
76 |
import org.cresques.ui.raster.InfoPanel; |
77 |
import org.cresques.ui.raster.RasterTransparencyPanel; |
78 |
|
79 |
import com.hardcode.driverManager.Driver; |
80 |
import com.hardcode.driverManager.DriverLoadException; |
81 |
import com.iver.andami.PluginServices; |
82 |
import com.iver.andami.messages.NotificationManager; |
83 |
import com.iver.andami.ui.mdiManager.IWindow; |
84 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
85 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
86 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
87 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
88 |
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster; |
89 |
|
90 |
/**
|
91 |
* <P>
|
92 |
* Dialogo para las propiedades de un raster. Esta maneja los eventos y aplica
|
93 |
* filtros sobre el raster a trav?s de l gestor de la pila de filtros seg?n la
|
94 |
* selecci?n del usuario. Este dialogo contiene varios paneles:
|
95 |
* </P>
|
96 |
* <UL>
|
97 |
* <LI>Propiedades</LI>
|
98 |
* <LI>Selecci?n de bandas</LI>
|
99 |
* <LI>Transparencia</LI>
|
100 |
* <LI>Realce</LI>
|
101 |
* </UL>
|
102 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
103 |
*/
|
104 |
public class PropertiesRasterDialog extends FilterRasterDialogPanel implements IWindow, MouseListener, ActionListener, FocusListener{ |
105 |
|
106 |
private JPanel propPanel = null; |
107 |
private IProjection currentProjection = null; |
108 |
private FLyrRaster fLayer = null; |
109 |
private static final int nprops = 13; |
110 |
private Object[][] props = null; |
111 |
private RasterFilterStackManager stackManager = null; |
112 |
private Status status = null; |
113 |
private String filename = null; |
114 |
private long filesize = 0; |
115 |
private int width = 0; |
116 |
private int height = 0; |
117 |
private JFileChooser fileChooser = null; |
118 |
private String lastPath = new String("./"); |
119 |
private StatusLayerRaster rasterStatus = null; |
120 |
private int sizeX = 486, sizeY = 352; |
121 |
|
122 |
/**
|
123 |
* Clase que guarda el estado del dialogo y gestiona la restauraci?n
|
124 |
* del estado inicial en caso de cancelar.
|
125 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
126 |
*/
|
127 |
class Status{ |
128 |
public String inicAlpha; |
129 |
public int bandR; |
130 |
public int bandG; |
131 |
public int bandB; |
132 |
private ArrayList filesAdd = new ArrayList(); |
133 |
private ArrayList filesRem = new ArrayList(); |
134 |
private ArrayList filters = null; |
135 |
|
136 |
|
137 |
public Status(String alpha, int bandR, int bandG, int bandB){ |
138 |
this.inicAlpha = alpha;
|
139 |
this.bandR = bandR;
|
140 |
this.bandG = bandG;
|
141 |
this.bandB = bandB;
|
142 |
filters = stackManager.getStringsFromStack(); |
143 |
} |
144 |
|
145 |
/**
|
146 |
* A?ade un fichero a la lista de a?adidos. Si estaba en la de eliminados
|
147 |
* lo quitamos.
|
148 |
* @param file Fichero a?adido
|
149 |
*/
|
150 |
public void addFile(String file){ |
151 |
filesAdd.add(file); |
152 |
for(int j=0;j<filesRem.size();j++){ |
153 |
if(file.equals((String)filesRem.get(j))) |
154 |
filesRem.remove(j); |
155 |
} |
156 |
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* Elimina un fichero de la lista de a?adidos si ha sido a?adido. Si ya estaba
|
161 |
* antes no estar? en la lista de a?adidos por lo que habr? que ponerlo en la
|
162 |
* lista de eliminados.
|
163 |
* @param file Fichero eliminado
|
164 |
*/
|
165 |
public void removeFile(String file){ |
166 |
boolean isAdd = false; |
167 |
for(int i=0;i<filesAdd.size();i++){ |
168 |
if(((String)filesAdd.get(i)).equals(file)){ |
169 |
filesAdd.remove(i); |
170 |
isAdd = true;
|
171 |
} |
172 |
} |
173 |
if(!isAdd)
|
174 |
filesRem.add(file); |
175 |
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* Restaura el Estado salvado
|
180 |
* @param status Estado
|
181 |
*/
|
182 |
public void restoreStatus(PropertiesRasterDialog props){ |
183 |
//Devolvemos la pila de filtros al estado inicial
|
184 |
//if(stackManager != null)
|
185 |
// stackManager.deleteTempFilters();
|
186 |
|
187 |
//Devolvemos el alpha al estado inicial
|
188 |
int opac = Integer.parseInt(status.inicAlpha); |
189 |
opac = (int)((opac*255)/100); |
190 |
fLayer.getSource().setTransparency(true);
|
191 |
fLayer.setTransparency(255-opac);
|
192 |
rasterStatus.transparency = 255-opac;
|
193 |
|
194 |
//Devolvemos el estado inicial de las bandas
|
195 |
|
196 |
if (fLayer != null) { |
197 |
fLayer.getSource().setBand(GeoRasterFile.RED_BAND, status.bandR); |
198 |
fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND, status.bandG); |
199 |
fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND, status.bandB); |
200 |
rasterStatus.bandR = status.bandR; |
201 |
rasterStatus.bandG = status.bandG; |
202 |
rasterStatus.bandB = status.bandB; |
203 |
} |
204 |
|
205 |
|
206 |
//Los que han sido a?adidos los quitamos
|
207 |
for(int i=0;i<filesAdd.size();i++) |
208 |
fLayer.delFile((String)this.filesAdd.get(i)); |
209 |
|
210 |
//Los que fueron quitados los a?adimos
|
211 |
for(int i=0;i<filesRem.size();i++) |
212 |
fLayer.addFiles((String)this.filesRem.get(i)); |
213 |
|
214 |
//Restauramos los filtros
|
215 |
if(filters!=null && ((FLyrRaster)fLayer).getSource().getFiles() != null) |
216 |
stackManager.createStackFromStrings(filters, ((FLyrRaster)fLayer).getSource().getFiles()); |
217 |
|
218 |
fLayer.getFMap().invalidate(); |
219 |
//this.show();
|
220 |
} |
221 |
|
222 |
public void show(){ |
223 |
System.out.println("***Lista A?adidos***"); |
224 |
for(int i=0;i<filesAdd.size();i++){ |
225 |
System.out.println(filesAdd.get(i).toString());
|
226 |
} |
227 |
System.out.println("***Lista Eliminados***"); |
228 |
for(int i=0;i<filesRem.size();i++){ |
229 |
System.out.println(filesRem.get(i).toString());
|
230 |
} |
231 |
System.out.println("*********************"); |
232 |
} |
233 |
|
234 |
} |
235 |
|
236 |
public class DriverFileFilter extends FileFilter{ |
237 |
|
238 |
private Driver driver; |
239 |
|
240 |
public DriverFileFilter(String driverName) throws DriverLoadException{ |
241 |
driver = LayerFactory.getDM().getDriver(driverName); |
242 |
} |
243 |
|
244 |
/**
|
245 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
|
246 |
*/
|
247 |
public boolean accept(File f) { |
248 |
if (f.isDirectory()) return true; |
249 |
if (driver instanceof RasterDriver){ |
250 |
return ((RasterDriver) driver).fileAccepted(f);
|
251 |
}else{
|
252 |
throw new RuntimeException("Tipo no reconocido"); |
253 |
} |
254 |
} |
255 |
|
256 |
/**
|
257 |
* @see javax.swing.filechooser.FileFilter#getDescription()
|
258 |
*/
|
259 |
public String getDescription() { |
260 |
return ((Driver) driver).getName(); |
261 |
} |
262 |
} |
263 |
|
264 |
/**
|
265 |
* Inicializador de valores de la ventana de dialogo.
|
266 |
* @param app
|
267 |
*/
|
268 |
public PropertiesRasterDialog(FLyrRaster layer, ArrayList ranges){ |
269 |
fLayer = layer; |
270 |
if(fLayer.getStatus()==null){ |
271 |
rasterStatus = new StatusLayerRaster();
|
272 |
fLayer.setStatus(rasterStatus); |
273 |
}else
|
274 |
rasterStatus = (StatusLayerRaster)fLayer.getStatus(); |
275 |
init(); |
276 |
this.setRanges(ranges);
|
277 |
setTranslation(); |
278 |
|
279 |
EnhancedBrightnessContrastPanel ep = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
280 |
ep.lstBrightness.getJSlider().addMouseListener(this);
|
281 |
ep.lstContrast.getJSlider().addMouseListener(this);
|
282 |
ep.getCheckSliderText().getJTextField().addKeyListener(this);
|
283 |
ep.lstBrightness.getJTextField().addActionListener(this);
|
284 |
ep.lstContrast.getJTextField().addActionListener(this);
|
285 |
ep.lstBrightness.getJTextField().addFocusListener(this);
|
286 |
ep.lstContrast.getJTextField().addFocusListener(this);
|
287 |
} |
288 |
|
289 |
/**
|
290 |
* Asigna los textos a los paneles
|
291 |
*/
|
292 |
private void setTranslation(){ |
293 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
294 |
|
295 |
bandSetup.getFileList().getJButtonAdd().setText(PluginServices.getText(this,"Anadir")); |
296 |
bandSetup.getFileList().getJButtonRemove().setText(PluginServices.getText(this,"Eliminar")); |
297 |
bandSetup.getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bandas")); |
298 |
|
299 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)super.getPanelByClassName("RasterTransparencyPanel"); |
300 |
|
301 |
tpan.getTransparencyCheck().setText(PluginServices.getText(this,"activar")); |
302 |
tpan.getPTransparencyByPixel().setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"transparencia_pixel"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
303 |
tpan.getOpacityCheck().setText(PluginServices.getText(this,"activar")); |
304 |
tpan.getOpacityPanel().setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"opacidad"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
305 |
|
306 |
|
307 |
EnhancedBrightnessContrastPanel ep = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
308 |
|
309 |
ep.lLineal.setText(PluginServices.getText(this, "lineal_directo")); |
310 |
ep.lRemove.setText(PluginServices.getText(this, "eliminar_extremos")); |
311 |
ep.cstEnhanced.setName(PluginServices.getText(this, "recorte_colas")+" ( % )"); |
312 |
ep.lBrightC.setText(PluginServices.getText(this, "brillo_y_contraste")); |
313 |
ep.lstBrightness.setName(PluginServices.getText(this, "brillo")); |
314 |
ep.lstContrast.setName(PluginServices.getText(this, "contraste")); |
315 |
ep.lpreview.setText(PluginServices.getText(this, "previsualizacion")); |
316 |
ep.getPBrightCont().setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), (PluginServices.getText(this, "brillo_y_contraste")), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black)); |
317 |
ep.getPEnhanced().setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), (PluginServices.getText(this, "realce")), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black)); |
318 |
|
319 |
InfoPanel ip = (InfoPanel)super.getPanelByClassName("InfoPanel"); |
320 |
|
321 |
ip.cabInfo = new String(PluginServices.getText(this, "Informacion")); |
322 |
ip.cabCoord = new String(PluginServices.getText(this, "coor_geograficas")); |
323 |
ip.cabProy = new String(PluginServices.getText(this, "Proyecciones")); |
324 |
ip.cabOrig = new String(PluginServices.getText(this, "origen_de_datos")); |
325 |
ip.cabMeta = new String(PluginServices.getText(this, "metadatos")); |
326 |
|
327 |
//Recorremos los Tab y traducimos el nombre
|
328 |
for(int i=0;i<this.getTab().getTabCount();i++){ |
329 |
if(this.getTab().getTitleAt(i).equals("Info")) |
330 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"info")); |
331 |
if(this.getTab().getTitleAt(i).equals("Transparencia")) |
332 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"Transparencia")); |
333 |
if(this.getTab().getTitleAt(i).equals("Bandas")) |
334 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"bandas")); |
335 |
if(this.getTab().getTitleAt(i).equals("Realce")) |
336 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"realce")); |
337 |
} |
338 |
|
339 |
this.getAcceptButton().setText(PluginServices.getText(this,"Aceptar")); |
340 |
this.getApplyButton().setText(PluginServices.getText(this,"Aplicar")); |
341 |
this.getCancelButton().setText(PluginServices.getText(this,"Cancelar")); |
342 |
} |
343 |
|
344 |
/**
|
345 |
* Asigna un FLayerRaster
|
346 |
* @param layer capa a asignar
|
347 |
*/
|
348 |
public void setFLyrRaster(FLyrRaster layer){ |
349 |
fLayer = layer; |
350 |
} |
351 |
|
352 |
|
353 |
|
354 |
/**
|
355 |
* Carga los datos del panel info.
|
356 |
*/
|
357 |
private void loadInfoData(){ |
358 |
if(fLayer.getSource()!=null){ |
359 |
props = new Object[nprops][2]; |
360 |
props[0][0] = new String(PluginServices.getText(this,"Fichero")+":"); |
361 |
props[0][1] = filename; |
362 |
props[1][0] = new String(PluginServices.getText(this,"tamano")+":"); |
363 |
props[1][1] = new String(String.valueOf(this.filesize)+" bytes"); |
364 |
props[2][0] = new String(PluginServices.getText(this,"ancho_alto")+":"); |
365 |
props[2][1] = this.width+" , "+this.height; |
366 |
props[3][0] = new String(PluginServices.getText(this,"formato")+":"); |
367 |
props[3][1] = filename.substring( |
368 |
filename.lastIndexOf('.')+1, |
369 |
filename.length()); |
370 |
props[4][0] = new String(PluginServices.getText(this,"tipo_dato")+":"); |
371 |
String type = null; |
372 |
switch(fLayer.getSource().getDataType()){
|
373 |
case 0: type = new String("BYTE");break; |
374 |
case 1: type = new String("USHORT");break; |
375 |
case 2: type = new String("SHORT");break; |
376 |
case 3: type = new String("INT");break; |
377 |
case 4: type = new String("FLOAT");break; |
378 |
case 5: type = new String("DOUBLE");break; |
379 |
default: type = new String("UNDEFINED");break; |
380 |
} |
381 |
props[4][1] = type; |
382 |
props[4][0] = new String(PluginServices.getText(this, "georeferenciado")+":"); |
383 |
if(fLayer.isGeoreferenced()) props[4][1] = new String(PluginServices.getText(this, "si")); |
384 |
else props[4][1] = new String(PluginServices.getText(this, "no")); |
385 |
props[5][0] = new String(PluginServices.getText(this,"num_bandas")+":"); |
386 |
props[5][1] = new String(String.valueOf(fLayer.getSource().getNumBands())); |
387 |
props[6][0] = new String(PluginServices.getText(this,"coor_geograficas")); |
388 |
props[7][0] = new String(PluginServices.getText(this,"xmin")+":"); |
389 |
props[7][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinX()); |
390 |
props[8][0] = new String(PluginServices.getText(this,"ymin")+":"); |
391 |
props[8][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinY()); |
392 |
props[9][0] = new String(PluginServices.getText(this,"xmax")+":"); |
393 |
props[9][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxX()); |
394 |
props[10][0] = new String(PluginServices.getText(this,"ymax")+":"); |
395 |
props[10][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxY()); |
396 |
|
397 |
double tamRealX = fLayer.getSource().getFullExtent().getMaxX()-fLayer.getSource().getFullExtent().getMinX();
|
398 |
double tamRealY = fLayer.getSource().getFullExtent().getMaxY()-fLayer.getSource().getFullExtent().getMinY();
|
399 |
double tamX = Math.round((tamRealX/this.width)*10000000); |
400 |
double tamY = Math.round((tamRealY/this.height)*10000000); |
401 |
|
402 |
String tamPixX = String.valueOf(tamX/10000000); |
403 |
String tamPixY = String.valueOf(tamY/10000000); |
404 |
|
405 |
props[11][0] = new String(PluginServices.getText(this, "tamPixX")); |
406 |
props[11][1] = tamPixX + " " + new String(PluginServices.getText(this, "m/pixel")); |
407 |
props[12][0] = new String(PluginServices.getText(this, "tamPixY")); |
408 |
props[12][1] = tamPixY + " " + new String(PluginServices.getText(this, "m/pixel")); |
409 |
|
410 |
if(!fLayer.isGeoreferenced()){
|
411 |
props[11][1] = "-"; |
412 |
props[12][1] = "-"; |
413 |
} |
414 |
|
415 |
}else{
|
416 |
props = new Object[1][2]; |
417 |
props[0][0] = new String("No props"); |
418 |
props[0][1] = new String("-"); |
419 |
} |
420 |
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* A?ade bandas al contador de bandas del FilterRasterDialogPanel
|
425 |
* @param numBands N?mero de bandas a a?adir
|
426 |
*/
|
427 |
public void addNumBands(int numBands){ |
428 |
nbands += numBands; |
429 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)super.getPanelByClassName("RasterTransparencyPanel"); |
430 |
if(tpan != null && tpan.getPTranspByPixel().isControlEnabled()) |
431 |
tpan.setActiveTransparencyControl(true);
|
432 |
} |
433 |
|
434 |
/**
|
435 |
* Inicializa el jDialog
|
436 |
*/
|
437 |
public void init() { |
438 |
|
439 |
//this.setLayout(new FlowLayout());
|
440 |
|
441 |
setName("filterRaster");
|
442 |
ArrayList attr = ((FLyrRaster)fLayer).getSource().getAttributes();
|
443 |
for (int i=0; i<attr.size(); i++) { |
444 |
Object[] a = (Object []) attr.get(i); |
445 |
if(a[0].toString().equals("Filename")) |
446 |
filename = a[1].toString();
|
447 |
if(a[0].toString().equals("Filesize")) |
448 |
filesize = ((Long)a[1]).intValue(); |
449 |
if(a[0].toString().equals("Width")) |
450 |
width = ((Integer)a[1]).intValue(); |
451 |
if(a[0].toString().equals("Height")) |
452 |
height = ((Integer)a[1]).intValue(); |
453 |
} |
454 |
|
455 |
this.loadInfoData();
|
456 |
super.init(props);
|
457 |
|
458 |
InfoPanel info = (InfoPanel)super.getPanelByClassName("InfoPanel"); |
459 |
info.columnNames[0] = PluginServices.getText(this,"propiedad"); |
460 |
info.columnNames[1] = PluginServices.getText(this,"Valor"); |
461 |
//info.resetTable();
|
462 |
//info.initialize();
|
463 |
|
464 |
//this.add(getContentPane());
|
465 |
|
466 |
this.setSize(this.sizeX, this.sizeY); |
467 |
|
468 |
//contentPane.getAcceptButton().setEnabled(false);
|
469 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
470 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
471 |
acceptButtonActionPerformed(evt); |
472 |
//Solo cuando le damos a aceptar guardamos la situaci?n actual de los
|
473 |
//ficheros cargados en el StatusLayerRaster
|
474 |
if(rasterStatus!=null){ |
475 |
ArrayList rs = new ArrayList(); |
476 |
for(int i=0;i<fLayer.getSource().getFiles().length;i++) |
477 |
rs.add(fLayer.getSource().getFiles()[i].getName()); |
478 |
rasterStatus.files = rs; |
479 |
} |
480 |
closeJDialog(); |
481 |
} |
482 |
}); |
483 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
484 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
485 |
cancelButtonActionPerformed(evt); |
486 |
closeJDialog(); |
487 |
} |
488 |
}); |
489 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
490 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
491 |
acceptButtonActionPerformed(evt); |
492 |
} |
493 |
}); |
494 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
495 |
bandSetup.getFileList().getJButtonAdd().addActionListener(new java.awt.event.ActionListener() {
|
496 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
497 |
addFileBand(evt); |
498 |
|
499 |
} |
500 |
}); |
501 |
bandSetup.getFileList().getJButtonRemove().addActionListener(new java.awt.event.ActionListener() {
|
502 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
503 |
delFileBand(evt); |
504 |
} |
505 |
}); |
506 |
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* Salva el estado inicial por si se cancela
|
511 |
*/
|
512 |
public void readStat(){ |
513 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)super.getPanelByClassName("RasterTransparencyPanel"); |
514 |
status = new Status(tpan.getOpacityText().getText(),
|
515 |
getAssignedBand(GeoRasterFile.RED_BAND), |
516 |
getAssignedBand(GeoRasterFile.GREEN_BAND), |
517 |
getAssignedBand(GeoRasterFile.BLUE_BAND)); |
518 |
} |
519 |
|
520 |
/**
|
521 |
* This method initializes jContentPane
|
522 |
*/
|
523 |
public Container getContentPane() { |
524 |
return this; |
525 |
} |
526 |
|
527 |
/**
|
528 |
* Asigna una proyecci?n
|
529 |
* @param prj
|
530 |
*/
|
531 |
public void setProjection(IProjection prj) { |
532 |
this.currentProjection = prj;
|
533 |
} |
534 |
|
535 |
public void closeJDialog() { |
536 |
try{
|
537 |
PluginServices.getMDIManager().closeView(PropertiesRasterDialog.this); |
538 |
}catch(ArrayIndexOutOfBoundsException e){ |
539 |
//Si la ventana no se puede eliminar no hacemos nada
|
540 |
} |
541 |
} |
542 |
|
543 |
/**
|
544 |
* Asigna el RasterFilterStackManager
|
545 |
* @param stackManager
|
546 |
*/
|
547 |
public void setRasterFilterStackManager(RasterFilterStackManager stackManager){ |
548 |
this.stackManager = stackManager;
|
549 |
stackManager.resetTempFilters(); |
550 |
} |
551 |
|
552 |
/**
|
553 |
*
|
554 |
* @param flag
|
555 |
* @return
|
556 |
*/
|
557 |
public int getAssignedBand(int flag) { |
558 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
559 |
return bandSetup.getAssignedBand(flag);
|
560 |
} |
561 |
|
562 |
/**
|
563 |
* Obtiene las bandas que el usuario ha seleccionado que son visibles.
|
564 |
* Devuelve una cadena: RGB, R, G, B, RG, RB, GB
|
565 |
* @return Bandas visibles
|
566 |
*/
|
567 |
public String getVisibleBands(){ |
568 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
569 |
return bandSetup.getFileList().getJComboBox().getSelectedItem().toString();
|
570 |
} |
571 |
|
572 |
/**
|
573 |
* Pulsar aceptar con el panel de bandas seleccionado hace que se procesen los valores
|
574 |
* introducidos en este.
|
575 |
* @return true si estaba seleccionado el panel de bandas y se ha procesado la
|
576 |
* acci?n y false si no lo estaba.
|
577 |
*/
|
578 |
public void processBandPanel(){ |
579 |
//if(this.getTab().getSelectedComponent() == this.getBandSetup()){
|
580 |
fLayer.getSource().setBand(GeoRasterFile.RED_BAND, |
581 |
getAssignedBand(GeoRasterFile.RED_BAND)); |
582 |
fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND, |
583 |
getAssignedBand(GeoRasterFile.GREEN_BAND)); |
584 |
fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND, |
585 |
getAssignedBand(GeoRasterFile.BLUE_BAND)); |
586 |
rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND); |
587 |
rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND); |
588 |
rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND); |
589 |
|
590 |
//Comprobamos si hay alguna banda que no est? asignada y aplicamos el filtro
|
591 |
StringBuffer sb = new StringBuffer(); |
592 |
if(getAssignedBand(GeoRasterFile.RED_BAND) == -1) |
593 |
sb.append("R");
|
594 |
if(getAssignedBand(GeoRasterFile.GREEN_BAND) == -1) |
595 |
sb.append("G");
|
596 |
if(getAssignedBand(GeoRasterFile.BLUE_BAND) == -1) |
597 |
sb.append("B");
|
598 |
|
599 |
if(!sb.toString().equals("")) |
600 |
stackManager.addRemoveBands(sb.toString()); |
601 |
else
|
602 |
stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
|
603 |
|
604 |
//Al reasignar las bandas tenemos que tenerlo en cuenta en el sharpening
|
605 |
RasterFilter sharp = stackManager.getFilter("sharpening");
|
606 |
if(sharp != null){ |
607 |
int[] order = {getAssignedBand(GeoRasterFile.RED_BAND),getAssignedBand(GeoRasterFile.GREEN_BAND),getAssignedBand(GeoRasterFile.BLUE_BAND)}; |
608 |
sharp.removeParam("order");
|
609 |
sharp.addParam("order", order);
|
610 |
} |
611 |
fLayer.getFMap().invalidate(); |
612 |
|
613 |
InfoPanel pInfo = (InfoPanel)super.getPanelByClassName("InfoPanel"); |
614 |
pInfo.setBands(getAssignedBand(GeoRasterFile.RED_BAND),getAssignedBand(GeoRasterFile.GREEN_BAND),getAssignedBand(GeoRasterFile.BLUE_BAND)); |
615 |
} |
616 |
|
617 |
/**
|
618 |
* Pulsar aceptar con el panel de transparecias seleccionado hace que se procesen los valores
|
619 |
* introducidos en este.
|
620 |
* @return true si estaba seleccionado el panel de transparencias y se ha procesado la
|
621 |
* acci?n y false si no lo estaba.
|
622 |
*/
|
623 |
public void processTransparencyPanel(){ |
624 |
//OPACIDAD
|
625 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)super.getPanelByClassName("RasterTransparencyPanel"); |
626 |
String sOpac = tpan.getOpacityText().getText();
|
627 |
if(!sOpac.equals("") && tpan.getOpacityCheck().isSelected()){ |
628 |
int opac = Integer.parseInt(sOpac); |
629 |
opac = (int)((opac*255)/100); |
630 |
fLayer.getSource().setTransparency(true);
|
631 |
fLayer.setTransparency(255-opac);
|
632 |
rasterStatus.transparency = 255-opac;
|
633 |
}else{
|
634 |
fLayer.getSource().setTransparency(false);
|
635 |
fLayer.setTransparency(0);
|
636 |
rasterStatus.transparency = 0;
|
637 |
} |
638 |
|
639 |
//TRANSPARENCIA
|
640 |
if( tpan.getTransparencyCheck().isSelected()){
|
641 |
stackManager.addTransparencyFilter( tpan.getPTranspByPixel().getEntries(), |
642 |
0x10, //Transparencia |
643 |
0xff, //Color Transparencia R |
644 |
0xff, //Color Transparencia G |
645 |
0xff); //Color Transparencia B |
646 |
}else{
|
647 |
fLayer.getSource().getFilterStack().removeFilter(stackManager.getTypeFilter("transparency"));
|
648 |
} |
649 |
|
650 |
} |
651 |
|
652 |
private void processBrightnessContrastPanel(){ |
653 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
654 |
// Si est? activo el panel de brillo y contraste tomamos los valores y cargamos un filtro de
|
655 |
// brillo y contraste
|
656 |
|
657 |
BrightnessContrastStackManager bcStackManager = (BrightnessContrastStackManager)stackManager.getManagerByClass(BrightnessContrastStackManager.class); |
658 |
if(ebcPanel.getCBrightC().isSelected()){
|
659 |
int incrBrillo = (int)Math.round(Double.valueOf(ebcPanel.lstBrightness.getTextValue()).doubleValue()); |
660 |
int incrContraste = (int)Math.round(Double.valueOf(ebcPanel.lstContrast.getTextValue()).doubleValue()); |
661 |
bcStackManager.addBrightnessFilter(incrBrillo); |
662 |
bcStackManager.addContrastFilter(incrContraste); |
663 |
|
664 |
if(incrBrillo == 0) stackManager.removeFilter(bcStackManager.brightness); |
665 |
if(incrContraste == 0) stackManager.removeFilter(bcStackManager.contrast); |
666 |
|
667 |
}else{
|
668 |
stackManager.removeFilter(bcStackManager.brightness); |
669 |
stackManager.removeFilter(bcStackManager.contrast); |
670 |
} |
671 |
fLayer.getFMap().invalidate(); |
672 |
} |
673 |
|
674 |
/**
|
675 |
* Pulsar aceptar con el panel de realce seleccionado hace que se procesen los valores
|
676 |
* introducidos en este.
|
677 |
* @return true si estaba seleccionado el panel de realce y se ha procesado la
|
678 |
* acci?n y false si no lo estaba.
|
679 |
*/
|
680 |
public void processEnhancedPanel(){ |
681 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
682 |
|
683 |
//Filtro de realce lineal seleccionado
|
684 |
if(ebcPanel.getCEnhanced().isSelected()){
|
685 |
if((ebcPanel.getJCheckBox().isSelected()) && (!ebcPanel.getCheckSliderText().getJCheckBox().isSelected()))
|
686 |
stackManager.addEnhancedFilter(true, fLayer.getSource().getFiles()[0].getName()); |
687 |
else
|
688 |
stackManager.addEnhancedFilter(false, fLayer.getSource().getFiles()[0].getName()); |
689 |
|
690 |
//Recorte de colas seleccionado
|
691 |
if(ebcPanel.getCheckSliderText().getJCheckBox().isSelected()){
|
692 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
693 |
double recorte = Double.parseDouble(ebcPanel.getCheckSliderText().getTextValue())/100; |
694 |
if(ebcPanel.getJCheckBox().isSelected())
|
695 |
stackManager.addTailFilter(recorte, 0D, true); |
696 |
else
|
697 |
stackManager.addTailFilter(recorte, 0D, false); |
698 |
}else{
|
699 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
700 |
stackManager.addComputeMinMaxFilter(); |
701 |
} |
702 |
|
703 |
} |
704 |
// Sin filtro lineal seleccionado
|
705 |
if(!ebcPanel.getCEnhanced().isSelected()){
|
706 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
707 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
708 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
709 |
} |
710 |
fLayer.getFMap().invalidate(); |
711 |
} |
712 |
|
713 |
/**
|
714 |
* Gestiona la acci?n cuando se pulsa aplicar/aceptar o aplicar en el control
|
715 |
* de propiedades de raster
|
716 |
* @param e
|
717 |
*/
|
718 |
public void acceptButtonActionPerformed(ActionEvent e) { |
719 |
this.processBandPanel();
|
720 |
this.processTransparencyPanel();
|
721 |
this.processBrightnessContrastPanel();
|
722 |
this.processEnhancedPanel();
|
723 |
|
724 |
//Pasamos por todos los tabs registrados ejecutando su actionPerformed
|
725 |
for(int i=0;i<super.getTab().getTabCount() ;i++){ |
726 |
JPanel p = (JPanel)super.getTab().getComponentAt(i); |
727 |
if(p instanceof IRasterPropertiesRegistrable) |
728 |
((IRasterPropertiesRegistrable)p).actionPerformed(stackManager, this, fLayer);
|
729 |
} |
730 |
} |
731 |
|
732 |
/**
|
733 |
* A?ade una banda al raster
|
734 |
* @param e
|
735 |
*/
|
736 |
private void addFileBand(ActionEvent e){ |
737 |
String[] driverNames = null; |
738 |
|
739 |
//Creaci?n del dialogo para selecci?n de ficheros
|
740 |
|
741 |
fileChooser = new JFileChooser(lastPath); |
742 |
fileChooser.setMultiSelectionEnabled(true);
|
743 |
fileChooser.setAcceptAllFileFilterUsed(false);
|
744 |
try {
|
745 |
driverNames = LayerFactory.getDM().getDriverNames(); |
746 |
FileFilter auxF;
|
747 |
for (int i = 0; i < driverNames.length; i++) { |
748 |
|
749 |
if (driverNames[i].endsWith("gvSIG Image Driver")){ |
750 |
auxF = new DriverFileFilter(driverNames[i]);
|
751 |
fileChooser.addChoosableFileFilter(auxF); |
752 |
} |
753 |
} |
754 |
} catch (DriverLoadException e1) {
|
755 |
NotificationManager.addError("No se pudo acceder a los drivers", e1);
|
756 |
} |
757 |
int result = fileChooser.showOpenDialog(PropertiesRasterDialog.this);
|
758 |
|
759 |
if(result == JFileChooser.APPROVE_OPTION){ |
760 |
File[] files = fileChooser.getSelectedFiles(); |
761 |
|
762 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
763 |
lastPath = files[0].getPath();
|
764 |
|
765 |
//Lo a?adimos a la capa si no esta
|
766 |
|
767 |
Vector v = new Vector(); |
768 |
for(int i=0;i<files.length;i++){ |
769 |
|
770 |
//Comprobamos que el fichero no est?
|
771 |
boolean exist = false; |
772 |
for(int j=0;j<fLayer.getSource().getFiles().length;j++){ |
773 |
if(fLayer.getSource().getFiles()[j].getName().endsWith(files[i].getName()))
|
774 |
exist = true;
|
775 |
} |
776 |
if(!exist){
|
777 |
try{
|
778 |
Rectangle2D extentOrigin = fLayer.getFullExtent();
|
779 |
|
780 |
GeoRasterFile geoRasterFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()); |
781 |
Extent extentNewFile = geoRasterFile.getExtent(); |
782 |
nbands += geoRasterFile.getBandCount(); |
783 |
|
784 |
//Comprobamos que el extent y tama?o del fichero a?adido sea igual al
|
785 |
//fichero original. Si no es as? no abrimos la capa y mostramos un aviso
|
786 |
|
787 |
double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
|
788 |
double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
|
789 |
|
790 |
if( (widthNewFile-extentOrigin.getWidth()) > 1.0 || |
791 |
(widthNewFile-extentOrigin.getWidth()) < -1.0 ||
|
792 |
(heightNewFile-extentOrigin.getHeight()) > 1.0 ||
|
793 |
(heightNewFile-extentOrigin.getHeight()) < -1.0){
|
794 |
JOptionPane.showMessageDialog( null, |
795 |
PluginServices.getText(this, "extents_no_coincidentes"), |
796 |
"",
|
797 |
JOptionPane.ERROR_MESSAGE);
|
798 |
return;
|
799 |
} |
800 |
|
801 |
if( (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
|
802 |
(extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight() ){ |
803 |
JOptionPane.showMessageDialog(null, |
804 |
PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE); |
805 |
return;
|
806 |
} |
807 |
|
808 |
}catch(Exception exc){ |
809 |
exc.printStackTrace(); |
810 |
} |
811 |
|
812 |
//Lo a?adimos a la capa
|
813 |
fLayer.addFiles(files[i].getAbsolutePath()); |
814 |
//Mantiene la lista de ficheros a?adidos por si se cancela
|
815 |
status.addFile(files[i].getAbsolutePath()); |
816 |
|
817 |
|
818 |
}else{
|
819 |
JOptionPane.showMessageDialog(null, |
820 |
PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
821 |
} |
822 |
} |
823 |
|
824 |
//A?adimos los georasterfile a la tabla del Panel
|
825 |
|
826 |
v = new Vector(); |
827 |
Vector vInfo = new Vector(); |
828 |
for(int i=0;i<fLayer.getSource().getFiles().length;i++){ |
829 |
boolean exist = false; |
830 |
for(int j=0;j<bandSetup.getNBands();j++){ |
831 |
if(fLayer.getSource().getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
|
832 |
exist = true;
|
833 |
} |
834 |
if(!exist)
|
835 |
v.add(fLayer.getSource().getFiles()[i]); |
836 |
vInfo.add(fLayer.getSource().getFiles()[i]); |
837 |
} |
838 |
|
839 |
grf = new GeoRasterFile[v.size()];
|
840 |
for(int i=0;i<grf.length;i++){ |
841 |
grf[i] = (GeoRasterFile)v.get(i); |
842 |
} |
843 |
GeoRasterFile[] infoGrf = new GeoRasterFile[vInfo.size()]; |
844 |
for(int i = 0; i<infoGrf.length ; i++){ |
845 |
infoGrf[i] = (GeoRasterFile)vInfo.get(i); |
846 |
} |
847 |
|
848 |
this.addFiles(grf);
|
849 |
this.addInfoFiles(infoGrf);
|
850 |
} |
851 |
} |
852 |
|
853 |
/**
|
854 |
* Asigna la lista de GeoRasterFile
|
855 |
* @return
|
856 |
*/
|
857 |
public void setGeoRasterFile(GeoRasterFile[] grf){ |
858 |
this.grf = grf;
|
859 |
} |
860 |
|
861 |
/**
|
862 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha
|
863 |
* seleccionado ninguna banda no hace nada.
|
864 |
* @param e
|
865 |
*/
|
866 |
private void delFileBand(ActionEvent e){ |
867 |
BandSetupPanel bandSetup = (BandSetupPanel)super.getPanelByClassName("BandSetupPanel"); |
868 |
|
869 |
if( bandSetup.getFileList().getJList().getSelectedValue()!=null && |
870 |
bandSetup.getFileList().getNFiles() > 1){
|
871 |
String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
|
872 |
GeoRasterFile geoRasterFile = GeoRasterFile.openFile(fLayer.getProjection(), pathName); |
873 |
nbands -= geoRasterFile.getBandCount(); |
874 |
fLayer.delFile(pathName); |
875 |
String file = pathName.substring(pathName.lastIndexOf("/")+1); |
876 |
file = file.substring(file.lastIndexOf("\\")+1); |
877 |
this.removeFile(file);
|
878 |
|
879 |
//Mantiene la lista de ficheros eliminados por si se cancela
|
880 |
status.removeFile(pathName); |
881 |
} |
882 |
|
883 |
Vector vInfo = new Vector(); |
884 |
for(int i=0;i<fLayer.getSource().getFiles().length;i++){ |
885 |
vInfo.add(fLayer.getSource().getFiles()[i]); |
886 |
} |
887 |
|
888 |
GeoRasterFile[] infoGrf = new GeoRasterFile[vInfo.size()]; |
889 |
for(int i = 0; i<infoGrf.length ; i++){ |
890 |
infoGrf[i] = (GeoRasterFile)vInfo.get(i); |
891 |
} |
892 |
|
893 |
this.addInfoFiles(infoGrf);
|
894 |
|
895 |
} |
896 |
|
897 |
/**
|
898 |
* El bot?n de cancelar recupera el estado anterior a la apertura de
|
899 |
* este dialogo.
|
900 |
* @param e Evento
|
901 |
*/
|
902 |
private void cancelButtonActionPerformed(ActionEvent e) { |
903 |
this.status.restoreStatus(this); |
904 |
fLayer.getFMap().invalidate(); |
905 |
} |
906 |
|
907 |
/**
|
908 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getViewInfo()
|
909 |
*/
|
910 |
public ViewInfo getViewInfo() {
|
911 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG | ViewInfo.RESIZABLE);
|
912 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
913 |
return m_viewinfo;
|
914 |
} |
915 |
|
916 |
/**
|
917 |
* Devuelve el stackManager que se esta utilizando actualmente.
|
918 |
* @return stackManager.
|
919 |
*/
|
920 |
public RasterFilterStackManager getStackManager(){
|
921 |
return this.stackManager; |
922 |
} |
923 |
|
924 |
/**
|
925 |
* Devuelve el layer que se est? utilizando actualmente
|
926 |
* @return FLyrRaster actual.
|
927 |
*/
|
928 |
public FLyrRaster getFLyrRaster(){
|
929 |
return this.fLayer; |
930 |
} |
931 |
|
932 |
//********************************************************************
|
933 |
//***********************EVENTOS DE RAT?N*****************************
|
934 |
|
935 |
public void mouseClicked(MouseEvent e) { |
936 |
// TODO Auto-generated method stub
|
937 |
|
938 |
} |
939 |
|
940 |
public void mouseEntered(MouseEvent e) { |
941 |
// TODO Auto-generated method stub
|
942 |
|
943 |
} |
944 |
|
945 |
public void mouseExited(MouseEvent e) { |
946 |
// TODO Auto-generated method stub
|
947 |
|
948 |
} |
949 |
|
950 |
public void mousePressed(MouseEvent e) { |
951 |
// TODO Auto-generated method stub
|
952 |
|
953 |
} |
954 |
|
955 |
public void mouseReleased(MouseEvent e) { |
956 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
957 |
if (((e.getSource() == ebcPanel.lstBrightness.getJSlider()) || (e.getSource() == ebcPanel.lstContrast.getJSlider())) &&
|
958 |
(ebcPanel.getJCheckBox1().isSelected() == true))
|
959 |
processBrightnessContrastPanel(); |
960 |
} |
961 |
|
962 |
/*public void keyPressed(KeyEvent e) {
|
963 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel");
|
964 |
if(e.getSource() == ebcPanel.getCheckSliderText().getJTextField()){
|
965 |
ebcPanel.getCheckSliderText().getJSlider().setValue((int) Math.round(Double.valueOf(ebcPanel.getCheckSliderText().getTextValue()).doubleValue()));
|
966 |
}
|
967 |
|
968 |
}
|
969 |
|
970 |
public void keyReleased(KeyEvent e) {
|
971 |
// TODO Auto-generated method stub
|
972 |
|
973 |
}
|
974 |
|
975 |
public void keyTyped(KeyEvent e) {
|
976 |
// TODO Auto-generated method stub
|
977 |
|
978 |
}*/
|
979 |
|
980 |
public void brightnessContrastPreview(Event e){ |
981 |
|
982 |
} |
983 |
|
984 |
public void actionPerformed(ActionEvent e){ |
985 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
986 |
|
987 |
ebcPanel.getLabelSliderText().actionPerformed(e); |
988 |
ebcPanel.getLabelSliderText1().actionPerformed(e); |
989 |
|
990 |
if((e.getSource() == ebcPanel.getLabelSliderText().getJTextField()))
|
991 |
if(ebcPanel.getJCheckBox1().isSelected()){
|
992 |
int valor = Math.round(Float.parseFloat(ebcPanel.getLabelSliderText().getJTextField().getText())); |
993 |
if((valor > ebcPanel.getLabelSliderText().getJSlider().getMaximum()))
|
994 |
ebcPanel.getLabelSliderText().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMaximum()));
|
995 |
if((valor < ebcPanel.getLabelSliderText().getJSlider().getMinimum()))
|
996 |
ebcPanel.getLabelSliderText().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMinimum()));
|
997 |
processBrightnessContrastPanel(); |
998 |
} |
999 |
|
1000 |
if((e.getSource() == ebcPanel.getLabelSliderText1().getJTextField()))
|
1001 |
if(ebcPanel.getJCheckBox1().isSelected()){
|
1002 |
int valor1 = Math.round(Float.parseFloat(ebcPanel.getLabelSliderText1().getJTextField().getText())); |
1003 |
if((valor1 > ebcPanel.getLabelSliderText1().getJSlider().getMaximum()))
|
1004 |
ebcPanel.getLabelSliderText1().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMaximum()));
|
1005 |
if((valor1 < ebcPanel.getLabelSliderText1().getJSlider().getMinimum()))
|
1006 |
ebcPanel.getLabelSliderText1().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMinimum()));
|
1007 |
processBrightnessContrastPanel(); |
1008 |
} |
1009 |
} |
1010 |
|
1011 |
public void focusLost(FocusEvent e) { |
1012 |
EnhancedBrightnessContrastPanel ebcPanel = (EnhancedBrightnessContrastPanel)super.getPanelByClassName("EnhancedBrightnessContrastPanel"); |
1013 |
|
1014 |
if((e.getSource() == ebcPanel.getLabelSliderText().getJTextField()))
|
1015 |
if(ebcPanel.getJCheckBox1().isSelected()){
|
1016 |
int valor = Math.round(Float.parseFloat(ebcPanel.getLabelSliderText().getJTextField().getText())); |
1017 |
if((valor > ebcPanel.getLabelSliderText().getJSlider().getMaximum()))
|
1018 |
ebcPanel.getLabelSliderText().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMaximum()));
|
1019 |
if((valor < ebcPanel.getLabelSliderText().getJSlider().getMinimum()))
|
1020 |
ebcPanel.getLabelSliderText().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMinimum()));
|
1021 |
processBrightnessContrastPanel(); |
1022 |
} |
1023 |
|
1024 |
if((e.getSource() == ebcPanel.getLabelSliderText1().getJTextField()))
|
1025 |
if(ebcPanel.getJCheckBox1().isSelected()){
|
1026 |
int valor1 = Math.round(Float.parseFloat(ebcPanel.getLabelSliderText1().getJTextField().getText())); |
1027 |
if((valor1 > ebcPanel.getLabelSliderText1().getJSlider().getMaximum()))
|
1028 |
ebcPanel.getLabelSliderText1().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMaximum()));
|
1029 |
if((valor1 < ebcPanel.getLabelSliderText1().getJSlider().getMinimum()))
|
1030 |
ebcPanel.getLabelSliderText1().getJTextField().setText(String.valueOf(ebcPanel.getLabelSliderText().getJSlider().getMinimum()));
|
1031 |
processBrightnessContrastPanel(); |
1032 |
} |
1033 |
super.focusLost(e);
|
1034 |
} |
1035 |
|
1036 |
} |
1037 |
|