root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / Panels / PropertiesWCSDialog.java @ 2147
History | View | Annotate | Download (19 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 |
* Dialog for the properties of a WCS layer. It manages the avants and aplies
|
39 |
* filters to the raster through the filter stack manager according to the user's
|
40 |
* selection. This dialog contains some panels.
|
41 |
* </P>
|
42 |
* <UL>
|
43 |
* <LI>Propierties</LI>
|
44 |
* <LI>Band selection</LI>
|
45 |
* <LI>Transparency</LI>
|
46 |
* <LI>Enhancement</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 |
* Class that holds the dialog state and restores the initial state if it
|
67 |
* is cancelled.
|
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 |
* Dialog window constructor.
|
179 |
*
|
180 |
* @param app
|
181 |
*/
|
182 |
public PropertiesWCSDialog(FLyrWCS layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){ |
183 |
super();
|
184 |
fLayer = layer; |
185 |
this.px = layer.getWCSAdaptor().getPxRaster();
|
186 |
this.grf = layer.getWCSAdaptor().getGeoRasterFile();
|
187 |
initialize(); |
188 |
this.setRanges(rangeR, rangeG, rangeB);
|
189 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
|
190 |
fr.getBandSetup().getFileList().getJButton2().setEnabled(false);
|
191 |
fr.getBandSetup().getFileList().getJButton3().setEnabled(false);
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* Assigns a FLayerRaster
|
196 |
* @param layer capa a asignar
|
197 |
*/
|
198 |
public void setFLyrWCS(FLyrWCS layer){ |
199 |
fLayer = layer; |
200 |
} |
201 |
|
202 |
/**
|
203 |
* Dialog window constructor.
|
204 |
*/
|
205 |
public PropertiesWCSDialog() {
|
206 |
initialize(); |
207 |
} |
208 |
|
209 |
|
210 |
|
211 |
/**
|
212 |
* Loads the info panel data.
|
213 |
*/
|
214 |
private void loadInfoData(){ |
215 |
if(fLayer.getWCSAdaptor()!=null){ |
216 |
props = new Object[nprops][2]; |
217 |
props[0][0] = new String("Fichero: "); |
218 |
props[0][1] = grf.getName(); |
219 |
props[1][0] = new String("N?mero de Bandas: "); |
220 |
props[1][1] = new String(String.valueOf( grf.getBandCount())); |
221 |
props[2][0] = new String("Ancho X Alto: "); |
222 |
props[2][1] = grf.getWidth()+" X "+grf.getHeight(); |
223 |
props[3][0] = new String("Formato: "); |
224 |
props[3][1] = grf.getName().substring( |
225 |
grf.getName().lastIndexOf('.')+1, |
226 |
grf.getName().length()); |
227 |
props[4][0] = new String("Tipo de dato: "); |
228 |
String type = null; |
229 |
switch(grf.getDataType()){
|
230 |
case 0: type = new String("BYTE");break; |
231 |
case 1: type = new String("USHORT");break; |
232 |
case 2: type = new String("SHORT");break; |
233 |
case 3: type = new String("INT");break; |
234 |
case 4: type = new String("FLOAT");break; |
235 |
case 5: type = new String("DOUBLE");break; |
236 |
default: type = new String("UNDEFINED");break; |
237 |
} |
238 |
props[4][1] = type; |
239 |
props[5][0] = new String("Coor. Geograficas"); |
240 |
props[6][0] = new String(" - X m?nima:"); |
241 |
props[6][1] = String.valueOf(px.getExtent().minX()); |
242 |
props[7][0] = new String(" - Y m?nima:"); |
243 |
props[7][1] = String.valueOf(px.getExtent().minY()); |
244 |
props[8][0] = new String(" - X m?xima:"); |
245 |
props[8][1] = String.valueOf(px.getExtent().maxX()); |
246 |
props[9][0] = new String(" - Y m?xima:"); |
247 |
props[9][1] = String.valueOf(px.getExtent().maxY()); |
248 |
|
249 |
}else{
|
250 |
props = new Object[1][2]; |
251 |
props[0][0] = new String("No props"); |
252 |
props[0][1] = new String("-"); |
253 |
} |
254 |
|
255 |
} |
256 |
|
257 |
/**
|
258 |
* Inits the jDialog
|
259 |
*/
|
260 |
private void initialize() { |
261 |
|
262 |
//this.setLayout(new FlowLayout());
|
263 |
|
264 |
setName("filterRaster");
|
265 |
|
266 |
this.loadInfoData();
|
267 |
super.init(props);
|
268 |
//this.add(getContentPane());
|
269 |
|
270 |
this.setSize(486, 318); |
271 |
|
272 |
//contentPane.getAcceptButton().setEnabled(false);
|
273 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
274 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
275 |
acceptButtonActionPerformed(evt); |
276 |
closeJDialog(); |
277 |
} |
278 |
}); |
279 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
280 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
281 |
cancelButtonActionPerformed(evt); |
282 |
closeJDialog(); |
283 |
} |
284 |
}); |
285 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
286 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
287 |
acceptButtonActionPerformed(evt); |
288 |
} |
289 |
}); |
290 |
this.getBandSetup().getFileList().getJButton2().addActionListener(new java.awt.event.ActionListener() { |
291 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
292 |
addFileBand(evt); |
293 |
|
294 |
} |
295 |
}); |
296 |
this.getBandSetup().getFileList().getJButton3().addActionListener(new java.awt.event.ActionListener() { |
297 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
298 |
delFileBand(evt); |
299 |
} |
300 |
}); |
301 |
|
302 |
|
303 |
} |
304 |
|
305 |
/**
|
306 |
* Saves the initial state to restore it if cancel.
|
307 |
*/
|
308 |
public void readStat(){ |
309 |
status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(), |
310 |
getAssignedBand(GeoRasterFile.RED_BAND), |
311 |
getAssignedBand(GeoRasterFile.GREEN_BAND), |
312 |
getAssignedBand(GeoRasterFile.BLUE_BAND) |
313 |
); |
314 |
} |
315 |
|
316 |
/**
|
317 |
* This method initializes jContentPane
|
318 |
*/
|
319 |
public Container getContentPane() { |
320 |
return this; |
321 |
} |
322 |
|
323 |
/**
|
324 |
* Sets a projection.
|
325 |
*
|
326 |
* @param prj
|
327 |
*/
|
328 |
public void setProjection(IProjection prj) { |
329 |
this.currentProjection = prj;
|
330 |
} |
331 |
|
332 |
|
333 |
|
334 |
public void closeJDialog() { |
335 |
PluginServices.getMDIManager().closeView(PropertiesWCSDialog.this); |
336 |
} |
337 |
|
338 |
/**
|
339 |
* Sets the RasterFilterStackManager
|
340 |
* @param stackManager
|
341 |
*/
|
342 |
public void setRasterFilterStackManager(RasterFilterStackManager stackManager){ |
343 |
this.stackManager = stackManager;
|
344 |
stackManager.resetTempFilters(); |
345 |
} |
346 |
|
347 |
/**
|
348 |
*
|
349 |
* @param flag
|
350 |
* @return
|
351 |
*/
|
352 |
public int getAssignedBand(int flag) { |
353 |
return this.getBandSetup().getAssignedBand(flag); |
354 |
} |
355 |
|
356 |
/**
|
357 |
* Pressing OK with the bands panel selected makes its values to be
|
358 |
* processed.
|
359 |
*
|
360 |
* @return true if the bands panel was selected and the action is processed, false it
|
361 |
* was not selected.
|
362 |
*/
|
363 |
public boolean processBandPanel(){ |
364 |
if(this.getTab().getSelectedComponent() == this.getBandSetup()){ |
365 |
|
366 |
fLayer.getWCSAdaptor().setBandR(getAssignedBand(GeoRasterFile.RED_BAND)); |
367 |
fLayer.getWCSAdaptor().setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND)); |
368 |
fLayer.getWCSAdaptor().setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND)); |
369 |
|
370 |
fLayer.getFMap().invalidate(); |
371 |
return true; |
372 |
} |
373 |
return false; |
374 |
} |
375 |
|
376 |
/**
|
377 |
* Pressing OK with the transparency panel selected makes its values to be processed.
|
378 |
* @return true if the transparency panel was selected and the action is processed, false it
|
379 |
* was not selected.
|
380 |
*/
|
381 |
public boolean processTransparencyPanel(){ |
382 |
|
383 |
if(this.getTab().getSelectedComponent() == this.getTransparencyPanel()){ |
384 |
|
385 |
//OPACIDAD
|
386 |
String sOpac = this.getTransparencyPanel().getOpacityText().getText(); |
387 |
if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){ |
388 |
int opac = Integer.parseInt(sOpac); |
389 |
opac = (int)((opac*255)/100); |
390 |
px.setTransparency(true);
|
391 |
//px.setTransparency(255-opac);
|
392 |
fLayer.getWCSAdaptor().setTransparency(255-opac);
|
393 |
}else{
|
394 |
px.setTransparency(false);
|
395 |
fLayer.getWCSAdaptor().setTransparency(0);
|
396 |
} |
397 |
|
398 |
//TRANSPARENCIA
|
399 |
if( this.getTransparencyPanel().getTransparencyCheck().isSelected()){ |
400 |
this.checkTransparencyValues();
|
401 |
stackManager.addTransparencyFilter( this.getRangeRed(),
|
402 |
this.getRangeGreen(),
|
403 |
this.getRangeBlue(),
|
404 |
0x10, //Transparencia |
405 |
0xff, //Color Transparencia R |
406 |
0xff, //Color Transparencia G |
407 |
0xff); //Color Transparencia B |
408 |
}else
|
409 |
px.filterStack.removeFilter(stackManager.getTypeFilter("transparency"));
|
410 |
|
411 |
fLayer.getFMap().invalidate(); |
412 |
return true; |
413 |
} |
414 |
|
415 |
return false; |
416 |
} |
417 |
|
418 |
/**
|
419 |
* Pressing OK with the enhancement panel selected makes its values to be processed.
|
420 |
* @return true if the enhancement panel was selected and the action is processed, false it
|
421 |
* was not selected.
|
422 |
*/
|
423 |
public boolean processEnhancedPanel(){ |
424 |
if(this.getTab().getSelectedComponent() == this.getEnhancedPanel()){ |
425 |
|
426 |
//Filtro lineal seleccionado
|
427 |
if( this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){ |
428 |
if(contentPane.getEnhancedPanel().getRemoveCheck().isSelected())
|
429 |
stackManager.addEnhancedFilter(true);
|
430 |
else
|
431 |
stackManager.addEnhancedFilter(false);
|
432 |
|
433 |
//Recorte de colas seleccionado
|
434 |
if(this.getEnhancedPanel().getTailCheck().isSelected()){ |
435 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
436 |
double recorte = Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100; |
437 |
if(this.getEnhancedPanel().getRemoveCheck().isSelected()) |
438 |
stackManager.addTailFilter( recorte, 0D, true); |
439 |
else
|
440 |
stackManager.addTailFilter( recorte, 0D, false); |
441 |
}else{
|
442 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
443 |
stackManager.addComputeMinMaxFilter(); |
444 |
} |
445 |
} |
446 |
|
447 |
//Sin filtro lineal seleccionado
|
448 |
if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){ |
449 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
450 |
stackManager.removeFilter(stackManager.getTypeFilter("tail"));
|
451 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
452 |
} |
453 |
fLayer.getFMap().invalidate(); |
454 |
|
455 |
return true; |
456 |
} |
457 |
return false; |
458 |
} |
459 |
|
460 |
/**
|
461 |
* Manages the action perfomed when Apply/OK is pressed or Apply at the raster
|
462 |
* properties control.
|
463 |
* @param e
|
464 |
*/
|
465 |
private void acceptButtonActionPerformed(ActionEvent e) { |
466 |
this.processBandPanel();
|
467 |
this.processTransparencyPanel();
|
468 |
this.processEnhancedPanel();
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* Adds a band to the raster.
|
473 |
* @param e
|
474 |
*/
|
475 |
private void addFileBand(ActionEvent e){ |
476 |
String[] driverNames = null; |
477 |
String rasterDriver = null; |
478 |
|
479 |
//Creaci?n del dialogo para selecci?n de ficheros
|
480 |
|
481 |
fileChooser = new JFileChooser(lastPath); |
482 |
fileChooser.setMultiSelectionEnabled(true);
|
483 |
fileChooser.setAcceptAllFileFilterUsed(false);
|
484 |
try {
|
485 |
driverNames = LayerFactory.getDM().getDriverNames(); |
486 |
FileFilter defaultFileFilter = null, auxF; |
487 |
for (int i = 0; i < driverNames.length; i++) { |
488 |
|
489 |
if (driverNames[i].endsWith("gvSIG Image Driver")){ |
490 |
rasterDriver = driverNames[i]; |
491 |
auxF = new DriverFileFilter(driverNames[i]);
|
492 |
fileChooser.addChoosableFileFilter(auxF); |
493 |
defaultFileFilter = auxF; |
494 |
} |
495 |
} |
496 |
} catch (DriverLoadException e1) {
|
497 |
NotificationManager.addError("No se pudo acceder a los drivers", e1);
|
498 |
} |
499 |
int result = fileChooser.showOpenDialog(PropertiesWCSDialog.this);
|
500 |
|
501 |
if(result == JFileChooser.APPROVE_OPTION){ |
502 |
File[] files = fileChooser.getSelectedFiles(); |
503 |
FileFilter filter = fileChooser.getFileFilter();
|
504 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
|
505 |
lastPath = files[0].getPath();
|
506 |
|
507 |
//Lo a?adimos a la capa si no esta
|
508 |
|
509 |
Vector v = new Vector(); |
510 |
for(int i=0;i<files.length;i++){ |
511 |
boolean exist = false; |
512 |
for(int j=0;j<px.getFiles().length;j++){ |
513 |
if(px.getFiles()[j].getName().endsWith(files[i].getName()))
|
514 |
exist = true;
|
515 |
} |
516 |
if(!exist){
|
517 |
try{
|
518 |
Rectangle2D extentOrigin = fLayer.getFullExtent();
|
519 |
|
520 |
Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent(); |
521 |
|
522 |
//Comprobamos que el extent y tama?o del fichero a?adido sea igual al
|
523 |
//fichero original. Si no es as? no abrimos la capa y mostramos un aviso
|
524 |
|
525 |
double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
|
526 |
double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
|
527 |
|
528 |
if( (widthNewFile-extentOrigin.getWidth()) > 1.0 || |
529 |
(widthNewFile-extentOrigin.getWidth()) < -1.0 ||
|
530 |
(heightNewFile-extentOrigin.getHeight()) > 1.0 ||
|
531 |
(heightNewFile-extentOrigin.getHeight()) < -1.0){
|
532 |
JOptionPane.showMessageDialog( null, |
533 |
PluginServices.getText(this, "extents_no_coincidentes"), |
534 |
"",
|
535 |
JOptionPane.ERROR_MESSAGE);
|
536 |
return;
|
537 |
} |
538 |
|
539 |
if( (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
|
540 |
(extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight() ){ |
541 |
JOptionPane.showMessageDialog(null, |
542 |
PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE); |
543 |
return;
|
544 |
} |
545 |
|
546 |
}catch(Exception exc){ |
547 |
exc.printStackTrace(); |
548 |
} |
549 |
|
550 |
//Lo a?adimos a la capa
|
551 |
px.addFile(files[i].getAbsolutePath()); |
552 |
//Mantiene la lista de ficheros a?adidos por si se cancela
|
553 |
status.addFile(files[i].getAbsolutePath()); |
554 |
}else{
|
555 |
JOptionPane.showMessageDialog(null, |
556 |
PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
557 |
} |
558 |
} |
559 |
|
560 |
//A?adimos los georasterfile a la tabla del Panel
|
561 |
|
562 |
v = new Vector(); |
563 |
for(int i=0;i<px.getFiles().length;i++){ |
564 |
boolean exist = false; |
565 |
for(int j=0;j<bandSetup.getNBands();j++){ |
566 |
if(px.getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
|
567 |
exist = true;
|
568 |
} |
569 |
if(!exist)
|
570 |
v.add(px.getFiles()[i]); |
571 |
} |
572 |
|
573 |
GeoRasterFile[] grf = new GeoRasterFile[v.size()]; |
574 |
for(int i=0;i<grf.length;i++){ |
575 |
grf[i] = (GeoRasterFile)v.get(i); |
576 |
} |
577 |
bandSetup.addFiles(grf); |
578 |
} |
579 |
} |
580 |
|
581 |
/**
|
582 |
* Deletes a band from the raster. If there is only a file or no band is
|
583 |
* selected then it does nothing.
|
584 |
*
|
585 |
* @param e
|
586 |
*/
|
587 |
private void delFileBand(ActionEvent e){ |
588 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
|
589 |
|
590 |
if( bandSetup.getFileList().getJList().getSelectedValue()!=null && |
591 |
bandSetup.getFileList().getNFiles() > 1){
|
592 |
String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
|
593 |
px.delFile(pathName); |
594 |
String file = pathName.substring(pathName.lastIndexOf("/")+1); |
595 |
file = file.substring(file.lastIndexOf("\\")+1); |
596 |
bandSetup.removeFile(file); |
597 |
|
598 |
//Mantiene la lista de ficheros eliminados por si se cancela
|
599 |
status.removeFile(pathName); |
600 |
} |
601 |
} |
602 |
|
603 |
/**
|
604 |
* The cancel button restores the previous state to the loading of this dialog
|
605 |
* @param e Evento
|
606 |
*/
|
607 |
private void cancelButtonActionPerformed(ActionEvent e) { |
608 |
this.status.restoreStatus(this); |
609 |
fLayer.getFMap().invalidate(); |
610 |
} |
611 |
|
612 |
/**
|
613 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
614 |
*/
|
615 |
public ViewInfo getViewInfo() {
|
616 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
617 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
618 |
return m_viewinfo;
|
619 |
} |
620 |
|
621 |
|
622 |
} |