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