Revision 4181 org.gvsig.raster.multifile/trunk/org.gvsig.raster.multifile/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorPropertiesListener.java
BandSelectorPropertiesListener.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.raster.multifile.app.panel; |
23 | 23 |
|
24 | 24 |
import java.awt.event.ActionEvent; |
25 | 25 |
import java.awt.geom.Point2D; |
26 | 26 |
import java.io.File; |
27 |
import java.net.URI; |
|
27 | 28 |
import java.util.ArrayList; |
28 | 29 |
import java.util.List; |
29 | 30 |
|
... | ... | |
85 | 86 |
public void init(FLyrRaster lyr) { |
86 | 87 |
fLayer = lyr; |
87 | 88 |
} |
88 |
|
|
89 |
|
|
89 | 90 |
public RasterDataStore getResult() { |
90 | 91 |
return fLayer.getDataStore(); |
91 | 92 |
} |
92 |
|
|
93 |
|
|
93 | 94 |
/** |
94 | 95 |
* Listener para la gesti?n de los botones de a?adir, eliminar fichero y |
95 | 96 |
* el combo de selecci?n de bandas. |
96 | 97 |
*/ |
97 | 98 |
public void actionPerformed(ActionEvent e) { |
98 | 99 |
super.actionPerformed(e); |
99 |
|
|
100 |
|
|
100 | 101 |
if (e.getSource().equals(bandSetupPanel.getNumBandSelectorCombo())) { |
101 | 102 |
String vBands = (String) bandSetupPanel.getNumBandSelectorCombo().getSelectedItem(); |
102 | 103 |
if (vBands != null) { |
... | ... | |
133 | 134 |
try { |
134 | 135 |
String[] bands = new String[bandSetupPanel.getARGBTable().getRowCount()]; |
135 | 136 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation(bands); |
136 |
|
|
137 |
|
|
137 | 138 |
// Combinaci?n GRAY |
138 | 139 |
if ((numBandToRed == numBandToGreen) && (numBandToRed == numBandToBlue) && (numBandToRed >= 0)) { |
139 | 140 |
for (int iBand = 0; iBand < bandSetupPanel.getARGBTable().getRowCount(); iBand++) { |
... | ... | |
157 | 158 |
} |
158 | 159 |
|
159 | 160 |
boolean autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
160 |
|
|
161 |
|
|
161 | 162 |
if (!autoRefreshView) |
162 | 163 |
return; |
163 | 164 |
|
... | ... | |
177 | 178 |
File[] files = fileChooser.getSelectedFiles(); |
178 | 179 |
|
179 | 180 |
JFileChooser.setLastPath(FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, files[0]); |
180 |
|
|
181 |
|
|
181 | 182 |
fileList = new ArrayList<File>(); |
182 |
|
|
183 |
|
|
183 | 184 |
for (int i = 0; i < files.length; i++) { |
184 | 185 |
//Checks that the file does not exist |
185 |
String[] uris = dataStore.getURIByProvider();
|
|
186 |
URI[] uris = dataStore.getURIByProvider();
|
|
186 | 187 |
boolean exists = false; |
187 | 188 |
for (int j = 0; j < uris.length; j++) { |
188 |
if (uris[j].endsWith(files[i].getName())) { |
|
189 |
if (uris[j].getPath().endsWith(files[i].getName())) {
|
|
189 | 190 |
RasterSwingLibrary.messageBoxError( Messages.getText("fichero_existe") + ": " + files[i].getAbsolutePath(), bandSetupPanel); |
190 | 191 |
exists = true; |
191 | 192 |
break; |
... | ... | |
194 | 195 |
if(!exists) |
195 | 196 |
fileList.add(files[i]); |
196 | 197 |
} |
197 |
|
|
198 |
|
|
198 | 199 |
if(!checkStoresCompatibility(fLayer.getDataStore(), fileList)) |
199 | 200 |
return; |
200 |
|
|
201 |
|
|
201 | 202 |
if(dataStore.isMultiFile()) { |
202 | 203 |
for (int i = 0; i < fileList.size(); i++) { |
203 | 204 |
try { |
204 |
dataStore.addFile(fileList.get(i).getAbsolutePath());
|
|
205 |
dataStore.addFile(fileList.get(i)); |
|
205 | 206 |
} catch (InvalidSourceException e) { |
206 | 207 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, e); |
207 | 208 |
} |
208 | 209 |
} |
209 |
|
|
210 |
|
|
210 | 211 |
dataStore.setProvider(dataStore.getProvider()); |
211 |
|
|
212 |
|
|
212 | 213 |
//It shows the files and bands in the panel |
213 | 214 |
try { |
214 | 215 |
bandSetupPanel.addFiles(dataStore); |
... | ... | |
223 | 224 |
} |
224 | 225 |
} |
225 | 226 |
} |
226 |
|
|
227 |
|
|
227 | 228 |
/** |
228 | 229 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha |
229 | 230 |
* seleccionado ninguna banda no hace nada. |
... | ... | |
233 | 234 |
public void delFileBand() { |
234 | 235 |
Object[] objects = bandSetupPanel.getFileList().getJList().getSelectedValues(); |
235 | 236 |
RasterDataStore dataStore = fLayer.getDataStore(); |
236 |
|
|
237 |
|
|
237 | 238 |
for (int i = objects.length - 1; i >= 0; i--) { |
238 | 239 |
if (bandSetupPanel.getFileList().getNFiles() > 1) { |
239 | 240 |
String pathName = objects[i].toString(); |
240 |
dataStore.removeFile(pathName);
|
|
241 |
dataStore.removeFile(new File(pathName));
|
|
241 | 242 |
|
242 | 243 |
String file = pathName.substring(pathName.lastIndexOf(File.separator) + 1); |
243 | 244 |
file = file.substring(file.lastIndexOf("\\") + 1); |
244 | 245 |
bandSetupPanel.removeFile(file); |
245 | 246 |
} |
246 | 247 |
} |
247 |
|
|
248 |
|
|
248 | 249 |
setNewBandsPositionInRendering(); |
249 | 250 |
} |
250 |
|
|
251 |
|
|
251 | 252 |
/** |
252 | 253 |
* Catchs the events from LayerNameDialog to get the name of the new layer |
253 | 254 |
*/ |
254 | 255 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
255 | 256 |
String layerName = (String)e.getSource(); |
256 |
|
|
257 |
|
|
257 | 258 |
RasterDataStore dataStore = fLayer.getDataStore(); |
258 | 259 |
RasterDataParameters paramFirstFile = (RasterDataParameters)dataStore.getParameters();//(RasterDataParameters)((RasterProvider)dataStore.getProvider()).getDataParameters(); |
259 |
String path = paramFirstFile.getURI().substring(0, paramFirstFile.getURI().lastIndexOf(File.separator) + 1);
|
|
260 |
|
|
260 |
String path = paramFirstFile.getURI().getPath().substring(0, paramFirstFile.getURI().getPath().lastIndexOf(File.separator) + 1);
|
|
261 |
|
|
261 | 262 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
262 | 263 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
263 | 264 |
|
... | ... | |
268 | 269 |
|
269 | 270 |
//And now it creates and adds the new ones |
270 | 271 |
for (int i = 0; i < fileList.size(); i++) { |
271 |
ArrayList<RasterDataParameters> storeParametersList = provServ.createParametersList(fileList.get(i).getAbsolutePath()); |
|
272 |
ArrayList<RasterDataParameters> storeParametersList = provServ.createParametersList(fileList.get(i)); //.getAbsolutePath());
|
|
272 | 273 |
for (int j = 0; j < storeParametersList.size(); j++) { |
273 | 274 |
DataStoreProvider newFileProv = dataManager.createProvider((DataStoreProviderServices)dataStore, storeParametersList.get(j)); |
274 | 275 |
newParamsMultifile.addProviderNotTiled(newFileProv); |
... | ... | |
285 | 286 |
} catch (NotInitializeException ex) { |
286 | 287 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), this, ex); |
287 | 288 |
} |
288 |
|
|
289 |
|
|
289 | 290 |
ArrayList<File> uriList = new ArrayList<File>(); |
290 | 291 |
uriList.add(new File(paramFirstFile.getURI())); |
291 | 292 |
for (int i = 0; i < fileList.size(); i++) { |
292 | 293 |
uriList.add(fileList.get(i)); |
293 | 294 |
} |
294 |
saveMultiFileLayer(layerName, paramFirstFile.getURI(), uriList); |
|
295 |
saveMultiFileLayer(layerName, paramFirstFile.getURI().getPath(), uriList);
|
|
295 | 296 |
|
296 | 297 |
} catch (Exception exc) { |
297 | 298 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, exc); |
298 | 299 |
} |
299 | 300 |
} |
300 |
|
|
301 |
|
|
301 | 302 |
/** |
302 | 303 |
* Acciones a ejecutar cuando se aplica |
303 | 304 |
*/ |
... | ... | |
309 | 310 |
public void setNewBandsPositionInRendering() { |
310 | 311 |
if (fLayer != null && fLayer.getRender() != null) { |
311 | 312 |
fLayer.getRender().setRenderColorInterpretation(bandSetupPanel.getSelectedColorInterpretation()); |
312 |
|
|
313 |
|
|
313 | 314 |
int alphaBand = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
314 | 315 |
Transparency gt = fLayer.getRender().getRenderingTransparency(); |
315 | 316 |
if(gt != null) |
Also available in: Unified diff