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