root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / Panels / PropertiesWCSDialog.java @ 2048
History | View | Annotate | Download (18.8 KB)
1 |
/*
|
---|---|
2 |
* Creado el 7-marzo-2005
|
3 |
*/
|
4 |
package com.iver.cit.gvsig.gui.Panels; |
5 |
|
6 |
import java.awt.Container; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.geom.Rectangle2D; |
9 |
import java.io.File; |
10 |
import java.util.ArrayList; |
11 |
import java.util.Vector; |
12 |
|
13 |
import javax.swing.JFileChooser; |
14 |
import javax.swing.JOptionPane; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.filechooser.FileFilter; |
17 |
|
18 |
import org.cresques.cts.IProjection; |
19 |
import org.cresques.io.GeoRasterFile; |
20 |
import org.cresques.io.raster.RasterFilterStackManager; |
21 |
import org.cresques.px.Extent; |
22 |
import org.cresques.px.PxRaster; |
23 |
import org.cresques.ui.raster.BandSetupPanel; |
24 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
25 |
|
26 |
import com.hardcode.driverManager.Driver; |
27 |
import com.hardcode.driverManager.DriverLoadException; |
28 |
import com.iver.andami.PluginServices; |
29 |
import com.iver.andami.messages.NotificationManager; |
30 |
import com.iver.andami.ui.mdiManager.View; |
31 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
32 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
33 |
import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
34 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
35 |
|
36 |
/**
|
37 |
* <P>
|
38 |
* Dialogo para las propiedades de una capa wcs. Esta maneja los eventos y aplica
|
39 |
* filtros sobre el raster a trav?s de l gestor de la pila de filtros seg?n la
|
40 |
* selecci?n del usuario. Este dialogo contiene varios paneles:
|
41 |
* </P>
|
42 |
* <UL>
|
43 |
* <LI>Propiedades</LI>
|
44 |
* <LI>Selecci?n de bandas</LI>
|
45 |
* <LI>Transparencia</LI>
|
46 |
* <LI>Realce</LI>
|
47 |
* </UL>
|
48 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
49 |
*/
|
50 |
public class PropertiesWCSDialog extends FilterRasterDialogPanel implements View { |
51 |
|
52 |
private FilterRasterDialogPanel contentPane = null; |
53 |
private JPanel propPanel = null; |
54 |
private IProjection currentProjection = null; |
55 |
private FLyrWCS fLayer = null; |
56 |
private static final int nprops = 11; |
57 |
private Object[][] props = null; |
58 |
private RasterFilterStackManager stackManager = null; |
59 |
private Status status = null; |
60 |
private JFileChooser fileChooser = null; |
61 |
private String lastPath = new String("./"); |
62 |
private PxRaster px = null; |
63 |
private GeoRasterFile grf = null; |
64 |
|
65 |
/**
|
66 |
* Clase que guarda el estado del dialogo y gestiona la restauraci?n
|
67 |
* del estado inicial en caso de cancelar.
|
68 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
69 |
*/
|
70 |
class Status{ |
71 |
public String inicAlpha; |
72 |
public int bandR; |
73 |
public int bandG; |
74 |
public int bandB; |
75 |
private ArrayList files = new ArrayList(); |
76 |
|
77 |
public Status(String alpha, int bandR, int bandG, int bandB){ |
78 |
this.inicAlpha = alpha;
|
79 |
this.bandR = bandR;
|
80 |
this.bandG = bandG;
|
81 |
this.bandB = bandB;
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* A?ade un fichero a la lista
|
86 |
* @param file
|
87 |
*/
|
88 |
public void addFile(String file){ |
89 |
files.add(file); |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Elimina un fichero de la lista
|
94 |
* @param file
|
95 |
*/
|
96 |
public void removeFile(String file){ |
97 |
for(int i=0;i<files.size();i++){ |
98 |
if(((String)files.get(i)).equals(file)) |
99 |
files.remove(i); |
100 |
} |
101 |
} |
102 |
|
103 |
/**
|
104 |
*
|
105 |
* @param i
|
106 |
* @return
|
107 |
*/
|
108 |
public String getFile(int i){ |
109 |
return ((String)files.get(i)); |
110 |
} |
111 |
|
112 |
public int getNFiles(){ |
113 |
return files.size();
|
114 |
} |
115 |
|
116 |
/**
|
117 |
* Restaura el Estado salvado
|
118 |
* @param status Estado
|
119 |
*/
|
120 |
public void restoreStatus(PropertiesWCSDialog props){ |
121 |
//Devolvemos la pila de filtros al estado inicial
|
122 |
if(stackManager != null) |
123 |
stackManager.deleteTempFilters(); |
124 |
|
125 |
//Devolvemos el alpha al estado inicial
|
126 |
int opac = Integer.parseInt(status.inicAlpha); |
127 |
opac = (int)((opac*255)/100); |
128 |
px.setTransparency(true);
|
129 |
fLayer.setTransparency(255-opac);
|
130 |
|
131 |
if (fLayer != null) { |
132 |
px.setBand(GeoRasterFile.RED_BAND, status.bandR); |
133 |
px.setBand(GeoRasterFile.GREEN_BAND, status.bandG); |
134 |
px.setBand(GeoRasterFile.GREEN_BAND, status.bandB); |
135 |
} |
136 |
|
137 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)props.getContentPane()).getBandSetup(); |
138 |
for(int i=0;i<status.getNFiles();i++){ |
139 |
px.delFile(status.getFile(i)); |
140 |
String file = status.getFile(i).substring(status.getFile(i).lastIndexOf("/")+1); |
141 |
file = file.substring(file.lastIndexOf("\\")+1); |
142 |
bandSetup.removeFile(file); |
143 |
} |
144 |
fLayer.getFMap().invalidate(); |
145 |
|
146 |
} |
147 |
} |
148 |
|
149 |
public class DriverFileFilter extends FileFilter{ |
150 |
|
151 |
private Driver driver; |
152 |
|
153 |
public DriverFileFilter(String driverName) throws DriverLoadException{ |
154 |
driver = LayerFactory.getDM().getDriver(driverName); |
155 |
} |
156 |
|
157 |
/**
|
158 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
|
159 |
*/
|
160 |
public boolean accept(File f) { |
161 |
if (f.isDirectory()) return true; |
162 |
if (driver instanceof RasterDriver){ |
163 |
return ((RasterDriver) driver).fileAccepted(f);
|
164 |
}else{
|
165 |
throw new RuntimeException("Tipo no reconocido"); |
166 |
} |
167 |
} |
168 |
|
169 |
/**
|
170 |
* @see javax.swing.filechooser.FileFilter#getDescription()
|
171 |
*/
|
172 |
public String getDescription() { |
173 |
return ((Driver) driver).getName(); |
174 |
} |
175 |
} |
176 |
|
177 |
/**
|
178 |
* Constructor de la ventana de dialogo.
|
179 |
* @param app
|
180 |
*/
|
181 |
public PropertiesWCSDialog(FLyrWCS layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){ |
182 |
super();
|
183 |
fLayer = layer; |
184 |
this.px = layer.getWCSAdaptor().getPxRaster();
|
185 |
this.grf = layer.getWCSAdaptor().getGeoRasterFile();
|
186 |
initialize(); |
187 |
this.setRanges(rangeR, rangeG, rangeB);
|
188 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
189 |
fr.getBandSetup().getFileList().getJButton2().setEnabled(false);
|
190 |
fr.getBandSetup().getFileList().getJButton3().setEnabled(false);
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* Asigna un FLayerRaster
|
195 |
* @param layer capa a asignar
|
196 |
*/
|
197 |
public void setFLyrWCS(FLyrWCS layer){ |
198 |
fLayer = layer; |
199 |
} |
200 |
|
201 |
/**
|
202 |
* Constructor de la ventana de dialogo.
|
203 |
*/
|
204 |
public PropertiesWCSDialog() {
|
205 |
initialize(); |
206 |
} |
207 |
|
208 |
|
209 |
|
210 |
/**
|
211 |
* Carga los datos del panel info.
|
212 |
*/
|
213 |
private void loadInfoData(){ |
214 |
if(fLayer.getWCSAdaptor()!=null){ |
215 |
props = new Object[nprops][2]; |
216 |
props[0][0] = new String("Fichero: "); |
217 |
props[0][1] = grf.getName(); |
218 |
props[1][0] = new String("N?mero de Bandas: "); |
219 |
props[1][1] = new String(String.valueOf( grf.getBandCount())); |
220 |
props[2][0] = new String("Ancho X Alto: "); |
221 |
props[2][1] = grf.getWidth()+" X "+grf.getHeight(); |
222 |
props[3][0] = new String("Formato: "); |
223 |
props[3][1] = grf.getName().substring( |
224 |
grf.getName().lastIndexOf('.')+1, |
225 |
grf.getName().length()); |
226 |
props[4][0] = new String("Tipo de dato: "); |
227 |
String type = null; |
228 |
switch(grf.getDataType()){
|
229 |
case 0: type = new String("BYTE");break; |
230 |
case 1: type = new String("USHORT");break; |
231 |
case 2: type = new String("SHORT");break; |
232 |
case 3: type = new String("INT");break; |
233 |
case 4: type = new String("FLOAT");break; |
234 |
case 5: type = new String("DOUBLE");break; |
235 |
default: type = new String("UNDEFINED");break; |
236 |
} |
237 |
props[4][1] = type; |
238 |
props[5][0] = new String("Coor. Geograficas"); |
239 |
props[6][0] = new String(" - X m?nima:"); |
240 |
props[6][1] = String.valueOf(px.getExtent().minX()); |
241 |
props[7][0] = new String(" - Y m?nima:"); |
242 |
props[7][1] = String.valueOf(px.getExtent().minY()); |
243 |
props[8][0] = new String(" - X m?xima:"); |
244 |
props[8][1] = String.valueOf(px.getExtent().maxX()); |
245 |
props[9][0] = new String(" - Y m?xima:"); |
246 |
props[9][1] = String.valueOf(px.getExtent().maxY()); |
247 |
|
248 |
}else{
|
249 |
props = new Object[1][2]; |
250 |
props[0][0] = new String("No props"); |
251 |
props[0][1] = new String("-"); |
252 |
} |
253 |
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Inicializa el jDialog
|
258 |
*/
|
259 |
private void initialize() { |
260 |
|
261 |
//this.setLayout(new FlowLayout());
|
262 |
|
263 |
setName("filterRaster");
|
264 |
|
265 |
this.loadInfoData();
|
266 |
super.init(props);
|
267 |
//this.add(getContentPane());
|
268 |
|
269 |
this.setSize(386, 268); |
270 |
|
271 |
//contentPane.getAcceptButton().setEnabled(false);
|
272 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
273 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
274 |
acceptButtonActionPerformed(evt); |
275 |
closeJDialog(); |
276 |
} |
277 |
}); |
278 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
279 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
280 |
cancelButtonActionPerformed(evt); |
281 |
closeJDialog(); |
282 |
} |
283 |
}); |
284 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
285 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
286 |
acceptButtonActionPerformed(evt); |
287 |
} |
288 |
}); |
289 |
this.getBandSetup().getFileList().getJButton2().addActionListener(new java.awt.event.ActionListener() { |
290 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
291 |
addFileBand(evt); |
292 |
|
293 |
} |
294 |
}); |
295 |
this.getBandSetup().getFileList().getJButton3().addActionListener(new java.awt.event.ActionListener() { |
296 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
297 |
delFileBand(evt); |
298 |
} |
299 |
}); |
300 |
|
301 |
|
302 |
} |
303 |
|
304 |
/**
|
305 |
* Salva el estado inicial por si se cancela
|
306 |
*/
|
307 |
public void readStat(){ |
308 |
status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(), |
309 |
getAssignedBand(GeoRasterFile.RED_BAND), |
310 |
getAssignedBand(GeoRasterFile.GREEN_BAND), |
311 |
getAssignedBand(GeoRasterFile.BLUE_BAND) |
312 |
); |
313 |
} |
314 |
|
315 |
/**
|
316 |
* This method initializes jContentPane
|
317 |
*/
|
318 |
public Container getContentPane() { |
319 |
return this; |
320 |
} |
321 |
|
322 |
/**
|
323 |
* Asigna una proyecci?n
|
324 |
* @param prj
|
325 |
*/
|
326 |
public void setProjection(IProjection prj) { |
327 |
this.currentProjection = prj;
|
328 |
} |
329 |
|
330 |
|
331 |
|
332 |
public void closeJDialog() { |
333 |
PluginServices.getMDIManager().closeView(PropertiesWCSDialog.this); |
334 |
} |
335 |
|
336 |
/**
|
337 |
* Asigna el RasterFilterStackManager
|
338 |
* @param stackManager
|
339 |
*/
|
340 |
public void setRasterFilterStackManager(RasterFilterStackManager stackManager){ |
341 |
this.stackManager = stackManager;
|
342 |
stackManager.resetTempFilters(); |
343 |
} |
344 |
|
345 |
/**
|
346 |
*
|
347 |
* @param flag
|
348 |
* @return
|
349 |
*/
|
350 |
public int getAssignedBand(int flag) { |
351 |
return this.getBandSetup().getAssignedBand(flag); |
352 |
} |
353 |
|
354 |
/**
|
355 |
* Pulsar aceptar con el panel de bandas seleccionado hace que se procesen los valores
|
356 |
* introducidos en este.
|
357 |
* @return true si estaba seleccionado el panel de bandas y se ha procesado la
|
358 |
* acci?n y false si no lo estaba.
|
359 |
*/
|
360 |
public boolean processBandPanel(){ |
361 |
if(this.getTab().getSelectedComponent() == this.getBandSetup()){ |
362 |
|
363 |
fLayer.getWCSAdaptor().setBandR(getAssignedBand(GeoRasterFile.RED_BAND)); |
364 |
fLayer.getWCSAdaptor().setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND)); |
365 |
fLayer.getWCSAdaptor().setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND)); |
366 |
|
367 |
fLayer.getFMap().invalidate(); |
368 |
return true; |
369 |
} |
370 |
return false; |
371 |
} |
372 |
|
373 |
/**
|
374 |
* Pulsar aceptar con el panel de transparecias seleccionado hace que se procesen los valores
|
375 |
* introducidos en este.
|
376 |
* @return true si estaba seleccionado el panel de transparencias y se ha procesado la
|
377 |
* acci?n y false si no lo estaba.
|
378 |
*/
|
379 |
public boolean processTransparencyPanel(){ |
380 |
|
381 |
if(this.getTab().getSelectedComponent() == this.getTransparencyPanel()){ |
382 |
|
383 |
//OPACIDAD
|
384 |
String sOpac = this.getTransparencyPanel().getOpacityText().getText(); |
385 |
if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){ |
386 |
int opac = Integer.parseInt(sOpac); |
387 |
opac = (int)((opac*255)/100); |
388 |
px.setTransparency(true);
|
389 |
//px.setTransparency(255-opac);
|
390 |
fLayer.getWCSAdaptor().setTransparency(255-opac);
|
391 |
}else{
|
392 |
px.setTransparency(false);
|
393 |
fLayer.getWCSAdaptor().setTransparency(0);
|
394 |
} |
395 |
|
396 |
//TRANSPARENCIA
|
397 |
if( this.getTransparencyPanel().getTransparencyCheck().isSelected()){ |
398 |
this.checkTransparencyValues();
|
399 |
stackManager.addTransparencyFilter( this.getRangeRed(),
|
400 |
this.getRangeGreen(),
|
401 |
this.getRangeBlue(),
|
402 |
0x10, //Transparencia |
403 |
0xff, //Color Transparencia R |
404 |
0xff, //Color Transparencia G |
405 |
0xff); //Color Transparencia B |
406 |
}else
|
407 |
px.filterStack.removeFilter(stackManager.getTypeFilter("transparency"));
|
408 |
|
409 |
fLayer.getFMap().invalidate(); |
410 |
return true; |
411 |
} |
412 |
|
413 |
return false; |
414 |
} |
415 |
|
416 |
/**
|
417 |
* Pulsar aceptar con el panel de realce seleccionado hace que se procesen los valores
|
418 |
* introducidos en este.
|
419 |
* @return true si estaba seleccionado el panel de realce y se ha procesado la
|
420 |
* acci?n y false si no lo estaba.
|
421 |
*/
|
422 |
public boolean processEnhancedPanel(){ |
423 |
if(this.getTab().getSelectedComponent() == this.getEnhancedPanel()){ |
424 |
|
425 |
//Filtro lineal seleccionado
|
426 |
if( this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){ |
427 |
stackManager.addEnhancedFilter(); |
428 |
|
429 |
if(this.getEnhancedPanel().getTailCheck().isSelected()){ |
430 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
431 |
stackManager.addTailFilter( Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100,0D); |
432 |
}else{
|
433 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
434 |
stackManager.addComputeMinMaxFilter(); |
435 |
} |
436 |
} |
437 |
|
438 |
//Sin filtro lineal seleccionado
|
439 |
if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){ |
440 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
441 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
442 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
443 |
} |
444 |
fLayer.getFMap().invalidate(); |
445 |
|
446 |
return true; |
447 |
} |
448 |
return false; |
449 |
} |
450 |
|
451 |
/**
|
452 |
* Gestiona la acci?n cuando se pulsa aplicar/aceptar o aplicar en el control
|
453 |
* de propiedades de raster
|
454 |
* @param e
|
455 |
*/
|
456 |
private void acceptButtonActionPerformed(ActionEvent e) { |
457 |
this.processBandPanel();
|
458 |
this.processTransparencyPanel();
|
459 |
this.processEnhancedPanel();
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* A?ade una banda al raster
|
464 |
* @param e
|
465 |
*/
|
466 |
private void addFileBand(ActionEvent e){ |
467 |
String[] driverNames = null; |
468 |
String rasterDriver = null; |
469 |
|
470 |
//Creaci?n del dialogo para selecci?n de ficheros
|
471 |
|
472 |
fileChooser = new JFileChooser(lastPath); |
473 |
fileChooser.setMultiSelectionEnabled(true);
|
474 |
fileChooser.setAcceptAllFileFilterUsed(false);
|
475 |
try {
|
476 |
driverNames = LayerFactory.getDM().getDriverNames(); |
477 |
FileFilter defaultFileFilter = null, auxF; |
478 |
for (int i = 0; i < driverNames.length; i++) { |
479 |
|
480 |
if (driverNames[i].endsWith("gvSIG Image Driver")){ |
481 |
rasterDriver = driverNames[i]; |
482 |
auxF = new DriverFileFilter(driverNames[i]);
|
483 |
fileChooser.addChoosableFileFilter(auxF); |
484 |
defaultFileFilter = auxF; |
485 |
} |
486 |
} |
487 |
} catch (DriverLoadException e1) {
|
488 |
NotificationManager.addError("No se pudo acceder a los drivers", e1);
|
489 |
} |
490 |
int result = fileChooser.showOpenDialog(PropertiesWCSDialog.this);
|
491 |
|
492 |
if(result == JFileChooser.APPROVE_OPTION){ |
493 |
File[] files = fileChooser.getSelectedFiles(); |
494 |
FileFilter filter = fileChooser.getFileFilter();
|
495 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
|
496 |
lastPath = files[0].getPath();
|
497 |
|
498 |
//Lo a?adimos a la capa si no esta
|
499 |
|
500 |
Vector v = new Vector(); |
501 |
for(int i=0;i<files.length;i++){ |
502 |
boolean exist = false; |
503 |
for(int j=0;j<px.getFiles().length;j++){ |
504 |
if(px.getFiles()[j].getName().endsWith(files[i].getName()))
|
505 |
exist = true;
|
506 |
} |
507 |
if(!exist){
|
508 |
try{
|
509 |
Rectangle2D extentOrigin = fLayer.getFullExtent();
|
510 |
|
511 |
Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent(); |
512 |
|
513 |
//Comprobamos que el extent y tama?o del fichero a?adido sea igual al
|
514 |
//fichero original. Si no es as? no abrimos la capa y mostramos un aviso
|
515 |
|
516 |
double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
|
517 |
double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
|
518 |
|
519 |
if( (widthNewFile-extentOrigin.getWidth()) > 1.0 || |
520 |
(widthNewFile-extentOrigin.getWidth()) < -1.0 ||
|
521 |
(heightNewFile-extentOrigin.getHeight()) > 1.0 ||
|
522 |
(heightNewFile-extentOrigin.getHeight()) < -1.0){
|
523 |
JOptionPane.showMessageDialog( null, |
524 |
PluginServices.getText(this, "extents_no_coincidentes"), |
525 |
"",
|
526 |
JOptionPane.ERROR_MESSAGE);
|
527 |
return;
|
528 |
} |
529 |
|
530 |
if( (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
|
531 |
(extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight() ){ |
532 |
JOptionPane.showMessageDialog(null, |
533 |
PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE); |
534 |
return;
|
535 |
} |
536 |
|
537 |
}catch(Exception exc){ |
538 |
exc.printStackTrace(); |
539 |
} |
540 |
|
541 |
//Lo a?adimos a la capa
|
542 |
px.addFile(files[i].getAbsolutePath()); |
543 |
//Mantiene la lista de ficheros a?adidos por si se cancela
|
544 |
status.addFile(files[i].getAbsolutePath()); |
545 |
}else{
|
546 |
JOptionPane.showMessageDialog(null, |
547 |
PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
548 |
} |
549 |
} |
550 |
|
551 |
//A?adimos los georasterfile a la tabla del Panel
|
552 |
|
553 |
v = new Vector(); |
554 |
for(int i=0;i<px.getFiles().length;i++){ |
555 |
boolean exist = false; |
556 |
for(int j=0;j<bandSetup.getNBands();j++){ |
557 |
if(px.getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
|
558 |
exist = true;
|
559 |
} |
560 |
if(!exist)
|
561 |
v.add(px.getFiles()[i]); |
562 |
} |
563 |
|
564 |
GeoRasterFile[] grf = new GeoRasterFile[v.size()]; |
565 |
for(int i=0;i<grf.length;i++){ |
566 |
grf[i] = (GeoRasterFile)v.get(i); |
567 |
} |
568 |
bandSetup.addFiles(grf); |
569 |
} |
570 |
} |
571 |
|
572 |
/**
|
573 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha
|
574 |
* seleccionado ninguna banda no hace nada.
|
575 |
* @param e
|
576 |
*/
|
577 |
private void delFileBand(ActionEvent e){ |
578 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
|
579 |
|
580 |
if( bandSetup.getFileList().getJList().getSelectedValue()!=null && |
581 |
bandSetup.getFileList().getNFiles() > 1){
|
582 |
String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
|
583 |
px.delFile(pathName); |
584 |
String file = pathName.substring(pathName.lastIndexOf("/")+1); |
585 |
file = file.substring(file.lastIndexOf("\\")+1); |
586 |
bandSetup.removeFile(file); |
587 |
|
588 |
//Mantiene la lista de ficheros eliminados por si se cancela
|
589 |
status.removeFile(pathName); |
590 |
} |
591 |
} |
592 |
|
593 |
/**
|
594 |
* El bot?n de cancelar recupera el estado anterior a la apertura de
|
595 |
* este dialogo.
|
596 |
* @param e Evento
|
597 |
*/
|
598 |
private void cancelButtonActionPerformed(ActionEvent e) { |
599 |
this.status.restoreStatus(this); |
600 |
fLayer.getFMap().invalidate(); |
601 |
} |
602 |
|
603 |
/**
|
604 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
605 |
*/
|
606 |
public ViewInfo getViewInfo() {
|
607 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
608 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
609 |
return m_viewinfo;
|
610 |
} |
611 |
|
612 |
|
613 |
} |