Revision 1930
branches/gvSIG_03_raster/applications/appgvSIG/config/config.xml | ||
---|---|---|
96 | 96 |
<selectable-tool icon="images/Poligono16.png" action-command="AREA" tooltip="medir_area"/> |
97 | 97 |
<selectable-tool icon="images/Select.png" action-command="SELPOINT" tooltip="seleccionar_por_punto" /> |
98 | 98 |
<selectable-tool icon="images/SelEspacial2b.png" action-command="SELRECT" tooltip="seleccionar_por_rectangulo"/> |
99 |
|
|
99 |
<selectable-tool icon="images/Rectangle.png" action-command="SAVERASTER" tooltip="salvar_raster"/> |
|
100 |
<selectable-tool icon="images/zoommas.png" action-command="SELECTIMAGE" tooltip="seleccionar_capas"/> |
|
100 | 101 |
</tool-bar> |
101 | 102 |
</extension> |
102 | 103 |
<extension class-name="com.iver.cit.gvsig.ThemeControls" |
branches/gvSIG_03_raster/applications/appgvSIG/text.properties | ||
---|---|---|
162 | 162 |
exportar=Exportar |
163 | 163 |
exportar_a=Exportar a... |
164 | 164 |
extension=Extensi?n |
165 |
extents_no_coincidentes=El extent de la imagen seleccionada no coincide con el de la de origen |
|
165 | 166 |
Fichero=Fichero |
167 |
fichero_existe=El fichero seleccionado ya existe como banda de la capa |
|
166 | 168 |
filtro=Filtro |
167 | 169 |
finalizar=Finalizar |
168 | 170 |
Font=Fuente |
... | ... | |
306 | 308 |
propiedades_marco_imagenes=Propiedades del marco de im?genes |
307 | 309 |
propiedades_marco_leyenda=Propiedades del marco de la leyenda |
308 | 310 |
propiedades_marco_vista=Propiedades del marco de la vista |
311 |
propiedades_raster=Propiedades del raster |
|
309 | 312 |
propiedades_sesion=Propiedades de la sesi?n |
310 | 313 |
propiedades_tabla=Propiedades de la tabla |
311 | 314 |
Propiedades_texto=Propiedades del texto |
... | ... | |
332 | 335 |
renombrar=Renombrar |
333 | 336 |
resolucion_resultado=Resoluci?n del resultado: |
334 | 337 |
Sample=Ejemplo |
338 |
salvar_raster=Salvar a raster |
|
335 | 339 |
Seleccionar=Seleccionar |
336 | 340 |
seleccionar_capas=Seleccionar Capas |
337 | 341 |
Seleccionar_del_conjunto=Seleccionar del conjunto |
... | ... | |
424 | 428 |
Zoom_Menos_Vista=Zoom Menos sobre la Vista |
425 | 429 |
Zoom_M?s=Zoom M?s |
426 | 430 |
Zoom_M?s_Vista=Zoom M?s sobre la Vista |
431 |
Zoom_pixel=Zoom a la resoluci?n del raster |
|
427 | 432 |
Zoom_Previo=Zoom Previo |
428 | 433 |
Zoom_Real=Zoom 1:1 |
429 | 434 |
Zoom_Select=Zoom a lo seleccionado |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/RasterizerLayer.java | ||
---|---|---|
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; |
|
48 |
|
|
49 |
import java.awt.Color; |
|
50 |
import java.awt.Dimension; |
|
51 |
import java.awt.Graphics2D; |
|
52 |
import java.awt.geom.Rectangle2D; |
|
53 |
import java.awt.image.BufferedImage; |
|
54 |
|
|
55 |
import org.cresques.geo.ViewPortData; |
|
56 |
import org.cresques.io.Rasterizer; |
|
57 |
import org.cresques.px.Extent; |
|
58 |
import org.cresques.px.PxLayerList; |
|
59 |
|
|
60 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
61 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
62 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
63 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
64 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
|
65 |
|
|
66 |
/** |
|
67 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
68 |
* |
|
69 |
* Sirve datos solicitados por los drivers que salvan a raster. |
|
70 |
* Hereda de Rasterizer y reescribe el m?todo readData que es el que |
|
71 |
* ser? llamado desde el driver cada vez que vacie el buffer y |
|
72 |
* necesite m?s datos. |
|
73 |
*/ |
|
74 |
public class RasterizerLayer extends Rasterizer{ |
|
75 |
|
|
76 |
private ViewPort viewPort = null; |
|
77 |
private ViewPort viewPortBlock = null; |
|
78 |
private FLayers flayers = null; |
|
79 |
private Color backgroundColor = null; |
|
80 |
|
|
81 |
/** |
|
82 |
* Calculo del viewPort |
|
83 |
* @param vp |
|
84 |
*/ |
|
85 |
private void calcViewPort(ViewPort vp){ |
|
86 |
Rectangle2D ext = null; |
|
87 |
|
|
88 |
if(viewPortBlock == null){ |
|
89 |
ext = new Rectangle2D.Double( vp.getExtent().getMinX(), |
|
90 |
vp.getExtent().getMaxY()-wcIntervalo, |
|
91 |
vp.getExtent().getWidth(), |
|
92 |
wcIntervalo |
|
93 |
); |
|
94 |
}else{ |
|
95 |
ext = new Rectangle2D.Double( vp.getExtent().getMinX(), |
|
96 |
vp.getExtent().getMinY()-wcIntervalo, |
|
97 |
vp.getExtent().getWidth(), |
|
98 |
wcIntervalo |
|
99 |
); |
|
100 |
} |
|
101 |
|
|
102 |
viewPortBlock = new ViewPort(vp.getProjection()); |
|
103 |
viewPortBlock.setExtent(ext); |
|
104 |
viewPortBlock.setImageSize(dimension); |
|
105 |
viewPortBlock.setScale(); |
|
106 |
//System.out.println("--->bloque="+contBlocks+" ImageHeight="+viewPortBlock.getImageHeight()+" ImageWidth="+viewPortBlock.getImageWidth()); |
|
107 |
//System.out.println("--->minX="+viewPortBlock.getExtent().getMinX()+" minY="+viewPortBlock.getExtent().getMinY()+" maxX="+viewPortBlock.getExtent().getMaxX()+" maxY="+viewPortBlock.getExtent().getMaxY()+" width="+viewPortBlock.getExtent().getWidth()+" height="+viewPortBlock.getExtent().getHeight()); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Constructor |
|
112 |
* @param flyrs capas |
|
113 |
* @param vp viewport |
|
114 |
* @param sizeBlock altura del bloque que se lee de una vez en la imagen de entrada |
|
115 |
* @param mapCtrl Mapcontrol |
|
116 |
*/ |
|
117 |
public RasterizerLayer(FLayers flyrs, ViewPort vp, int sizeBlock, MapControl mapCtrl){ |
|
118 |
|
|
119 |
super(sizeBlock); |
|
120 |
backgroundColor = vp.getBackColor(); |
|
121 |
viewPort = new ViewPort(vp.getProjection()); |
|
122 |
viewPort.setImageSize(vp.getImageSize()); |
|
123 |
viewPort.setExtent(vp.getExtent()); |
|
124 |
|
|
125 |
//Calculo del viewPort del primer bloque |
|
126 |
|
|
127 |
wcAlto = viewPort.getExtent().getMaxY() - viewPort.getExtent().getMinY(); |
|
128 |
wcIntervalo = (sizeBlock*wcAlto)/viewPort.getImageHeight(); |
|
129 |
dimension = new Dimension(viewPort.getImageWidth(), sizeBlock); |
|
130 |
|
|
131 |
calcViewPort(viewPort); |
|
132 |
|
|
133 |
int nBlocks = (int)(vp.getImageHeight()/sizeBlock); |
|
134 |
|
|
135 |
//Tama?o de ?ltimo bloque en pixeles |
|
136 |
lastBlock = Math.round(vp.getImageHeight()-(nBlocks*sizeBlock)); |
|
137 |
|
|
138 |
/*System.out.println("1--->SizeBlock="+sizeBlock+" ImageHeight="+viewPort.getImageHeight()+" ImageWidth="+viewPort.getImageWidth()); |
|
139 |
System.out.println("2--->wcAlto="+wcAlto+" wcIntervalo="+wcIntervalo); |
|
140 |
System.out.println("3--->nBlocks="+nBlocks+" lastBlock="+lastBlock); |
|
141 |
System.out.println("4--->minX="+viewPort.getExtent().getMinX()+" minY="+viewPort.getExtent().getMinY()+" maxX="+viewPort.getExtent().getMaxX()+" maxY="+viewPort.getExtent().getMaxY()+" width="+viewPort.getExtent().getWidth()+" height="+viewPort.getExtent().getHeight()); |
|
142 |
*/ |
|
143 |
this.flayers = flyrs; |
|
144 |
this.sizeBlock = sizeBlock; |
|
145 |
} |
|
146 |
|
|
147 |
|
|
148 |
/* (non-Javadoc) |
|
149 |
* @see org.cresques.io.IDataWriter#readData(int, int, int) |
|
150 |
*/ |
|
151 |
public int[] readData(int sX, int sY, int nBand){ |
|
152 |
if(nBand == 0){ //Con nBand==0 se devuelven las 3 bandas |
|
153 |
image = new BufferedImage(sX, sY, BufferedImage.TYPE_INT_RGB); |
|
154 |
g = (Graphics2D) image.getGraphics(); |
|
155 |
BufferedImage img = new BufferedImage( viewPortBlock.getImageWidth(), |
|
156 |
viewPortBlock.getImageHeight(), |
|
157 |
BufferedImage.TYPE_INT_ARGB |
|
158 |
); |
|
159 |
g.setColor(backgroundColor); |
|
160 |
g.fillRect(0, 0, viewPortBlock.getImageWidth(), viewPortBlock.getImageHeight()); |
|
161 |
try{ |
|
162 |
flayers.draw(img, g, viewPortBlock,new Cancellable() { |
|
163 |
public boolean isCanceled() { |
|
164 |
return false; |
|
165 |
} |
|
166 |
}); |
|
167 |
}catch (DriverException e) { |
|
168 |
e.printStackTrace(); |
|
169 |
} |
|
170 |
rasterData = image.getRGB(0, 0, sX, sY, rasterData, 0, sX); |
|
171 |
|
|
172 |
//Calculamos el viewPort del sgte bloque |
|
173 |
|
|
174 |
if(((contBlocks+1)*sizeBlock)<=viewPort.getImageHeight()){ |
|
175 |
dimension = new Dimension(sX, sY); |
|
176 |
} |
|
177 |
else{ //Calculo de la altura del ?ltimo bloque |
|
178 |
dimension = new Dimension(sX, (int)(viewPort.getImageHeight()-(contBlocks*sizeBlock))); |
|
179 |
wcIntervalo = (lastBlock*wcAlto)/viewPort.getImageHeight(); |
|
180 |
} |
|
181 |
|
|
182 |
calcViewPort(viewPortBlock); |
|
183 |
|
|
184 |
contBlocks++; |
|
185 |
return rasterData; |
|
186 |
} |
|
187 |
|
|
188 |
return null; |
|
189 |
} |
|
190 |
|
|
191 |
} |
|
0 | 192 |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/ViewControls.java | ||
---|---|---|
150 | 150 |
setActives(true, mapa); |
151 | 151 |
} else if (s.compareTo("TEMAS_NOACTIVOS") == 0) { |
152 | 152 |
setActives(false, mapa); |
153 |
}else if (s.compareTo("SAVERASTER") == 0) { |
|
154 |
mapCtrl.setTool("saveRaster"); |
|
155 |
}else if (s.compareTo("SELECTIMAGE") == 0) { |
|
156 |
mapCtrl.setTool("selectImage"); |
|
153 | 157 |
} |
154 | 158 |
} |
155 | 159 |
|
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutControls.java | ||
---|---|---|
118 | 118 |
zooms.zoomIn(); |
119 | 119 |
} else if (s.compareTo("ZOOMSELECT") == 0) { |
120 | 120 |
zooms.zoomSelect(); |
121 |
} |
|
121 |
}
|
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
/** |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/SaveRasterDialog.java | ||
---|---|---|
1 |
/* |
|
2 |
* Creado el 7-marzo-2005 |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.gui.Panels; |
|
5 |
|
|
6 |
import java.awt.Container; |
|
7 |
import java.awt.Dimension; |
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
import java.awt.geom.Rectangle2D; |
|
10 |
import java.io.IOException; |
|
11 |
|
|
12 |
import javax.swing.JDialog; |
|
13 |
import javax.swing.JPanel; |
|
14 |
|
|
15 |
import org.cresques.cts.IProjection; |
|
16 |
import org.cresques.geo.ViewPortData; |
|
17 |
import org.cresques.io.EcwWriter; |
|
18 |
import org.cresques.io.GdalWriter; |
|
19 |
import org.cresques.io.GeoRasterWriter; |
|
20 |
import org.cresques.io.IDataWriter; |
|
21 |
import org.cresques.io.Rasterizer; |
|
22 |
import org.cresques.px.Extent; |
|
23 |
import org.cresques.px.PxLayerList; |
|
24 |
import org.cresques.ui.CQSaveRaster; |
|
25 |
import org.cresques.ui.raster.DataInputSaveRaster; |
|
26 |
import org.cresques.ui.raster.SaveRasterDialogPanel; |
|
27 |
import org.cresques.ui.raster.SaveSetupPanel; |
|
28 |
|
|
29 |
import com.iver.andami.PluginServices; |
|
30 |
import com.iver.andami.ui.mdiManager.View; |
|
31 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
32 |
import com.iver.cit.gvsig.RasterizerLayer; |
|
33 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
34 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
35 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
36 |
|
|
37 |
/** |
|
38 |
* Dialogo para abrir fichero. |
|
39 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
40 |
*/ |
|
41 |
//public class SaveRasterDialog extends JDialog{ |
|
42 |
public class SaveRasterDialog extends SaveRasterDialogPanel implements View{ |
|
43 |
|
|
44 |
//private SaveRasterDialogPanel contentPane = null; |
|
45 |
private GeoRasterWriter writer=null; |
|
46 |
private GeoRasterWriter writerProps=null; |
|
47 |
private IProjection currentProjection = null; |
|
48 |
private SaveRasterPropsDialog frameSaveRasterProps = null; |
|
49 |
private int compresion = 1; |
|
50 |
private int sizeBlock = 64; |
|
51 |
public DriverProperties driverProps = null; |
|
52 |
private FLayers layers = null; |
|
53 |
private MapControl mapCtrl = null; |
|
54 |
|
|
55 |
class DriverProperties{ |
|
56 |
|
|
57 |
private String[][] driversProps = null; |
|
58 |
private String[] driversExtension = null; |
|
59 |
|
|
60 |
DriverProperties(){ |
|
61 |
|
|
62 |
driversProps = new String[GeoRasterWriter.getNDrivers()][]; |
|
63 |
for(int i=0;i<GeoRasterWriter.getNDrivers();i++) |
|
64 |
driversProps[i] = null; |
|
65 |
driversExtension = GeoRasterWriter.getDriversExtensions(); |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Asigna un vector de propiedades de driver de escritura. |
|
71 |
* @param ext extensi?n del driver. |
|
72 |
* @param props propiedades. |
|
73 |
*/ |
|
74 |
public void setProperties(String ext, String[] props){ |
|
75 |
for(int i=0;i<driversExtension.length;i++){ |
|
76 |
if(ext.equals(driversExtension[i])){ |
|
77 |
driversProps[i] = props; |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Obtiene un vector de propiedades de driver de escritura. |
|
84 |
* @param ext extensi?n del driver. |
|
85 |
* @return propiedades. |
|
86 |
*/ |
|
87 |
public String[] getProperties(String ext){ |
|
88 |
for(int i=0;i<driversExtension.length;i++){ |
|
89 |
if(ext.equals(driversExtension[i])){ |
|
90 |
return driversProps[i]; |
|
91 |
} |
|
92 |
} |
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Constructor de la ventana de dialogo. |
|
100 |
* |
|
101 |
*/ |
|
102 |
public SaveRasterDialog(FLayers layers, MapControl mapCtrl) { |
|
103 |
super(); |
|
104 |
//super.setModal(true); |
|
105 |
driverProps = new DriverProperties(); |
|
106 |
this.layers = layers; |
|
107 |
this.mapCtrl = mapCtrl; |
|
108 |
init(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Inicializa el jDialog |
|
113 |
* |
|
114 |
* @return javax.swing.JDialog |
|
115 |
*/ |
|
116 |
private void init() { |
|
117 |
setBounds(0, 0, 386, 268); |
|
118 |
setName("saveRaster"); |
|
119 |
|
|
120 |
this.getAcceptButton().setEnabled(false); |
|
121 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
|
122 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
123 |
acceptButtonActionPerformed(evt); |
|
124 |
closeJDialog(); |
|
125 |
} |
|
126 |
}); |
|
127 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
|
128 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
129 |
closeJDialog(); |
|
130 |
} |
|
131 |
}); |
|
132 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
|
133 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
134 |
acceptButtonActionPerformed(evt); |
|
135 |
} |
|
136 |
}); |
|
137 |
|
|
138 |
//Captura de eventos para el bot?n de propiedades |
|
139 |
|
|
140 |
((SaveSetupPanel)this.getContentPanel()).getSaveParameters().getBPropiedades().addActionListener(new java.awt.event.ActionListener() { |
|
141 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
142 |
propsButtonActionPerformed(evt); |
|
143 |
} |
|
144 |
}); |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
/** |
|
150 |
* This method initializes jContentPane |
|
151 |
* |
|
152 |
* @return javax.swing.JPanel |
|
153 |
*/ |
|
154 |
public Container getContentPane() { |
|
155 |
return this; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* |
|
160 |
* @param prj |
|
161 |
*/ |
|
162 |
|
|
163 |
public void setProjection(IProjection prj) { |
|
164 |
this.currentProjection = prj; |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Asigna el FLayers |
|
169 |
* @param layers |
|
170 |
*/ |
|
171 |
public void setLayerList(FLayers layers){ |
|
172 |
this.layers = layers; |
|
173 |
} |
|
174 |
|
|
175 |
|
|
176 |
public void closeJDialog() { |
|
177 |
this.hide(); |
|
178 |
for(int i=0;i<layers.getLayersCount();i++){ |
|
179 |
layers.getLayer(i).getFMap().invalidate(); |
|
180 |
} |
|
181 |
PluginServices.getMDIManager().closeView(SaveRasterDialog.this); |
|
182 |
//dlg.dispose(); |
|
183 |
} |
|
184 |
|
|
185 |
private void propsButtonActionPerformed(ActionEvent e){ |
|
186 |
DataInputSaveRaster dialog = (DataInputSaveRaster)((SaveSetupPanel)((SaveRasterDialogPanel)this.getContentPane()).getContentPanel()).getSaveParameters(); |
|
187 |
if(dialog.getBPropiedades().getText().endsWith("Ecw")){ |
|
188 |
writerProps = new EcwWriter(); |
|
189 |
if(driverProps.getProperties("ecw")!=null){ |
|
190 |
writerProps.setProps(driverProps.getProperties("ecw")); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
if(dialog.getBPropiedades().getText().endsWith("GeoTiff")){ |
|
195 |
writerProps = new GdalWriter("GTiff"); |
|
196 |
if(driverProps.getProperties("tif")!=null){ |
|
197 |
writerProps.setProps(driverProps.getProperties("tif")); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
frameSaveRasterProps = new SaveRasterPropsDialog(writerProps); |
|
202 |
frameSaveRasterProps.setParentDialog(this); |
|
203 |
frameSaveRasterProps.show(); |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* |
|
208 |
* @param e |
|
209 |
*/ |
|
210 |
private void acceptButtonActionPerformed(ActionEvent e) { |
|
211 |
DataInputSaveRaster dialog = (DataInputSaveRaster)((SaveSetupPanel)((SaveRasterDialogPanel)this.getContentPane()).getContentPanel()).getSaveParameters(); |
|
212 |
|
|
213 |
String fName = ((SaveSetupPanel)((SaveRasterDialogPanel)this.getContentPane()).getContentPanel()).getFileName(); |
|
214 |
Dimension dimension = new Dimension(Integer.parseInt(dialog.getTancho().getText()), |
|
215 |
Integer.parseInt(dialog.getTalto().getText())); |
|
216 |
|
|
217 |
double lrX = Double.parseDouble(dialog.getTinf_derX().getText()); |
|
218 |
double lrY = Double.parseDouble(dialog.getTinf_derY().getText()); |
|
219 |
double ulX = Double.parseDouble(dialog.getTsup_izqX().getText()); |
|
220 |
double ulY = Double.parseDouble(dialog.getTsup_izqY().getText()); |
|
221 |
double width = 0; |
|
222 |
if(ulX>lrX)width = ulX-lrX; |
|
223 |
else width = lrX-ulX; |
|
224 |
double height = 0; |
|
225 |
if(ulY>lrY)height = ulY-lrY; |
|
226 |
else height = lrY-ulY; |
|
227 |
Rectangle2D ext = null; |
|
228 |
|
|
229 |
if(ulY<lrY) |
|
230 |
ext = new Rectangle2D.Double(ulX, ulY, width, height); |
|
231 |
else |
|
232 |
ext = new Rectangle2D.Double(ulX, lrY, width, height); |
|
233 |
|
|
234 |
ViewPort vp = new ViewPort(this.currentProjection); |
|
235 |
vp.setBackColor(mapCtrl.getViewPort().getBackColor()); |
|
236 |
vp.setImageSize(dimension); |
|
237 |
vp.setExtent(ext); |
|
238 |
|
|
239 |
if (fName.endsWith(".ecw")) { |
|
240 |
//System.out.println("Salvando vista a fichero "+fName+" a formato Ecw"); |
|
241 |
try{ |
|
242 |
|
|
243 |
RasterizerLayer p = new RasterizerLayer(this.layers, vp, sizeBlock, mapCtrl); |
|
244 |
Extent ex = new Extent(vp.getAdjustedExtent()); |
|
245 |
Dimension imgSz = vp.getImageSize(); |
|
246 |
ViewPortData vpData = new ViewPortData(vp.getProjection(), ex, imgSz ); |
|
247 |
writer = new EcwWriter( ((IDataWriter)p), |
|
248 |
vpData, |
|
249 |
fName, |
|
250 |
sizeBlock, |
|
251 |
3, |
|
252 |
compresion); |
|
253 |
//Si han sido modificadas las propiedades se asignan los valores modificados |
|
254 |
String[] prp = driverProps.getProperties("ecw"); |
|
255 |
if(prp!=null) |
|
256 |
writer.setProps(prp); |
|
257 |
((EcwWriter)writer).dataWrite(); |
|
258 |
((EcwWriter)writer).writeClose(); |
|
259 |
|
|
260 |
|
|
261 |
}catch(IOException ev){ |
|
262 |
ev.printStackTrace(); |
|
263 |
}catch(es.gva.cit.jecwcompress.EcwException r){ |
|
264 |
r.printStackTrace(); |
|
265 |
} |
|
266 |
|
|
267 |
}else if (fName.endsWith(".tif")) { |
|
268 |
//System.out.println("Salvando fichero "+fName+" a formato Tif"); |
|
269 |
try{ |
|
270 |
|
|
271 |
RasterizerLayer p = new RasterizerLayer(this.layers, vp, sizeBlock, mapCtrl); |
|
272 |
Extent ex = new Extent(vp.getAdjustedExtent()); |
|
273 |
writer = new GdalWriter( ((IDataWriter)p), |
|
274 |
dimension.width, |
|
275 |
dimension.height, |
|
276 |
fName, |
|
277 |
ex.maxX(), |
|
278 |
ex.minX(), |
|
279 |
ex.maxY(), |
|
280 |
ex.minY(), |
|
281 |
3, |
|
282 |
sizeBlock, |
|
283 |
"GTiff"); |
|
284 |
//Si han sido modificadas las propiedades se asignan los valores modificados |
|
285 |
String[] prp = driverProps.getProperties("tif"); |
|
286 |
if(prp!=null) |
|
287 |
writer.setProps(prp); |
|
288 |
((GdalWriter)writer).dataWrite(); |
|
289 |
((GdalWriter)writer).writeClose(); |
|
290 |
}catch(IOException ev){ |
|
291 |
ev.printStackTrace(); |
|
292 |
}catch(es.gva.cit.jgdal.GdalException r){ |
|
293 |
r.printStackTrace(); |
|
294 |
} |
|
295 |
|
|
296 |
} else { |
|
297 |
System.err.println("Extensi?n del fichero " + fName + " no soportada."); |
|
298 |
} |
|
299 |
|
|
300 |
for(int i=0;i<layers.getLayersCount();i++){ |
|
301 |
layers.getLayer(i).getFMap().invalidate(); |
|
302 |
} |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo() |
|
307 |
*/ |
|
308 |
public ViewInfo getViewInfo() { |
|
309 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG); |
|
310 |
m_viewinfo.setTitle(PluginServices.getText(this, "salvar_raster")); |
|
311 |
return m_viewinfo; |
|
312 |
} |
|
313 |
|
|
314 |
} |
|
0 | 315 |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/SaveRasterPropsDialog.java | ||
---|---|---|
1 |
/* |
|
2 |
* Creado el 7-marzo-2005 |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.gui.Panels; |
|
5 |
|
|
6 |
import java.awt.Container; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
|
|
9 |
import javax.swing.JDialog; |
|
10 |
|
|
11 |
import org.cresques.cts.IProjection; |
|
12 |
import org.cresques.io.CXMLParser; |
|
13 |
import org.cresques.io.GeoRasterWriter; |
|
14 |
import org.cresques.px.PxLayerList; |
|
15 |
import org.cresques.ui.raster.SavePropsSetupPanel; |
|
16 |
import org.cresques.ui.raster.SaveRasterPropsDialogPanel; |
|
17 |
|
|
18 |
/** |
|
19 |
* Dialogo para abrir fichero. |
|
20 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
21 |
*/ |
|
22 |
public class SaveRasterPropsDialog extends JDialog { |
|
23 |
|
|
24 |
private SaveRasterPropsDialogPanel contentPane = null; |
|
25 |
private GeoRasterWriter writer=null; |
|
26 |
private String formato = null; |
|
27 |
private IProjection currentProjection = null; |
|
28 |
private PxLayerList layerList = null; |
|
29 |
private int widthWindow=386; |
|
30 |
private int heightWindow=300; |
|
31 |
private String[] properties = null; |
|
32 |
private SaveRasterDialog parentDialog = null; |
|
33 |
|
|
34 |
/** |
|
35 |
* Constructor |
|
36 |
* @param writer |
|
37 |
*/ |
|
38 |
public SaveRasterPropsDialog(GeoRasterWriter writer) { |
|
39 |
super(); |
|
40 |
super.setModal(true); |
|
41 |
this.writer = writer; |
|
42 |
this.formato = writer.getIdent(); |
|
43 |
//Obtenemos el tama?o de la ventana del XML generado por el driver |
|
44 |
String xml = writer.getXMLPropertiesDialog(); |
|
45 |
if(xml!=null){ |
|
46 |
CXMLParser parser = new CXMLParser(xml); |
|
47 |
widthWindow = Integer.parseInt(parser.getAttr("window","sizex")); |
|
48 |
heightWindow = Integer.parseInt(parser.getAttr("window","sizey")); |
|
49 |
} |
|
50 |
initialize(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Inicializaci?n del dialogo |
|
55 |
* |
|
56 |
* @return javax.swing.JDialog |
|
57 |
*/ |
|
58 |
private void initialize() { |
|
59 |
setBounds(0, 0, widthWindow, heightWindow); //Size Ventana |
|
60 |
setResizable(false); |
|
61 |
setName("saveRasterProps"); |
|
62 |
setTitle("Propiedades de "+formato); |
|
63 |
setContentPane(getContentPane()); |
|
64 |
//contentPane.getAcceptButton().setEnabled(false); |
|
65 |
contentPane.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
|
66 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
67 |
acceptButtonActionPerformed(evt); |
|
68 |
closeJDialog(); |
|
69 |
} |
|
70 |
}); |
|
71 |
contentPane.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
|
72 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
73 |
closeJDialog(); |
|
74 |
} |
|
75 |
}); |
|
76 |
contentPane.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
|
77 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
78 |
acceptButtonActionPerformed(evt); |
|
79 |
} |
|
80 |
}); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Asigna el dialogo padre a una variable. |
|
85 |
* @param parentDialog Cuadro de dialogo padre. |
|
86 |
*/ |
|
87 |
public void setParentDialog(SaveRasterDialog parentDialog){ |
|
88 |
this.parentDialog = parentDialog; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Inicializa contenPane |
|
93 |
* @return Container |
|
94 |
*/ |
|
95 |
public Container getContentPane() { |
|
96 |
if (contentPane == null) { |
|
97 |
contentPane = new SaveRasterPropsDialogPanel(writer); |
|
98 |
//contentPane.addAncestorListener(this); |
|
99 |
} |
|
100 |
return contentPane; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Asigna la proyecci?n |
|
105 |
* @param prj Proyecci?n |
|
106 |
*/ |
|
107 |
|
|
108 |
public void setProjection(IProjection prj) { |
|
109 |
this.currentProjection = prj; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* |
|
114 |
* @param layerList |
|
115 |
*/ |
|
116 |
|
|
117 |
public void setLayerList(PxLayerList layerList){ |
|
118 |
this.layerList = layerList; |
|
119 |
} |
|
120 |
|
|
121 |
|
|
122 |
public void closeJDialog() { |
|
123 |
this.hide(); |
|
124 |
} |
|
125 |
|
|
126 |
|
|
127 |
/** |
|
128 |
* Cuando se acepta se obtienen las propiedades seleccionadas |
|
129 |
* @param e |
|
130 |
*/ |
|
131 |
private void acceptButtonActionPerformed(ActionEvent e) { |
|
132 |
if(((SavePropsSetupPanel)((SaveRasterPropsDialogPanel)this.getContentPane()).getContentPanel()).getProperties()!=null){ |
|
133 |
properties = ((SavePropsSetupPanel)((SaveRasterPropsDialogPanel)this.getContentPane()).getContentPanel()).getProperties(); |
|
134 |
parentDialog.driverProps.setProperties(writer.getDriverName(), properties); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
0 | 138 |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/PropertiesRasterDialog.java | ||
---|---|---|
1 |
/* |
|
2 |
* Creado el 7-marzo-2005 |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.gui.Panels; |
|
5 |
|
|
6 |
import java.awt.Container; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
import java.io.File; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Vector; |
|
12 |
|
|
13 |
import javax.swing.JFileChooser; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.filechooser.FileFilter; |
|
17 |
|
|
18 |
import org.cresques.cts.ICoordTrans; |
|
19 |
import org.cresques.cts.IProjection; |
|
20 |
import org.cresques.cts.gt2.CoordSys; |
|
21 |
import org.cresques.cts.gt2.CoordTrans; |
|
22 |
import org.cresques.io.GeoRasterFile; |
|
23 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
24 |
import org.cresques.px.Extent; |
|
25 |
import org.cresques.ui.raster.BandSetupPanel; |
|
26 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
|
27 |
|
|
28 |
import com.hardcode.driverManager.Driver; |
|
29 |
import com.hardcode.driverManager.DriverLoadException; |
|
30 |
import com.hardcode.gdbms.engine.data.FileDriver; |
|
31 |
import com.iver.andami.PluginServices; |
|
32 |
import com.iver.andami.messages.Messages; |
|
33 |
import com.iver.andami.messages.NotificationManager; |
|
34 |
import com.iver.andami.ui.mdiManager.View; |
|
35 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
36 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
37 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
38 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
|
39 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
|
40 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
41 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
42 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
|
43 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
44 |
import com.iver.cit.gvsig.gui.FOpenDialog; |
|
45 |
import com.iver.cit.gvsig.gui.FileOpenDialog; |
|
46 |
import com.iver.cit.gvsig.gui.FileOpenDialog.DriverFileFilter; |
|
47 |
import com.iver.cit.gvsig.gui.FileOpenDialog.MyFile; |
|
48 |
|
|
49 |
/** |
|
50 |
* <P> |
|
51 |
* Dialogo para las propiedades de un raster. Esta maneja los eventos y aplica |
|
52 |
* filtros sobre el raster a trav?s de l gestor de la pila de filtros seg?n la |
|
53 |
* selecci?n del usuario. Este dialogo contiene varios paneles: |
|
54 |
* </P> |
|
55 |
* <UL> |
|
56 |
* <LI>Propiedades</LI> |
|
57 |
* <LI>Selecci?n de bandas</LI> |
|
58 |
* <LI>Transparencia</LI> |
|
59 |
* <LI>Realce</LI> |
|
60 |
* </UL> |
|
61 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
62 |
*/ |
|
63 |
public class PropertiesRasterDialog extends FilterRasterDialogPanel implements View{ |
|
64 |
|
|
65 |
private FilterRasterDialogPanel contentPane = null; |
|
66 |
private JPanel propPanel = null; |
|
67 |
private IProjection currentProjection = null; |
|
68 |
private FLyrRaster fLayer = null; |
|
69 |
private static final int nprops = 11; |
|
70 |
private Object[][] props = null; |
|
71 |
private RasterFilterStackManager stackManager = null; |
|
72 |
private Status status = null; |
|
73 |
private String filename = null; |
|
74 |
private long filesize = 0; |
|
75 |
private int width = 0; |
|
76 |
private int height = 0; |
|
77 |
private int nbands = 0; |
|
78 |
private JFileChooser fileChooser = null; |
|
79 |
private String lastPath = new String("./"); |
|
80 |
|
|
81 |
/** |
|
82 |
* Clase que guarda el estado del dialogo y gestiona la restauraci?n |
|
83 |
* del estado inicial en caso de cancelar. |
|
84 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
85 |
*/ |
|
86 |
class Status{ |
|
87 |
public String inicAlpha; |
|
88 |
public int bandR; |
|
89 |
public int bandG; |
|
90 |
public int bandB; |
|
91 |
private ArrayList files = new ArrayList(); |
|
92 |
|
|
93 |
public Status(String alpha, int bandR, int bandG, int bandB){ |
|
94 |
this.inicAlpha = alpha; |
|
95 |
this.bandR = bandR; |
|
96 |
this.bandG = bandG; |
|
97 |
this.bandB = bandB; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* A?ade un fichero a la lista |
|
102 |
* @param file |
|
103 |
*/ |
|
104 |
public void addFile(String file){ |
|
105 |
files.add(file); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Elimina un fichero de la lista |
|
110 |
* @param file |
|
111 |
*/ |
|
112 |
public void removeFile(String file){ |
|
113 |
for(int i=0;i<files.size();i++){ |
|
114 |
if(((String)files.get(i)).equals(file)) |
|
115 |
files.remove(i); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* |
|
121 |
* @param i |
|
122 |
* @return |
|
123 |
*/ |
|
124 |
public String getFile(int i){ |
|
125 |
return ((String)files.get(i)); |
|
126 |
} |
|
127 |
|
|
128 |
public int getNFiles(){ |
|
129 |
return files.size(); |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Restaura el Estado salvado |
|
134 |
* @param status Estado |
|
135 |
*/ |
|
136 |
public void restoreStatus(PropertiesRasterDialog props){ |
|
137 |
//Devolvemos la pila de filtros al estado inicial |
|
138 |
if(stackManager != null) |
|
139 |
stackManager.deleteTempFilters(); |
|
140 |
|
|
141 |
//Devolvemos el alpha al estado inicial |
|
142 |
int opac = Integer.parseInt(status.inicAlpha); |
|
143 |
opac = (int)((opac*255)/100); |
|
144 |
fLayer.getSource().setTransparency(true); |
|
145 |
fLayer.setTransparency(255-opac); |
|
146 |
|
|
147 |
if (fLayer != null) { |
|
148 |
fLayer.getSource().setBand(GeoRasterFile.RED_BAND, status.bandR); |
|
149 |
fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND, status.bandG); |
|
150 |
fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND, status.bandB); |
|
151 |
} |
|
152 |
|
|
153 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)props.getContentPane()).getBandSetup(); |
|
154 |
for(int i=0;i<status.getNFiles();i++){ |
|
155 |
fLayer.delFile(status.getFile(i)); |
|
156 |
String file = status.getFile(i).substring(status.getFile(i).lastIndexOf("/")+1); |
|
157 |
file = file.substring(file.lastIndexOf("\\")+1); |
|
158 |
bandSetup.removeFile(file); |
|
159 |
} |
|
160 |
fLayer.getFMap().invalidate(); |
|
161 |
|
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
public class DriverFileFilter extends FileFilter{ |
|
166 |
|
|
167 |
private Driver driver; |
|
168 |
|
|
169 |
public DriverFileFilter(String driverName) throws DriverLoadException{ |
|
170 |
driver = LayerFactory.getDM().getDriver(driverName); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File) |
|
175 |
*/ |
|
176 |
public boolean accept(File f) { |
|
177 |
if (f.isDirectory()) return true; |
|
178 |
if (driver instanceof RasterDriver){ |
|
179 |
return ((RasterDriver) driver).fileAccepted(f); |
|
180 |
}else{ |
|
181 |
throw new RuntimeException("Tipo no reconocido"); |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* @see javax.swing.filechooser.FileFilter#getDescription() |
|
187 |
*/ |
|
188 |
public String getDescription() { |
|
189 |
return ((Driver) driver).getName(); |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* Constructor de la ventana de dialogo. |
|
195 |
* @param app |
|
196 |
*/ |
|
197 |
public PropertiesRasterDialog(FLyrRaster layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){ |
|
198 |
super(); |
|
199 |
fLayer = layer; |
|
200 |
initialize(); |
|
201 |
this.setRanges(rangeR, rangeG, rangeB); |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* Asigna un FLayerRaster |
|
206 |
* @param layer capa a asignar |
|
207 |
*/ |
|
208 |
public void setFLyrRaster(FLyrRaster layer){ |
|
209 |
fLayer = layer; |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Constructor de la ventana de dialogo. |
|
214 |
*/ |
|
215 |
public PropertiesRasterDialog() { |
|
216 |
initialize(); |
|
217 |
} |
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
/** |
|
222 |
* Carga los datos del panel info. |
|
223 |
*/ |
|
224 |
private void loadInfoData(){ |
|
225 |
if(fLayer.getSource()!=null){ |
|
226 |
props = new Object[nprops][2]; |
|
227 |
props[0][0] = new String("Fichero: "); |
|
228 |
props[0][1] = filename; |
|
229 |
props[1][0] = new String("N?mero de Bandas: "); |
|
230 |
props[1][1] = new String(String.valueOf(fLayer.getSource().getNumBands())); |
|
231 |
props[2][0] = new String("Ancho X Alto: "); |
|
232 |
props[2][1] = this.width+" X "+this.height; |
|
233 |
props[3][0] = new String("Formato: "); |
|
234 |
props[3][1] = filename.substring( |
|
235 |
filename.lastIndexOf('.')+1, |
|
236 |
filename.length()); |
|
237 |
props[4][0] = new String("Tipo de dato: "); |
|
238 |
String type = null; |
|
239 |
switch(fLayer.getSource().getDataType()){ |
|
240 |
case 0: type = new String("BYTE");break; |
|
241 |
case 1: type = new String("USHORT");break; |
|
242 |
case 2: type = new String("SHORT");break; |
|
243 |
case 3: type = new String("INT");break; |
|
244 |
case 4: type = new String("FLOAT");break; |
|
245 |
case 5: type = new String("DOUBLE");break; |
|
246 |
default: type = new String("UNDEFINED");break; |
|
247 |
} |
|
248 |
props[4][1] = type; |
|
249 |
props[5][0] = new String("Coor. Geograficas"); |
|
250 |
props[6][0] = new String(" - X m?nima:"); |
|
251 |
props[6][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinX()); |
|
252 |
props[7][0] = new String(" - Y m?nima:"); |
|
253 |
props[7][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinY()); |
|
254 |
props[8][0] = new String(" - X m?xima:"); |
|
255 |
props[8][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxX()); |
|
256 |
props[9][0] = new String(" - Y m?xima:"); |
|
257 |
props[9][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxY()); |
|
258 |
|
|
259 |
}else{ |
|
260 |
props = new Object[1][2]; |
|
261 |
props[0][0] = new String("No props"); |
|
262 |
props[0][1] = new String("-"); |
|
263 |
} |
|
264 |
|
|
265 |
} |
|
266 |
|
|
267 |
/** |
|
268 |
* Inicializa el jDialog |
|
269 |
*/ |
|
270 |
private void initialize() { |
|
271 |
|
|
272 |
//this.setLayout(new FlowLayout()); |
|
273 |
|
|
274 |
setName("filterRaster"); |
|
275 |
ArrayList attr = ((FLyrRaster)fLayer).getSource().getAttributes(); |
|
276 |
for (int i=0; i<attr.size(); i++) { |
|
277 |
Object[] a = (Object []) attr.get(i); |
|
278 |
if(a[0].toString().equals("Filename")) |
|
279 |
filename = a[1].toString(); |
|
280 |
if(a[0].toString().equals("Filesize")) |
|
281 |
filesize = ((Long)a[1]).intValue(); |
|
282 |
if(a[0].toString().equals("Width")) |
|
283 |
width = ((Integer)a[1]).intValue(); |
|
284 |
if(a[0].toString().equals("Height")) |
|
285 |
height = ((Integer)a[1]).intValue(); |
|
286 |
if(a[0].toString().equals("Bands")) |
|
287 |
nbands = ((Integer)a[1]).intValue(); |
|
288 |
|
|
289 |
} |
|
290 |
|
|
291 |
this.loadInfoData(); |
|
292 |
super.init(props); |
|
293 |
//this.add(getContentPane()); |
|
294 |
|
|
295 |
this.setSize(386, 268); |
|
296 |
|
|
297 |
//contentPane.getAcceptButton().setEnabled(false); |
|
298 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
|
299 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
300 |
acceptButtonActionPerformed(evt); |
|
301 |
closeJDialog(); |
|
302 |
} |
|
303 |
}); |
|
304 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
|
305 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
306 |
cancelButtonActionPerformed(evt); |
|
307 |
closeJDialog(); |
|
308 |
} |
|
309 |
}); |
|
310 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
|
311 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
312 |
acceptButtonActionPerformed(evt); |
|
313 |
} |
|
314 |
}); |
|
315 |
this.getBandSetup().getFileList().getJButton2().addActionListener(new java.awt.event.ActionListener() { |
|
316 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
|
317 |
addFileBand(evt); |
|
318 |
|
|
319 |
} |
|
320 |
}); |
|
321 |
this.getBandSetup().getFileList().getJButton3().addActionListener(new java.awt.event.ActionListener() { |
|
322 |
public void actionPerformed(java.awt.event.ActionEvent evt){ |
|
323 |
delFileBand(evt); |
|
324 |
} |
|
325 |
}); |
|
326 |
|
|
327 |
|
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* Salva el estado inicial por si se cancela |
|
332 |
*/ |
|
333 |
public void readStat(){ |
|
334 |
status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(), |
|
335 |
getAssignedBand(GeoRasterFile.RED_BAND), |
|
336 |
getAssignedBand(GeoRasterFile.GREEN_BAND), |
|
337 |
getAssignedBand(GeoRasterFile.BLUE_BAND) |
|
338 |
); |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* This method initializes jContentPane |
|
343 |
*/ |
|
344 |
public Container getContentPane() { |
|
345 |
return this; |
|
346 |
} |
|
347 |
|
|
348 |
/** |
|
349 |
* Asigna una proyecci?n |
|
350 |
* @param prj |
|
351 |
*/ |
|
352 |
public void setProjection(IProjection prj) { |
|
353 |
this.currentProjection = prj; |
|
354 |
} |
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
public void closeJDialog() { |
|
359 |
PluginServices.getMDIManager().closeView(PropertiesRasterDialog.this); |
|
360 |
} |
|
361 |
|
|
362 |
/** |
|
363 |
* Asigna el RasterFilterStackManager |
|
364 |
* @param stackManager |
|
365 |
*/ |
|
366 |
public void setRasterFilterStackManager(RasterFilterStackManager stackManager){ |
|
367 |
this.stackManager = stackManager; |
|
368 |
stackManager.resetTempFilters(); |
|
369 |
} |
|
370 |
|
|
371 |
/** |
|
372 |
* |
|
373 |
* @param flag |
|
374 |
* @return |
|
375 |
*/ |
|
376 |
public int getAssignedBand(int flag) { |
|
377 |
return this.getBandSetup().getAssignedBand(flag); |
|
378 |
} |
|
379 |
|
|
380 |
/** |
|
381 |
* Pulsar aceptar con el panel de bandas seleccionado hace que se procesen los valores |
|
382 |
* introducidos en este. |
|
383 |
* @return true si estaba seleccionado el panel de bandas y se ha procesado la |
|
384 |
* acci?n y false si no lo estaba. |
|
385 |
*/ |
|
386 |
public boolean processBandPanel(){ |
|
387 |
if(this.getTab().getSelectedComponent() == this.getBandSetup()){ |
|
388 |
/*System.out.println("==>Obteniendo bandas DIALOGO"+ |
|
389 |
getAssignedBand(GeoRasterFile.RED_BAND)+" "+ |
|
390 |
getAssignedBand(GeoRasterFile.GREEN_BAND)+" "+ |
|
391 |
getAssignedBand(GeoRasterFile.BLUE_BAND));*/ |
|
392 |
|
|
393 |
fLayer.getSource().setBand(GeoRasterFile.RED_BAND, |
|
394 |
getAssignedBand(GeoRasterFile.RED_BAND)); |
|
395 |
fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND, |
|
396 |
getAssignedBand(GeoRasterFile.GREEN_BAND)); |
|
397 |
fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND, |
|
398 |
getAssignedBand(GeoRasterFile.BLUE_BAND)); |
|
399 |
fLayer.getFMap().invalidate(); |
|
400 |
return true; |
|
401 |
} |
|
402 |
return false; |
|
403 |
} |
|
404 |
|
|
405 |
/** |
|
406 |
* Pulsar aceptar con el panel de transparecias seleccionado hace que se procesen los valores |
|
407 |
* introducidos en este. |
|
408 |
* @return true si estaba seleccionado el panel de transparencias y se ha procesado la |
|
409 |
* acci?n y false si no lo estaba. |
|
410 |
*/ |
|
411 |
public boolean processTransparencyPanel(){ |
|
412 |
|
|
413 |
if(this.getTab().getSelectedComponent() == this.getTransparencyPanel()){ |
|
414 |
|
|
415 |
//OPACIDAD |
|
416 |
String sOpac = this.getTransparencyPanel().getOpacityText().getText(); |
|
417 |
if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){ |
|
418 |
int opac = Integer.parseInt(sOpac); |
|
419 |
opac = (int)((opac*255)/100); |
|
420 |
fLayer.getSource().setTransparency(true); |
|
421 |
fLayer.setTransparency(255-opac); |
|
422 |
}else{ |
|
423 |
fLayer.getSource().setTransparency(false); |
|
424 |
fLayer.setTransparency(0); |
|
425 |
} |
|
426 |
|
|
427 |
//TRANSPARENCIA |
|
428 |
if( this.getTransparencyPanel().getTransparencyCheck().isSelected()){ |
|
429 |
this.checkTransparencyValues(); |
|
430 |
stackManager.addTransparencyFilter( this.getRangeRed(), |
|
431 |
this.getRangeGreen(), |
|
432 |
this.getRangeBlue(), |
|
433 |
0x10, //Transparencia |
|
434 |
0xff, //Color Transparencia R |
|
435 |
0xff, //Color Transparencia G |
|
436 |
0xff); //Color Transparencia B |
|
437 |
}else |
|
438 |
fLayer.getSource().getFilterStack().removeFilter(stackManager.getTypeFilter("transparency")); |
|
439 |
|
|
440 |
return true; |
|
441 |
} |
|
442 |
|
|
443 |
return false; |
|
444 |
} |
|
445 |
|
|
446 |
/** |
|
447 |
* Pulsar aceptar con el panel de realce seleccionado hace que se procesen los valores |
|
448 |
* introducidos en este. |
|
449 |
* @return true si estaba seleccionado el panel de realce y se ha procesado la |
|
450 |
* acci?n y false si no lo estaba. |
|
451 |
*/ |
|
452 |
public boolean processEnhancedPanel(){ |
|
453 |
if(this.getTab().getSelectedComponent() == this.getEnhancedPanel()){ |
|
454 |
|
|
455 |
//Filtro lineal seleccionado |
|
456 |
if( this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){ |
|
457 |
stackManager.addEnhancedFilter(); |
|
458 |
|
|
459 |
if(this.getEnhancedPanel().getTailCheck().isSelected()){ |
|
460 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax")); |
|
461 |
stackManager.addTailFilter( Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100,0D); |
|
462 |
}else{ |
|
463 |
stackManager.removeFilter(stackManager.getTypeFilter("tail")); |
|
464 |
stackManager.addComputeMinMaxFilter(); |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
//Sin filtro lineal seleccionado |
|
469 |
if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){ |
|
470 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax")); |
|
471 |
stackManager.removeFilter(stackManager.getTypeFilter("tail")); |
|
472 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced")); |
|
473 |
} |
|
474 |
fLayer.getFMap().invalidate(); |
|
475 |
|
|
476 |
return true; |
|
477 |
} |
|
478 |
return false; |
|
479 |
} |
|
480 |
|
|
481 |
/** |
|
482 |
* Gestiona la acci?n cuando se pulsa aplicar/aceptar o aplicar en el control |
|
483 |
* de propiedades de raster |
|
484 |
* @param e |
|
485 |
*/ |
|
486 |
private void acceptButtonActionPerformed(ActionEvent e) { |
|
487 |
this.processBandPanel(); |
|
488 |
this.processTransparencyPanel(); |
|
489 |
this.processEnhancedPanel(); |
|
490 |
} |
|
491 |
|
|
492 |
/** |
|
493 |
* A?ade una banda al raster |
|
494 |
* @param e |
|
495 |
*/ |
|
496 |
private void addFileBand(ActionEvent e){ |
|
497 |
String[] driverNames = null; |
|
498 |
String rasterDriver = null; |
|
499 |
|
|
500 |
//Creaci?n del dialogo para selecci?n de ficheros |
|
501 |
|
|
502 |
fileChooser = new JFileChooser(lastPath); |
|
503 |
fileChooser.setMultiSelectionEnabled(true); |
|
504 |
fileChooser.setAcceptAllFileFilterUsed(false); |
|
505 |
try { |
|
506 |
driverNames = LayerFactory.getDM().getDriverNames(); |
|
507 |
FileFilter defaultFileFilter = null, auxF; |
|
508 |
for (int i = 0; i < driverNames.length; i++) { |
|
509 |
|
|
510 |
if (driverNames[i].endsWith("gvSIG Image Driver")){ |
|
511 |
rasterDriver = driverNames[i]; |
|
512 |
auxF = new DriverFileFilter(driverNames[i]); |
|
513 |
fileChooser.addChoosableFileFilter(auxF); |
|
514 |
defaultFileFilter = auxF; |
|
515 |
} |
|
516 |
} |
|
517 |
} catch (DriverLoadException e1) { |
|
518 |
NotificationManager.addError("No se pudo acceder a los drivers", e1); |
|
519 |
} |
|
520 |
int result = fileChooser.showOpenDialog(PropertiesRasterDialog.this); |
|
521 |
|
|
522 |
if(result == JFileChooser.APPROVE_OPTION){ |
|
523 |
File[] files = fileChooser.getSelectedFiles(); |
|
524 |
FileFilter filter = fileChooser.getFileFilter(); |
|
525 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup(); |
|
526 |
lastPath = files[0].getPath(); |
|
527 |
|
|
528 |
//Lo a?adimos a la capa si no esta |
|
529 |
|
|
530 |
Vector v = new Vector(); |
|
531 |
for(int i=0;i<files.length;i++){ |
|
532 |
boolean exist = false; |
|
533 |
for(int j=0;j<fLayer.getSource().getFiles().length;j++){ |
|
534 |
if(fLayer.getSource().getFiles()[j].getName().endsWith(files[i].getName())) |
|
535 |
exist = true; |
|
536 |
} |
|
537 |
if(!exist){ |
|
538 |
try{ |
|
539 |
Rectangle2D extentOrigin = fLayer.getFullExtent(); |
|
540 |
|
|
541 |
Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent(); |
|
542 |
|
|
543 |
//Comprobamos que el extent y tama?o del fichero a?adido sea igual al |
|
544 |
//fichero original. Si no es as? no abrimos la capa y mostramos un aviso |
|
545 |
|
|
546 |
double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX()); |
|
547 |
double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY()); |
|
548 |
|
|
549 |
if( (widthNewFile-extentOrigin.getWidth()) > 1.0 || |
|
550 |
(widthNewFile-extentOrigin.getWidth()) < -1.0 || |
|
551 |
(heightNewFile-extentOrigin.getHeight()) > 1.0 || |
|
552 |
(heightNewFile-extentOrigin.getHeight()) < -1.0){ |
|
553 |
JOptionPane.showMessageDialog( null, |
|
554 |
PluginServices.getText(this, "extents_no_coincidentes"), |
|
555 |
"", |
|
556 |
JOptionPane.ERROR_MESSAGE); |
|
557 |
return; |
|
558 |
} |
|
559 |
|
|
560 |
if( (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() || |
|
561 |
(extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight() ){ |
|
562 |
JOptionPane.showMessageDialog(null, |
|
563 |
PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE); |
|
564 |
return; |
|
565 |
} |
|
566 |
|
|
567 |
}catch(Exception exc){ |
|
568 |
exc.printStackTrace(); |
|
569 |
} |
|
570 |
|
|
571 |
//Lo a?adimos a la capa |
|
572 |
fLayer.addFiles(files[i].getAbsolutePath()); |
|
573 |
//Mantiene la lista de ficheros a?adidos por si se cancela |
|
574 |
status.addFile(files[i].getAbsolutePath()); |
|
575 |
}else{ |
|
576 |
JOptionPane.showMessageDialog(null, |
|
577 |
PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
|
578 |
} |
|
579 |
} |
|
580 |
|
|
581 |
//A?adimos los georasterfile a la tabla del Panel |
|
582 |
|
|
583 |
v = new Vector(); |
|
584 |
for(int i=0;i<fLayer.getSource().getFiles().length;i++){ |
|
585 |
boolean exist = false; |
|
586 |
for(int j=0;j<bandSetup.getNBands();j++){ |
|
587 |
if(fLayer.getSource().getFiles()[i].getName().endsWith(bandSetup.getBandName(j))) |
|
588 |
exist = true; |
|
589 |
} |
|
590 |
if(!exist) |
|
591 |
v.add(fLayer.getSource().getFiles()[i]); |
|
592 |
} |
|
593 |
|
|
594 |
GeoRasterFile[] grf = new GeoRasterFile[v.size()]; |
|
595 |
for(int i=0;i<grf.length;i++){ |
|
596 |
grf[i] = (GeoRasterFile)v.get(i); |
|
597 |
} |
|
598 |
bandSetup.addFiles(grf); |
|
599 |
} |
|
600 |
} |
|
601 |
|
|
602 |
/** |
|
603 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha |
|
604 |
* seleccionado ninguna banda no hace nada. |
|
605 |
* @param e |
|
606 |
*/ |
|
607 |
private void delFileBand(ActionEvent e){ |
|
608 |
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup(); |
|
609 |
|
|
610 |
if( bandSetup.getFileList().getJList().getSelectedValue()!=null && |
|
611 |
bandSetup.getFileList().getNFiles() > 1){ |
|
612 |
String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString(); |
|
613 |
fLayer.delFile(pathName); |
|
614 |
String file = pathName.substring(pathName.lastIndexOf("/")+1); |
|
615 |
file = file.substring(file.lastIndexOf("\\")+1); |
|
616 |
bandSetup.removeFile(file); |
|
617 |
|
|
618 |
//Mantiene la lista de ficheros eliminados por si se cancela |
|
619 |
status.removeFile(pathName); |
|
620 |
} |
|
621 |
} |
|
622 |
|
|
623 |
/** |
|
624 |
* El bot?n de cancelar recupera el estado anterior a la apertura de |
|
625 |
* este dialogo. |
|
626 |
* @param e Evento |
|
627 |
*/ |
|
628 |
private void cancelButtonActionPerformed(ActionEvent e) { |
|
629 |
this.status.restoreStatus(this); |
|
630 |
fLayer.getFMap().invalidate(); |
|
631 |
} |
|
632 |
|
|
633 |
/** |
|
634 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo() |
|
635 |
*/ |
|
636 |
public ViewInfo getViewInfo() { |
|
637 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG); |
|
638 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
|
639 |
return m_viewinfo; |
|
640 |
} |
|
641 |
|
|
642 |
|
|
643 |
} |
|
0 | 644 |
branches/gvSIG_03_raster/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/FPopupMenu.java | ||
---|---|---|
58 | 58 |
import javax.swing.JTabbedPane; |
59 | 59 |
import javax.swing.tree.DefaultMutableTreeNode; |
60 | 60 |
|
61 |
import org.cresques.io.GeoRasterFile; |
|
62 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
63 |
import org.cresques.ui.raster.BandSetupPanel; |
|
64 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
|
65 |
|
|
61 | 66 |
import com.iver.andami.PluginServices; |
62 | 67 |
import com.iver.cit.gvsig.fmap.DriverException; |
63 | 68 |
import com.iver.cit.gvsig.fmap.FMap; |
69 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
70 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
64 | 71 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
65 | 72 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
66 | 73 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
67 | 74 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
68 | 75 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
76 |
import com.iver.cit.gvsig.fmap.layers.RasterAdapter; |
|
69 | 77 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
70 | 78 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
71 | 79 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
72 | 80 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
81 |
import com.iver.cit.gvsig.gui.View; |
|
73 | 82 |
import com.iver.cit.gvsig.gui.Panels.AdjustTransparencyPanel; |
83 |
import com.iver.cit.gvsig.gui.Panels.PropertiesRasterDialog; |
|
74 | 84 |
import com.iver.cit.gvsig.gui.legendmanager.FLegendManagerWindow; |
75 | 85 |
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
76 | 86 |
|
... | ... | |
187 | 197 |
} |
188 | 198 |
|
189 | 199 |
/** |
200 |
* |
|
201 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
202 |
* |
|
203 |
* Entrada de men? para la activaci?n de la funcionalidad de zoom a un |
|
204 |
* pixel. |
|
205 |
*/ |
|
206 |
class ZoomPixelTocMenuEntry extends TocMenuEntry{ |
|
207 |
private JMenuItem properties; |
|
208 |
FLayer lyr = null; |
|
209 |
|
|
210 |
public void initialize(FPopupMenu m) { |
|
211 |
super.initialize(m); |
|
212 |
|
|
213 |
if (isTocItemBranch()) { |
|
214 |
lyr = getNodeLayer(); |
|
215 |
// Opcciones para capas raster |
|
216 |
if ((lyr instanceof FLyrRaster)) { |
|
217 |
properties = new JMenuItem(PluginServices.getText(this, "Zoom_pixel")); |
|
218 |
getMenu().add( properties ); |
|
219 |
properties.setFont(FPopupMenu.theFont); |
|
220 |
getMenu().setEnabled(true); |
|
221 |
getMenu().addSeparator(); |
|
222 |
properties.addActionListener(this); |
|
223 |
} |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
public void actionPerformed(ActionEvent e) { |
|
228 |
System.out.println("Zoom a un pixel"); |
|
229 |
|
|
230 |
FLayer[] actives = getMapContext().getLayers().getActives(); |
|
231 |
if (actives.length==1) { |
|
232 |
try { |
|
233 |
Rectangle2D r = actives[0].getFullExtent(); |
|
234 |
|
|
235 |
ArrayList attr = ((FLyrRaster)actives[0]).getSource().getAttributes(); |
|
236 |
int width = 0, height = 0; |
|
237 |
for (int i=0; i<attr.size(); i++) { |
|
238 |
Object[] a = (Object []) attr.get(i); |
|
239 |
if(a[0].toString().equals("Width")) |
|
240 |
width = ((Integer)a[1]).intValue(); |
|
241 |
if(a[0].toString().equals("Height")) |
|
242 |
height = ((Integer)a[1]).intValue(); |
|
243 |
} |
|
244 |
ViewPort v = getMapContext().getViewPort(); |
Also available in: Unified diff