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