root / trunk / extensions / extRasterTools / src / com / iver / cit / gvsig / rasterTools / saveRaster / gui / SaveRasterDialog.java @ 4441
History | View | Annotate | Download (7.91 KB)
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.rasterTools.saveRaster.gui; |
48 |
|
49 |
import java.awt.Container; |
50 |
import java.awt.Dimension; |
51 |
import java.awt.event.ActionEvent; |
52 |
import java.awt.geom.Rectangle2D; |
53 |
|
54 |
import org.cresques.cts.IProjection; |
55 |
import org.cresques.io.GeoRasterWriter; |
56 |
|
57 |
import com.iver.andami.PluginServices; |
58 |
import com.iver.andami.ui.mdiManager.View; |
59 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
60 |
import com.iver.cit.gvsig.fmap.MapControl; |
61 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
62 |
import com.iver.cit.gvsig.rasterTools.saveRaster.DriverProperties; |
63 |
|
64 |
/**
|
65 |
* Dialogo para abrir fichero.
|
66 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
67 |
*/
|
68 |
public class SaveRasterDialog extends SaveRasterDialogPanel implements View { |
69 |
|
70 |
//Ancho y alto ventana de salvar a raster
|
71 |
private int widthWindow = 366; |
72 |
private int heightWindow = 288; |
73 |
|
74 |
private GeoRasterWriter writer=null; |
75 |
private IProjection currentProjection = null; |
76 |
private SaveRasterPropsDialog frameSaveRasterProps = null; |
77 |
private int compresion = 1; |
78 |
private int sizeBlock = 64; |
79 |
public DriverProperties driverProps = null; |
80 |
private FLayers layers = null; |
81 |
private MapControl mapCtrl = null; |
82 |
|
83 |
|
84 |
/**
|
85 |
* Constructor de la ventana de dialogo.
|
86 |
*/
|
87 |
public SaveRasterDialog(FLayers layers, MapControl mapCtrl) {
|
88 |
super();
|
89 |
//super.setModal(true);
|
90 |
driverProps = new DriverProperties();
|
91 |
this.layers = layers;
|
92 |
this.mapCtrl = mapCtrl;
|
93 |
init(); |
94 |
this.setTranslation();
|
95 |
} |
96 |
|
97 |
/**
|
98 |
* Asigna los textos a los paneles
|
99 |
*/
|
100 |
public void setTranslation(){ |
101 |
DataInputSaveRaster dInput = (DataInputSaveRaster)super.getContentPanel();
|
102 |
dInput.lSupIzq.setText(PluginServices.getText(this,"lsup_izq")+":"); |
103 |
dInput.lInfDer.setText(PluginServices.getText(this,"linf_der")+":"); |
104 |
dInput.lFile.setText(PluginServices.getText(this,"Fichero")+":"); |
105 |
dInput.lResolucion.setText(PluginServices.getText(this,"resolucion")); |
106 |
dInput.lEscala.setText(PluginServices.getText(this,"escala")+" 1:"); |
107 |
dInput.lPpp.setText(PluginServices.getText(this,"lppp")); |
108 |
dInput.bSeleccion.setText(PluginServices.getText(this,"Seleccionar")); |
109 |
dInput.lAncho.setText(PluginServices.getText(this,"ancho")+"."); |
110 |
dInput.lAlto.setText(PluginServices.getText(this,"alto")+"."); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Inicializa el jDialog
|
115 |
*
|
116 |
* @return javax.swing.JDialog
|
117 |
*/
|
118 |
private void init() { |
119 |
setBounds(0, 0, widthWindow, heightWindow); |
120 |
setName("saveRaster");
|
121 |
|
122 |
this.getAcceptButton().setEnabled(false); |
123 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
124 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
125 |
acceptButtonActionPerformed(evt); |
126 |
closeJDialog(); |
127 |
} |
128 |
}); |
129 |
this.getCancelButton().addActionListener(new java.awt.event.ActionListener() { |
130 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
131 |
closeJDialog(); |
132 |
} |
133 |
}); |
134 |
this.getApplyButton().addActionListener(new java.awt.event.ActionListener() { |
135 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
136 |
acceptButtonActionPerformed(evt); |
137 |
} |
138 |
}); |
139 |
|
140 |
//Captura de eventos para el bot?n de propiedades
|
141 |
|
142 |
((DataInputSaveRaster)this.getContentPanel()).getBPropiedades().addActionListener(new java.awt.event.ActionListener() { |
143 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
144 |
propsButtonActionPerformed(evt); |
145 |
} |
146 |
}); |
147 |
|
148 |
} |
149 |
|
150 |
|
151 |
/**
|
152 |
* This method initializes jContentPane
|
153 |
*
|
154 |
* @return javax.swing.JPanel
|
155 |
*/
|
156 |
public Container getContentPane() { |
157 |
return this; |
158 |
} |
159 |
|
160 |
/**
|
161 |
*
|
162 |
* @param prj
|
163 |
*/
|
164 |
|
165 |
public void setProjection(IProjection prj) { |
166 |
this.currentProjection = prj;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* Asigna el FLayers
|
171 |
* @param layers
|
172 |
*/
|
173 |
public void setLayerList(FLayers layers){ |
174 |
this.layers = layers;
|
175 |
} |
176 |
|
177 |
|
178 |
public void closeJDialog() { |
179 |
this.hide();
|
180 |
for(int i=0;i<layers.getLayersCount();i++){ |
181 |
layers.getLayer(i).getFMap().invalidate(); |
182 |
} |
183 |
PluginServices.getMDIManager().closeView(SaveRasterDialog.this); |
184 |
//dlg.dispose();
|
185 |
} |
186 |
|
187 |
private void propsButtonActionPerformed(ActionEvent e){ |
188 |
DataInputSaveRaster dialog = (DataInputSaveRaster)((SaveRasterDialogPanel)this.getContentPane()).getContentPanel();
|
189 |
String name = ((SaveRasterDialogPanel)this.getContentPane()).getListener().getFileName(); |
190 |
|
191 |
//Si no se ha seleccionado ning?n fichero salimos
|
192 |
if(name == null || name.equals("")) |
193 |
return;
|
194 |
|
195 |
GeoRasterWriter writer = GeoRasterWriter.getWriter(name); |
196 |
String ext = name.toLowerCase().substring(name.lastIndexOf(".") + 1); |
197 |
if(driverProps.getProperties(ext)!=null) |
198 |
writer.setProps(driverProps.getProperties(ext)); |
199 |
|
200 |
frameSaveRasterProps = new SaveRasterPropsDialog(writer);
|
201 |
frameSaveRasterProps.setParentDialog(this);
|
202 |
frameSaveRasterProps.show(); |
203 |
} |
204 |
|
205 |
/**
|
206 |
*
|
207 |
* @param e
|
208 |
*/
|
209 |
private void acceptButtonActionPerformed(ActionEvent e) { |
210 |
DataInputSaveRaster dialog = (DataInputSaveRaster)((SaveRasterDialogPanel)this.getContentPane()).getContentPanel();
|
211 |
|
212 |
String fName = ((SaveRasterDialogPanel)this.getContentPane()).getListener().getFileName(); |
213 |
Dimension dimension = new Dimension(Integer.parseInt(dialog.getTancho().getText()), |
214 |
Integer.parseInt(dialog.getTalto().getText()));
|
215 |
|
216 |
double lrX = Double.parseDouble(dialog.getTinf_derX().getText()); |
217 |
double lrY = Double.parseDouble(dialog.getTinf_derY().getText()); |
218 |
double ulX = Double.parseDouble(dialog.getTsup_izqX().getText()); |
219 |
double ulY = Double.parseDouble(dialog.getTsup_izqY().getText()); |
220 |
double width = 0; |
221 |
if(ulX>lrX)width = (double)(ulX-lrX); |
222 |
else width = (double)(lrX-ulX); |
223 |
double height = 0; |
224 |
if(ulY>lrY)height = (double)(ulY-lrY); |
225 |
else height = (double)(lrY-ulY); |
226 |
Rectangle2D ext = null; |
227 |
|
228 |
if(ulY<lrY)
|
229 |
ext = new Rectangle2D.Double(ulX, ulY, width, height); |
230 |
else
|
231 |
ext = new Rectangle2D.Double(ulX, lrY, width, height); |
232 |
|
233 |
ProgressSaveRasterDialog progressBar = |
234 |
new ProgressSaveRasterDialog(mapCtrl, this.layers, this.currentProjection, |
235 |
dimension, ext); |
236 |
|
237 |
progressBar.setProps(driverProps); |
238 |
progressBar.setWriter(writer); |
239 |
progressBar.setFName(fName); |
240 |
progressBar.setBlockSize(sizeBlock); |
241 |
progressBar.setCompresion(compresion); |
242 |
progressBar.showWindow(); |
243 |
|
244 |
for(int i=0;i<layers.getLayersCount();i++){ |
245 |
layers.getLayer(i).getFMap().invalidate(); |
246 |
} |
247 |
} |
248 |
|
249 |
/**
|
250 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
251 |
*/
|
252 |
public ViewInfo getViewInfo() {
|
253 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
254 |
m_viewinfo.setTitle(PluginServices.getText(this, "salvar_raster")); |
255 |
return m_viewinfo;
|
256 |
} |
257 |
|
258 |
} |