Revision 12562
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/buildNumber.properties | ||
---|---|---|
1 |
#Mon Sep 28 22:17:21 CEST 2020 |
|
2 |
buildNumber=165 |
|
0 | 3 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.raster.mainplugin" /> |
|
4 |
<depends plugin-name="org.gvsig.raster.tilecache.app" optional="true" /> |
|
5 |
<resourceBundle name="text" /> |
|
6 |
<libraries library-dir="lib" /> |
|
7 |
<extensions> |
|
8 |
<extension class-name="org.gvsig.raster.multifile.app.MultifileClientExtension" |
|
9 |
description="Support for raster multiband and multifile" active="true" |
|
10 |
priority="1"> |
|
11 |
|
|
12 |
<!-- <menu text="Layer/dataset_raster/create_multifile" name="raster-tools-multifile"/> |
|
13 |
<action name="raster-tools-multifile" label="create_multifile" action-command="MultifileCreator" |
|
14 |
icon="multifile-icon" position="000601500" accelerator="" /> --> |
|
15 |
</extension> |
|
16 |
</extensions> |
|
17 |
</plugin-config> |
|
0 | 18 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/resources-plugin/org/gvsig/raster/multifile/app/i18n/text.properties | ||
---|---|---|
1 |
store_tiled=La capa actual est? tileada.\n Para a?adir ficheros a ella se convertir? a no tileada. |
|
2 |
combinacion_no_asignable=No es posible guardar esa combinaci?n de bandas por defecto.\n Una banda solo puede tener una interpretaci?n de color. |
|
3 |
color_interpretation_continue=Se va a cambiar la interpretaci?n de color por defecto para su raster. ?Desea continuar? |
|
4 |
error_carga_capa=Error en la carga de la capa. |
|
5 |
error_salvando_rmf=Error escribiendo el fichero rmf |
|
6 |
table_not_initialize=Tabla no inicializada |
|
7 |
fichero_existe=El fichero existe en el dataset |
|
8 |
extents_no_coincidentes=La extensi?n de las capas no coinciden |
|
9 |
addband_error=No se pudo a?adir las bandas del fichero seleccionado al dataset |
|
10 |
anadir=A?adir |
|
11 |
eliminar=Eliminar |
|
12 |
bands_panel=Bandas |
|
13 |
bands=Bandas |
|
14 |
save=Salvar |
|
15 |
save_color_interpretation=Salvar la interpretaci?n de color |
|
16 |
layer_name=Nombre de capa |
|
17 |
character_not_valid=Caracter no valido |
|
18 |
create_multifile=Crear capa multifichero |
|
19 |
load_layer=Cargar capa |
|
20 |
generate_file=Generar fichero |
|
21 |
select_output_file=Capa de salida |
|
22 |
add_files=A?adir ficheros |
|
0 | 23 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/resources-plugin/org/gvsig/raster/multifile/app/i18n/text_en.properties | ||
---|---|---|
1 |
store_tiled=The current layer is tiled.\n To add files will be turned into not tiled. |
|
2 |
combinacion_no_asignable=It's not possible to save this selection of bands as default.\n A band only can to have one color interpretation |
|
3 |
color_interpretation_continue=It's going to change default color interpretationlor for this raster. Would you like to go on? |
|
4 |
error_carga_capa=Error loading layer |
|
5 |
error_salvando_rmf=Error writing in rmf file |
|
6 |
table_not_initialize=Table not initialize |
|
7 |
fichero_existe=Selected file already exists as layer band |
|
8 |
extents_no_coincidentes=Extent of the selected image does not match with the origin image. |
|
9 |
addband_error=Bands haven't been added to selected dataset. |
|
10 |
anadir=Add |
|
11 |
eliminar=Remove |
|
12 |
bands_panel=Bands |
|
13 |
bands=Bands |
|
14 |
save=Save |
|
15 |
save_color_interpretation=Save color interpretation |
|
16 |
layer_name=Layer name |
|
17 |
character_not_valid=Character not valid |
|
18 |
create_multifile=Create layer multifile |
|
19 |
load_layer=Load layer |
|
20 |
generate_file=Builds a file |
|
21 |
select_output_file=Output layer |
|
22 |
add_files=Add files |
|
0 | 23 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.multifile.app.multifileclient:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.multifile.io:jar</include> |
|
34 |
</includes> |
|
35 |
</dependencySet> |
|
36 |
</dependencySets> |
|
37 |
</assembly> |
|
0 | 38 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/MainDialogActions.java | ||
---|---|---|
1 |
package org.gvsig.raster.multifile.app; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.gvsig.andami.PluginServices; |
|
9 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
10 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
11 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
12 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
13 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
14 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
15 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
16 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
17 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
18 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
19 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
20 |
import org.gvsig.i18n.Messages; |
|
21 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
22 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
23 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
|
24 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
25 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
26 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
27 |
import org.gvsig.raster.multifile.app.panel.BandSelectorPanel; |
|
28 |
import org.gvsig.raster.multifile.io.MultiFileDataParameters; |
|
29 |
import org.gvsig.raster.multifile.io.MultiFileFormat; |
|
30 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author gvSIG team |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class MainDialogActions implements IProcessActions { |
|
37 |
private String file = null; |
|
38 |
private String folder = null; |
|
39 |
private BandSelectorPanel panel = null; |
|
40 |
private AbstractViewPanel selectedView = null; |
|
41 |
|
|
42 |
/** |
|
43 |
* @param panel |
|
44 |
* @param file |
|
45 |
* @param folder |
|
46 |
*/ |
|
47 |
public MainDialogActions(BandSelectorPanel panel, String file, String folder) { |
|
48 |
this.file = file; |
|
49 |
this.folder = folder; |
|
50 |
this.panel = panel; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
*/ |
|
56 |
public void buildOneLayer() { |
|
57 |
RasterDataStore mainRasterStore = panel.getResult(); |
|
58 |
saveMetadata(); |
|
59 |
|
|
60 |
DataProcess clippingProcess = null; |
|
61 |
try { |
|
62 |
clippingProcess = RasterBaseAlgorithmLibrary.getManager().createRasterTask("ClippingProcess"); |
|
63 |
} catch (ProcessException e) { |
|
64 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_processing_layer"), panel, e); |
|
65 |
} |
|
66 |
clippingProcess.setActions(this); |
|
67 |
String tit = PluginServices.getMDIManager().getWindowInfo(getView()).getTitle(); |
|
68 |
clippingProcess.addParam("viewname", tit); |
|
69 |
clippingProcess.addParam("pixelcoordinates", new int[] { 0, (int) mainRasterStore.getHeight(), (int) mainRasterStore.getWidth(), 0 }); |
|
70 |
clippingProcess.addParam("resolution", new int[]{(int) mainRasterStore.getWidth(), |
|
71 |
(int) mainRasterStore.getHeight()}); |
|
72 |
clippingProcess.addParam("suffix", ".tif"); |
|
73 |
|
|
74 |
clippingProcess.addParam("filename", folder + File.separator + file); |
|
75 |
clippingProcess.addParam("layer", mainRasterStore); |
|
76 |
int[] drawableBands = new int[mainRasterStore.getBandCount()]; |
|
77 |
for (int i = 0; i < drawableBands.length; i++) { |
|
78 |
drawableBands[i] = i; |
|
79 |
} |
|
80 |
clippingProcess.addParam("drawablebands", drawableBands); |
|
81 |
clippingProcess.addParam("onelayerperband", new Boolean(false)); |
|
82 |
clippingProcess.addParam("interpolationmethod", new Integer(Buffer.INTERPOLATION_NearestNeighbour)); |
|
83 |
clippingProcess.addParam("affinetransform", mainRasterStore.getAffineTransform()); |
|
84 |
|
|
85 |
|
|
86 |
/*if (params != null) |
|
87 |
RasterToolsUtil.loadWriterParamsFromPropertiesPanel(panelProperty, params); |
|
88 |
clippingProcess.addParam("driverparams", params);*/ |
|
89 |
clippingProcess.start(); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* |
|
94 |
*/ |
|
95 |
public void loadLayer() { |
|
96 |
RasterDataStore mainRasterStore = panel.getResult(); |
|
97 |
if(mainRasterStore == null) { |
|
98 |
return; |
|
99 |
} |
|
100 |
|
|
101 |
saveMff(mainRasterStore); |
|
102 |
saveMetadata(); |
|
103 |
try { |
|
104 |
loadLayerInView(mainRasterStore); |
|
105 |
} catch (LoadLayerException e) { |
|
106 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_loading_layer"), panel, e); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
private void saveMff(RasterDataStore mainRasterStore) { |
|
111 |
MultiFileDataParameters params = (MultiFileDataParameters)mainRasterStore.getParameters(); |
|
112 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
113 |
List<RasterProvider> providers = params.getProviders(); |
|
114 |
for (int i = 0; i < providers.size(); i++) { |
|
115 |
uriList.add(new File(providers.get(i).getURI())); |
|
116 |
} |
|
117 |
try { |
|
118 |
MultiFileFormat.saveMultiFileFormat(file, folder, uriList); |
|
119 |
} catch (IOException e) { |
|
120 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_salvando_mff"), panel, e); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
private void saveMetadata() { |
|
125 |
RasterDataStore mainRasterStore = panel.getResult(); |
|
126 |
int rBand = panel.getColorInterpretationByColorBandBand(RasterDataStore.RED_BAND); |
|
127 |
int gBand = panel.getColorInterpretationByColorBandBand(RasterDataStore.GREEN_BAND); |
|
128 |
int bBand = panel.getColorInterpretationByColorBandBand(RasterDataStore.BLUE_BAND); |
|
129 |
int aBand = panel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
|
130 |
|
|
131 |
if (!isCorrectAssignedBand(rBand, gBand, bBand, aBand)) { |
|
132 |
RasterSwingLibrary.messageBoxError(Messages.getText("combinacion_no_asignable"), panel); |
|
133 |
return; |
|
134 |
} |
|
135 |
|
|
136 |
try { |
|
137 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation( |
|
138 |
new String[mainRasterStore.getBandCount()]); |
|
139 |
// Combinaci?n GRAY |
|
140 |
if ((rBand == gBand) && (rBand == bBand) && (rBand >= 0)) { |
|
141 |
for (int iBand = 0; iBand < panel.getARGBTable().getRowCount(); iBand++) { |
|
142 |
ci.setColorInterpValue(iBand, ColorInterpretation.UNDEF_BAND); |
|
143 |
} |
|
144 |
ci.setColorInterpValue(rBand, ColorInterpretation.GRAY_BAND); |
|
145 |
ci.setColorInterpValue(aBand, ColorInterpretation.ALPHA_BAND); |
|
146 |
} else { |
|
147 |
// Combinaci?n RGB |
|
148 |
ci.setColorInterpValue(aBand, ColorInterpretation.ALPHA_BAND); |
|
149 |
ci.setColorInterpValue(rBand, ColorInterpretation.RED_BAND); |
|
150 |
ci.setColorInterpValue(gBand, ColorInterpretation.GREEN_BAND); |
|
151 |
ci.setColorInterpValue(bBand, ColorInterpretation.BLUE_BAND); |
|
152 |
} |
|
153 |
RasterLocator.getManager().getProviderServices().saveObjectToRmfFile(folder + File.separator + file, ci); |
|
154 |
} catch (RmfSerializerException exc) { |
|
155 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_salvando_rmf"), panel, exc); |
|
156 |
} catch (NotInitializeException exc) { |
|
157 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), panel, exc); |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
private void loadLayerInView(RasterDataStore mainRasterStore) throws LoadLayerException { |
|
162 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
163 |
FLyrRaster lyr = (FLyrRaster) mcm.createLayer(file, mainRasterStore); |
|
164 |
lyr.reload(); |
|
165 |
|
|
166 |
getView().getMapControl().getMapContext().beginAtomicEvent(); |
|
167 |
getView().getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
168 |
getView().getMapControl().getMapContext().invalidate(); |
|
169 |
getView().getMapControl().getMapContext().endAtomicEvent(); |
|
170 |
} |
|
171 |
|
|
172 |
private AbstractViewPanel getView() { |
|
173 |
if(selectedView == null) { |
|
174 |
IWindow[] wList = PluginServices.getMDIManager().getAllWindows(); |
|
175 |
for (int i = 0; i < wList.length; i++) { |
|
176 |
if(wList[i] instanceof AbstractViewPanel) |
|
177 |
selectedView = (AbstractViewPanel)wList[i]; |
|
178 |
} |
|
179 |
} |
|
180 |
return selectedView; |
|
181 |
} |
|
182 |
|
|
183 |
private boolean isCorrectAssignedBand(int r, int g, int b, int a) { |
|
184 |
// Si es gris es correcta la asignacion |
|
185 |
if ((r == g) && (r == b) && (r >= 0)) { |
|
186 |
// Si el alpha esta asignado a la misma banda es incorrecto |
|
187 |
if (r == a) |
|
188 |
return false; |
|
189 |
// En caso contrario es correcto |
|
190 |
return true; |
|
191 |
} |
|
192 |
|
|
193 |
// Si dos bandas coinciden, se dice que no es correcta la asignacion |
|
194 |
int list[] = { r, g, b, a }; |
|
195 |
for (int i = 0; i <= 3; i++) |
|
196 |
for (int j = 0; j <= 3; j++) |
|
197 |
if ((i != j) && (list[i] == list[j]) && (list[i] > -1)) |
|
198 |
return false; |
|
199 |
|
|
200 |
return true; |
|
201 |
} |
|
202 |
|
|
203 |
public void interrupted() { |
|
204 |
// TODO Auto-generated method stub |
|
205 |
|
|
206 |
} |
|
207 |
|
|
208 |
public void end(Object param) { |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
public void updateProgress(int current, int total) { |
|
213 |
// TODO Auto-generated method stub |
|
214 |
|
|
215 |
} |
|
216 |
} |
|
0 | 217 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/MultifileClientExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.multifile.app; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.util.Locale; |
|
27 |
|
|
28 |
import javax.swing.JComponent; |
|
29 |
|
|
30 |
import org.gvsig.andami.IconThemeHelper; |
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
import org.gvsig.andami.plugins.Extension; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.raster.multifile.app.panel.BandSelectorPanel; |
|
35 |
import org.gvsig.raster.multifile.app.panel.MainWindow; |
|
36 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
37 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
38 |
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
41 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
42 |
|
|
43 |
/** |
|
44 |
* Extension for adding grid netcdf support to gvSIG. |
|
45 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
46 |
*/ |
|
47 |
public class MultifileClientExtension extends Extension implements ActionListener { |
|
48 |
private CreateNewLayerPanel newLayerPanel = null; |
|
49 |
private MainWindow layerNamewindow = null; |
|
50 |
private MainWindow bandSelectorwindow = null; |
|
51 |
private MainDialogActions actions = null; |
|
52 |
|
|
53 |
public void initialize() { |
|
54 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
55 |
|
|
56 |
ExtensionPoint point = extensionPoints.get("AplicationPreferences"); |
|
57 |
point = extensionPoints.get("RasterSEPropertiesDialog"); |
|
58 |
point.append("Bandas", "", BandSelectorPanel.class); |
|
59 |
|
|
60 |
point = extensionPoints.add("GenericToolBarMenu"); |
|
61 |
point.append("Multifile", "", MultiFileCreatorTocMenuEntry.getSingleton()); |
|
62 |
MultiFileCreatorTocMenuEntry.setExtension(this); |
|
63 |
|
|
64 |
if (!Messages.hasLocales()) { |
|
65 |
Messages.addLocale(Locale.getDefault()); |
|
66 |
} |
|
67 |
|
|
68 |
Messages.addResourceFamily("org.gvsig.raster.multifile.app.i18n.text", |
|
69 |
MultifileClientExtension.class.getClassLoader(), |
|
70 |
MultifileClientExtension.class.getClass().getName()); |
|
71 |
|
|
72 |
initilizeIcons(); |
|
73 |
} |
|
74 |
|
|
75 |
public void execute(String actionCommand) { |
|
76 |
if (actionCommand.compareTo("MultifileCreator") == 0) { |
|
77 |
layerNamewindow = new MainWindow((JComponent)getNewLayerPanel(), |
|
78 |
Messages.getText("select_output_file"), 300, 150, this); |
|
79 |
PluginServices.getMDIManager().addCentredWindow(layerNamewindow); |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
private void initilizeIcons() { |
|
84 |
IconThemeHelper.registerIcon(null, "multifile-icon", this); |
|
85 |
} |
|
86 |
|
|
87 |
public boolean isEnabled() { |
|
88 |
return true; |
|
89 |
} |
|
90 |
|
|
91 |
public boolean isVisible() { |
|
92 |
return true; |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* @return CreateNewLayerPanel |
|
97 |
*/ |
|
98 |
public CreateNewLayerPanel getNewLayerPanel() { |
|
99 |
if(newLayerPanel == null) { |
|
100 |
newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(); |
|
101 |
} |
|
102 |
return newLayerPanel; |
|
103 |
} |
|
104 |
|
|
105 |
public void actionPerformed(ActionEvent e) { |
|
106 |
//Accept the window with the layer name |
|
107 |
if(e.getSource() == layerNamewindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT)) { |
|
108 |
String file = getNewLayerPanel().getFileSelected(); |
|
109 |
String folder = getNewLayerPanel().getDirectorySelected(); |
|
110 |
BandSelectorPanel panel = new BandSelectorPanel(BandSelectorPanel.TYPE_DIALOG); |
|
111 |
panel.getListener().setDestination(file, folder); |
|
112 |
actions = new MainDialogActions(panel, file, folder); |
|
113 |
bandSelectorwindow = new MainWindow(panel, Messages.getText("add_files"), 500, 400, this, true); |
|
114 |
PluginServices.getMDIManager().addCentredWindow(bandSelectorwindow); |
|
115 |
} |
|
116 |
|
|
117 |
//Button of load layer in the main dialog |
|
118 |
if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1)) { |
|
119 |
actions.loadLayer(); |
|
120 |
} |
|
121 |
|
|
122 |
//Button of create one file with al files |
|
123 |
if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2)) { |
|
124 |
actions.buildOneLayer(); |
|
125 |
} |
|
126 |
|
|
127 |
} |
|
128 |
} |
|
0 | 129 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/MultiFileCreatorTocMenuEntry.java | ||
---|---|---|
1 |
package org.gvsig.raster.multifile.app; |
|
2 |
|
|
3 |
import javax.swing.Icon; |
|
4 |
|
|
5 |
import org.gvsig.andami.IconThemeHelper; |
|
6 |
import org.gvsig.andami.plugins.Extension; |
|
7 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
8 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.i18n.Messages; |
|
11 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author gvSIG team |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class MultiFileCreatorTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
|
18 |
static private MultiFileCreatorTocMenuEntry singleton = null; |
|
19 |
private static Extension extension = null; |
|
20 |
|
|
21 |
|
|
22 |
/** |
|
23 |
* @param ext |
|
24 |
*/ |
|
25 |
public static void setExtension(Extension ext) { |
|
26 |
extension = ext; |
|
27 |
} |
|
28 |
|
|
29 |
private MultiFileCreatorTocMenuEntry() {} |
|
30 |
|
|
31 |
/** |
|
32 |
* @return MultiFileCreatorTocMenuEntry |
|
33 |
*/ |
|
34 |
static public MultiFileCreatorTocMenuEntry getSingleton() { |
|
35 |
if (singleton == null) |
|
36 |
singleton = new MultiFileCreatorTocMenuEntry(); |
|
37 |
return singleton; |
|
38 |
} |
|
39 |
|
|
40 |
public String getGroup() { |
|
41 |
return "Dataset"; |
|
42 |
} |
|
43 |
|
|
44 |
public int getGroupOrder() { |
|
45 |
return 55; |
|
46 |
} |
|
47 |
|
|
48 |
public int getOrder() { |
|
49 |
return 0; |
|
50 |
} |
|
51 |
|
|
52 |
public String getText() { |
|
53 |
return Messages.getText("create_multifile"); |
|
54 |
} |
|
55 |
|
|
56 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
57 |
return true; |
|
58 |
} |
|
59 |
|
|
60 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
61 |
return true; |
|
62 |
} |
|
63 |
|
|
64 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
65 |
extension.execute("MultifileCreator"); |
|
66 |
} |
|
67 |
|
|
68 |
public Icon getIcon() { |
|
69 |
return IconThemeHelper.getImageIcon("multifile-icon"); |
|
70 |
} |
|
71 |
|
|
72 |
} |
|
0 | 73 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorPropertiesListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.multifile.app.panel; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.io.File; |
|
27 |
import java.net.URI; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import org.apache.commons.io.FilenameUtils; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
35 |
import org.gvsig.fmap.dal.DALLocator; |
|
36 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
43 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
44 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
|
45 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanel; |
|
46 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
47 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
48 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
49 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
50 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
51 |
import org.gvsig.i18n.Messages; |
|
52 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
53 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
54 |
import org.gvsig.raster.mainplugin.RasterMainPluginUtils; |
|
55 |
import org.gvsig.raster.mainplugin.config.Configuration; |
|
56 |
import org.gvsig.raster.multifile.io.MultiFileDataParameters; |
|
57 |
import org.gvsig.raster.multifile.io.MultiFileProvider; |
|
58 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
59 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
60 |
|
|
61 |
/** |
|
62 |
* Clase que maneja los eventos del panel BandSetupPanel. Gestiona el a?adir o |
|
63 |
* eliminar ficheros de la lista y contiene las acciones a realizar cuando en |
|
64 |
* panel registrable se pulsa aceptar, aplicar o cancelar. |
|
65 |
* |
|
66 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
67 |
*/ |
|
68 |
public class BandSelectorPropertiesListener extends AbstractBandSelectorListener { |
|
69 |
private JFileChooser fileChooser = null; |
|
70 |
private FLyrRaster fLayer = null; |
|
71 |
private List<File> fileList = null; |
|
72 |
|
|
73 |
/** |
|
74 |
* Constructor |
|
75 |
* @param bs Panel del selector de bandas |
|
76 |
*/ |
|
77 |
public BandSelectorPropertiesListener(BandSelectorPanel bs) { |
|
78 |
super(bs); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Constructor |
|
83 |
* @param lyr Capa raster |
|
84 |
*/ |
|
85 |
public void init(FLyrRaster lyr) { |
|
86 |
fLayer = lyr; |
|
87 |
} |
|
88 |
|
|
89 |
public RasterDataStore getResult() { |
|
90 |
return fLayer.getDataStore(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Listener para la gesti?n de los botones de a?adir, eliminar fichero y |
|
95 |
* el combo de selecci?n de bandas. |
|
96 |
*/ |
|
97 |
public void actionPerformed(ActionEvent e) { |
|
98 |
super.actionPerformed(e); |
|
99 |
|
|
100 |
if (e.getSource().equals(bandSetupPanel.getNumBandSelectorCombo())) { |
|
101 |
String vBands = (String) bandSetupPanel.getNumBandSelectorCombo().getSelectedItem(); |
|
102 |
if (vBands != null) { |
|
103 |
if (vBands.compareTo("3") == 0) |
|
104 |
bandSetupPanel.resetMode(3); |
|
105 |
|
|
106 |
if (vBands.compareTo("2") == 0) |
|
107 |
bandSetupPanel.resetMode(2); |
|
108 |
|
|
109 |
if (vBands.compareTo("1") == 0) |
|
110 |
bandSetupPanel.resetMode(1); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
if (e.getSource().equals(bandSetupPanel.getSaveButton())) { |
|
115 |
int numBandToRed = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.RED_BAND); |
|
116 |
int numBandToGreen = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.GREEN_BAND); |
|
117 |
int numBandToBlue = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.BLUE_BAND); |
|
118 |
int numBandToAlpha = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
|
119 |
|
|
120 |
if (!isCorrectAssignedBand(numBandToRed, numBandToGreen, numBandToBlue, numBandToAlpha)) { |
|
121 |
RasterSwingLibrary.messageBoxError(Messages.getText("combinacion_no_asignable"), bandSetupPanel); |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
RasterSwingLibrary.messageBoxYesOrNot(Messages.getText("color_interpretation_continue"), this); |
|
126 |
RasterDataStore dataSource = fLayer.getDataStore(); |
|
127 |
if(dataSource == null) { |
|
128 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_carga_capa"), bandSetupPanel); |
|
129 |
return; |
|
130 |
} |
|
131 |
|
|
132 |
//ColorInterpretation ci = dataSource.getColorInterpretation(); |
|
133 |
try { |
|
134 |
String[] bands = new String[bandSetupPanel.getARGBTable().getRowCount()]; |
|
135 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation(bands); |
|
136 |
|
|
137 |
// Combinaci?n GRAY |
|
138 |
if ((numBandToRed == numBandToGreen) && (numBandToRed == numBandToBlue) && (numBandToRed >= 0)) { |
|
139 |
for (int iBand = 0; iBand < bandSetupPanel.getARGBTable().getRowCount(); iBand++) { |
|
140 |
ci.setColorInterpValue(iBand, ColorInterpretation.UNDEF_BAND); |
|
141 |
} |
|
142 |
ci.setColorInterpValue(0, ColorInterpretation.GRAY_BAND); |
|
143 |
ci.setColorInterpValue(numBandToAlpha, ColorInterpretation.ALPHA_BAND); |
|
144 |
} else { |
|
145 |
// Combinaci?n RGB |
|
146 |
for (int iBand = 0; iBand < bandSetupPanel.getARGBTable().getRowCount(); iBand++) |
|
147 |
ci.setColorInterpValue(iBand, bandSetupPanel.getColorInterpretationByBand(iBand)); |
|
148 |
} |
|
149 |
String fileName = fLayer.getDataStore().getName(); |
|
150 |
dataSource.setColorInterpretation(ci); |
|
151 |
RasterLocator.getManager().getProviderServices().saveObjectToRmfFile(fileName, ci); |
|
152 |
} catch (RmfSerializerException exc) { |
|
153 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_salvando_rmf"), bandSetupPanel, exc); |
|
154 |
} catch (NotInitializeException exc) { |
|
155 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), bandSetupPanel, exc); |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
boolean autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
|
160 |
|
|
161 |
if (!autoRefreshView) |
|
162 |
return; |
|
163 |
|
|
164 |
bandSetupPanel.onlyApply(); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* A?ade una banda al raster |
|
169 |
*/ |
|
170 |
public void addFileBand() { |
|
171 |
fileChooser = createJFileChooser(); |
|
172 |
int result = fileChooser.showOpenDialog(bandSetupPanel); |
|
173 |
|
|
174 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
175 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
176 |
File[] files = fileChooser.getSelectedFiles(); |
|
177 |
|
|
178 |
JFileChooser.setLastPath(FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, files[0]); |
|
179 |
|
|
180 |
fileList = new ArrayList<File>(); |
|
181 |
|
|
182 |
for (int i = 0; i < files.length; i++) { |
|
183 |
//Checks that the file does not exist |
|
184 |
URI[] uris = dataStore.getURIByProvider(); |
|
185 |
boolean exists = false; |
|
186 |
for (int j = 0; j < uris.length; j++) { |
|
187 |
if (new File(uris[j]).getAbsolutePath().endsWith(files[i].getName())) { |
|
188 |
RasterSwingLibrary.messageBoxError( Messages.getText("fichero_existe") + ": " + files[i].getAbsolutePath(), bandSetupPanel); |
|
189 |
exists = true; |
|
190 |
break; |
|
191 |
} |
|
192 |
} |
|
193 |
if(!exists) |
|
194 |
fileList.add(files[i]); |
|
195 |
} |
|
196 |
|
|
197 |
if(!checkStoresCompatibility(fLayer.getDataStore(), fileList)) |
|
198 |
return; |
|
199 |
|
|
200 |
if(dataStore.isMultiFile()) { |
|
201 |
for (int i = 0; i < fileList.size(); i++) { |
|
202 |
try { |
|
203 |
dataStore.addFile(fileList.get(i)); |
|
204 |
} catch (InvalidSourceException e) { |
|
205 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, e); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
dataStore.setProvider(dataStore.getProvider()); |
|
210 |
|
|
211 |
//It shows the files and bands in the panel |
|
212 |
try { |
|
213 |
bandSetupPanel.addFiles(dataStore); |
|
214 |
} catch (NotInitializeException e) { |
|
215 |
RasterSwingLibrary.messageBoxError("table_not_initialize", this, e); |
|
216 |
} |
|
217 |
} else { |
|
218 |
//New layer name |
|
219 |
WindowInfo wi = PluginServices.getMDIManager().getActiveWindow().getWindowInfo(); |
|
220 |
LayerNameDialog dialog = new LayerNameDialog(new Point2D.Double(wi.getX(), wi.getY()), 300, 80, this); |
|
221 |
RasterMainPluginUtils.addWindow(dialog); |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha |
|
228 |
* seleccionado ninguna banda no hace nada. |
|
229 |
* |
|
230 |
*/ |
|
231 |
public void delFileBand() { |
|
232 |
Object[] objects = bandSetupPanel.getFileList().getJList().getSelectedValues(); |
|
233 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
234 |
|
|
235 |
for (int i = objects.length - 1; i >= 0; i--) { |
|
236 |
if (bandSetupPanel.getFileList().getNFiles() > 1) { |
|
237 |
String pathName = objects[i].toString(); |
|
238 |
dataStore.removeFile(new File(pathName)); |
|
239 |
|
|
240 |
String file = pathName.substring(pathName.lastIndexOf(File.separator) + 1); |
|
241 |
file = file.substring(file.lastIndexOf("\\") + 1); |
|
242 |
bandSetupPanel.removeFile(file); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
setNewBandsPositionInRendering(); |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Catchs the events from LayerNameDialog to get the name of the new layer |
|
251 |
*/ |
|
252 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
253 |
String layerName = (String)e.getSource(); |
|
254 |
|
|
255 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
256 |
RasterDataParameters paramFirstFile = (RasterDataParameters)dataStore.getParameters();//(RasterDataParameters)((RasterProvider)dataStore.getProvider()).getDataParameters(); |
|
257 |
|
|
258 |
File firstFile = new File(paramFirstFile.getURI()); |
|
259 |
String path = FilenameUtils.getFullPath(firstFile.getAbsolutePath()); |
|
260 |
|
|
261 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
262 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
263 |
|
|
264 |
try { |
|
265 |
MultiFileProvider provMultifile = createMultiFileProvider(layerName, path); |
|
266 |
MultiFileDataParameters newParamsMultifile = (MultiFileDataParameters)provMultifile.getDataParameters(); |
|
267 |
newParamsMultifile.addProvider(dataStore); |
|
268 |
|
|
269 |
//And now it creates and adds the new ones |
|
270 |
for (int i = 0; i < fileList.size(); i++) { |
|
271 |
ArrayList<RasterDataParameters> storeParametersList = provServ.createParametersList(fileList.get(i)); //.getAbsolutePath()); |
|
272 |
for (int j = 0; j < storeParametersList.size(); j++) { |
|
273 |
DataStoreProvider newFileProv = dataManager.createProvider((DataStoreProviderServices)dataStore, storeParametersList.get(j)); |
|
274 |
newParamsMultifile.addProviderNotTiled(newFileProv); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
((DefaultFLyrRaster)fLayer).setName(layerName); |
|
279 |
//Assigns the MultifileProvider to the store |
|
280 |
dataStore.setProvider((CoverageStoreProvider)provMultifile); |
|
281 |
|
|
282 |
//It shows the files and bands in the panel |
|
283 |
try { |
|
284 |
bandSetupPanel.addFiles(dataStore); |
|
285 |
} catch (NotInitializeException ex) { |
|
286 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), this, ex); |
|
287 |
} |
|
288 |
|
|
289 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
290 |
uriList.add(firstFile); |
|
291 |
for (int i = 0; i < fileList.size(); i++) { |
|
292 |
uriList.add(fileList.get(i)); |
|
293 |
} |
|
294 |
saveMultiFileLayer(layerName, path, uriList); |
|
295 |
|
|
296 |
} catch (Exception exc) { |
|
297 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, exc); |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* Acciones a ejecutar cuando se aplica |
|
303 |
*/ |
|
304 |
public void apply() { |
|
305 |
if (enabled) |
|
306 |
setNewBandsPositionInRendering(); |
|
307 |
} |
|
308 |
|
|
309 |
public void setNewBandsPositionInRendering() { |
|
310 |
if (fLayer != null && fLayer.getRender() != null) { |
|
311 |
fLayer.getRender().setRenderColorInterpretation(bandSetupPanel.getSelectedColorInterpretation()); |
|
312 |
|
|
313 |
int alphaBand = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
|
314 |
Transparency gt = fLayer.getRender().getRenderingTransparency(); |
|
315 |
if(gt != null) |
|
316 |
gt.setTransparencyBand(alphaBand); |
|
317 |
fLayer.getMapContext().invalidate(); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
} |
|
0 | 322 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/MainWindow.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.multifile.app.panel; |
|
22 |
|
|
23 |
import java.awt.BorderLayout; |
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
|
|
27 |
import javax.swing.JComponent; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
32 |
import org.gvsig.i18n.Messages; |
|
33 |
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel; |
|
34 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons |
|
39 |
* of Cancel, Accept and others. |
|
40 |
* |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class MainWindow extends AbstractButtonsPanel implements IWindow, ActionListener { |
|
44 |
|
|
45 |
private static final long serialVersionUID = -4401123724140025094L; |
|
46 |
private ActionListener listener = null; |
|
47 |
private WindowInfo info = null; |
|
48 |
|
|
49 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
50 |
|
|
51 |
/** |
|
52 |
* @param panel |
|
53 |
* @param title |
|
54 |
* @param w |
|
55 |
* @param h |
|
56 |
* @param actionListener |
|
57 |
*/ |
|
58 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener) { |
|
59 |
this.listener = actionListener; |
|
60 |
|
|
61 |
setLayout(new BorderLayout()); |
|
62 |
add(panel, BorderLayout.CENTER); |
|
63 |
|
|
64 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
65 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
66 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
67 |
|
|
68 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
69 |
info.setTitle(title); |
|
70 |
info.setWidth(w); |
|
71 |
info.setHeight(h); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @param panel |
|
76 |
* @param title |
|
77 |
* @param w |
|
78 |
* @param h |
|
79 |
* @param actionListener |
|
80 |
* @param mainPanel |
|
81 |
*/ |
|
82 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener, boolean mainPanel) { |
|
83 |
this.listener = actionListener; |
|
84 |
|
|
85 |
setLayout(new BorderLayout()); |
|
86 |
add(panel, BorderLayout.CENTER); |
|
87 |
|
|
88 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
89 |
|
|
90 |
if(mainPanel) { |
|
91 |
getButtonsPanel().addButton(Messages.getText("load_layer"), IButtonsPanel.BUTTON_USR1); |
|
92 |
getButtonsPanel().addButton(Messages.getText("generate_file"), IButtonsPanel.BUTTON_USR2); |
|
93 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
94 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).setVisible(false); |
|
95 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).setVisible(false); |
|
96 |
getButtonsPanel().addClose(); |
|
97 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CLOSE).addActionListener(this); |
|
98 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1).addActionListener(this); |
|
99 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2).addActionListener(this); |
|
100 |
} else { |
|
101 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
102 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
103 |
} |
|
104 |
|
|
105 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE); |
|
106 |
info.setTitle(title); |
|
107 |
info.setWidth(w); |
|
108 |
info.setHeight(h); |
|
109 |
} |
|
110 |
|
|
111 |
public WindowInfo getWindowInfo() { |
|
112 |
return info; |
|
113 |
} |
|
114 |
|
|
115 |
public Object getWindowProfile() { |
|
116 |
return profile; |
|
117 |
} |
|
118 |
|
|
119 |
public void actionPerformed(ActionEvent e) { |
|
120 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1)) { |
|
121 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_USR1, e.getActionCommand())); |
|
122 |
PluginServices.getMDIManager().closeWindow(this); |
|
123 |
} |
|
124 |
|
|
125 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2)) { |
|
126 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_USR2, e.getActionCommand())); |
|
127 |
PluginServices.getMDIManager().closeWindow(this); |
|
128 |
} |
|
129 |
|
|
130 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT)) { |
|
131 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_ACCEPT, e.getActionCommand())); |
|
132 |
PluginServices.getMDIManager().closeWindow(this); |
|
133 |
} |
|
134 |
|
|
135 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY)) { |
|
136 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_APPLY, e.getActionCommand())); |
|
137 |
} |
|
138 |
|
|
139 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL)) { |
|
140 |
PluginServices.getMDIManager().closeWindow(this); |
|
141 |
} |
|
142 |
|
|
143 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_CLOSE)) { |
|
144 |
PluginServices.getMDIManager().closeWindow(this); |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
0 | 148 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/LayerNameDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.multifile.app.panel; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.awt.GridBagConstraints; |
|
23 |
import java.awt.GridBagLayout; |
|
24 |
import java.awt.Insets; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
import javax.swing.JPanel; |
|
29 |
import javax.swing.JTextField; |
|
30 |
|
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
34 |
import org.gvsig.i18n.Messages; |
|
35 |
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel; |
|
36 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
37 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelListener; |
|
38 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
39 |
|
|
40 |
/** |
|
41 |
* <code>LayerNameDialog</code>. |
|
42 |
* Window to introduce the name of the new layer |
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
44 |
*/ |
|
45 |
public class LayerNameDialog extends AbstractButtonsPanel implements IWindow, ButtonsPanelListener { |
|
46 |
private static final long serialVersionUID = 7362459094802955247L; |
|
47 |
private JPanel panel = null; |
|
48 |
private String layerName = null; |
|
49 |
private JTextField name = null; |
|
50 |
private ButtonsPanelListener listener = null; |
|
51 |
private Point2D position = null; |
|
52 |
|
|
53 |
/** |
|
54 |
* Builds a new window. |
|
55 |
* @param position |
|
56 |
* @param width |
|
57 |
* @param height |
|
58 |
* @param listener |
|
59 |
*/ |
|
60 |
public LayerNameDialog(Point2D position, int width, int height, ButtonsPanelListener listener) { |
|
61 |
super(IButtonsPanel.BUTTONS_ACCEPTCANCEL); |
|
62 |
this.position = position; |
|
63 |
layerName = null; |
|
64 |
this.listener = listener; |
|
65 |
this.setSize(width, height); |
|
66 |
this.setLayout(new BorderLayout(5, 5)); |
|
67 |
this.add(getMainPanel(), java.awt.BorderLayout.CENTER); |
|
68 |
this.addButtonPressedListener(this); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Builds a new window. |
|
73 |
* @param width |
|
74 |
* @param height |
|
75 |
* @param listener |
|
76 |
*/ |
|
77 |
public LayerNameDialog(int width, int height, ButtonsPanelListener listener) { |
|
78 |
this(new Point2D.Double(), width, height, listener); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Gets the main panel |
|
83 |
* @return JPanel |
|
84 |
*/ |
|
85 |
public JPanel getMainPanel() { |
|
86 |
if (panel == null) { |
|
87 |
panel = new JPanel(); |
|
88 |
panel.setLayout(new GridBagLayout()); |
|
89 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
90 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
91 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
92 |
gbc.anchor = GridBagConstraints.CENTER; |
|
93 |
gbc.weightx = 1.0; |
|
94 |
panel.add(getNameField(), gbc); |
|
95 |
} |
|
96 |
return panel; |
|
97 |
} |
|
98 |
|
|
99 |
private JTextField getNameField() { |
|
100 |
if(name == null) { |
|
101 |
name = new JTextField(); |
|
102 |
} |
|
103 |
return name; |
|
104 |
} |
|
105 |
|
|
106 |
public WindowInfo getWindowInfo() { |
|
107 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
108 |
m_viewinfo.setTitle(Messages.getText("layer_name")); |
|
109 |
m_viewinfo.setHeight(this.getHeight()); |
|
110 |
m_viewinfo.setWidth(this.getWidth()); |
|
111 |
m_viewinfo.setX((int)position.getX()); |
|
112 |
m_viewinfo.setY((int)position.getY()); |
|
113 |
return m_viewinfo; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Cancel actions |
|
118 |
*/ |
|
119 |
private void close() { |
|
120 |
try { |
|
121 |
PluginServices.getMDIManager().closeWindow(this); |
|
122 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
123 |
//Si la ventana no se puede eliminar no hacemos nada |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* Accept actions |
|
129 |
*/ |
|
130 |
private void accept() { |
|
131 |
String txt = getNameField().getText(); |
|
132 |
if(txt == null || txt.compareTo("") == 0) { |
|
133 |
JOptionPane.showMessageDialog(null, Messages.getText("character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
134 |
return; |
|
135 |
} |
|
136 |
|
|
137 |
byte[] byteList = txt.getBytes(); |
|
138 |
for (int i = 0; i < byteList.length; i++) { |
|
139 |
if(byteList[i] < 45 || |
|
140 |
(byteList[i] > 45 && byteList[i] < 48) || |
|
141 |
(byteList[i] > 57 && byteList[i] < 65) || |
|
142 |
(byteList[i] > 90 && byteList[i] < 95) || |
|
143 |
(byteList[i] > 95 && byteList[i] < 97) || |
|
144 |
(byteList[i] > 122 && byteList[i] < 126) || |
|
145 |
(byteList[i] > 126)) { |
|
146 |
JOptionPane.showMessageDialog(null, Messages.getText("character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
147 |
return; |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
layerName = txt; |
|
152 |
close(); |
|
153 |
listener.actionButtonPressed(new ButtonsPanelEvent(layerName, IButtonsPanel.BUTTON_ACCEPT)); |
|
154 |
} |
|
155 |
|
|
156 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
157 |
if (e.getButton() == IButtonsPanel.BUTTON_CANCEL) { |
|
158 |
close(); |
|
159 |
} |
|
160 |
|
|
161 |
if (e.getButton() == IButtonsPanel.BUTTON_ACCEPT) { |
|
162 |
accept(); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
public Object getWindowProfile() { |
|
167 |
return WindowInfo.PROPERTIES_PROFILE; |
|
168 |
} |
|
169 |
} |
|
0 | 170 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.113/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/AbstractBandSelectorListener.java | ||
---|---|---|
1 |
package org.gvsig.raster.multifile.app.panel; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.awt.geom.Rectangle2D; |
|
6 |
import java.io.File; |
|
7 |
import java.io.IOException; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
import javax.swing.JOptionPane; |
|
12 |
|
|
13 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
14 |
import org.gvsig.fmap.dal.DALLocator; |
|
15 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
16 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
17 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
18 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
19 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
20 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
21 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
22 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
23 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
24 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
25 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanel; |
|
26 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.raster.multifile.io.MultiFileDataParameters; |
|
29 |
import org.gvsig.raster.multifile.io.MultiFileFormat; |
|
30 |
import org.gvsig.raster.multifile.io.MultiFileProvider; |
|
31 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
32 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelListener; |
|
33 |
import org.gvsig.tools.locator.LocatorException; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
/** |
|
38 |
* Listener for <code>BandSelectorPanel</code>. This interface is implemented by two listeners |
|
39 |
* , the new layer listener and the properties panel listener. |
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
41 |
*/ |
|
42 |
public abstract class AbstractBandSelectorListener implements ActionListener, ButtonsPanelListener { |
|
43 |
protected Logger log = LoggerFactory.getLogger(AbstractBandSelectorListener.class); |
|
44 |
protected BandSelectorPanel bandSetupPanel = null; |
|
45 |
protected boolean enabled = true; |
|
46 |
protected String file = null; |
|
47 |
protected String folder = null; |
|
48 |
|
|
49 |
/** |
|
50 |
* Constructor |
|
51 |
* @param bs Panel del selector de bandas |
|
52 |
* @param lyr Capa raster |
|
53 |
*/ |
|
54 |
public AbstractBandSelectorListener(BandSelectorPanel bs) { |
|
55 |
this.bandSetupPanel = bs; |
|
56 |
bs.getFileList().getJButtonAdd().addActionListener(this); |
|
57 |
bs.getFileList().getJButtonRemove().addActionListener(this); |
|
58 |
bs.getNumBandSelectorCombo().addActionListener(this); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* @param file |
|
63 |
* @param folder |
|
64 |
*/ |
|
65 |
public void setDestination(String file, String folder) { |
|
66 |
this.file = file; |
|
67 |
this.folder = folder; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Enables or disables the panel action |
|
72 |
* @param enabled |
|
73 |
*/ |
|
74 |
public void setEnabledPanelAction(boolean enabled) { |
|
75 |
this.enabled = enabled; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Sets the band position when these are rendered. The position is read from |
|
80 |
* the band table |
|
81 |
*/ |
|
82 |
public abstract void setNewBandsPositionInRendering(); |
|
83 |
|
|
84 |
/** |
|
85 |
* @return RasterDataStore |
|
86 |
*/ |
|
87 |
public abstract RasterDataStore getResult(); |
|
88 |
|
|
89 |
/** |
|
90 |
* Actions when is applied |
|
91 |
*/ |
|
92 |
public abstract void apply(); |
|
93 |
|
|
94 |
/** |
|
95 |
* |
|
96 |
*/ |
|
97 |
public abstract void addFileBand(); |
|
98 |
|
|
99 |
/** |
|
100 |
* |
|
101 |
*/ |
|
102 |
public abstract void delFileBand(); |
|
103 |
|
|
104 |
/** |
|
105 |
* Listener para la gesti?n de los botones de a?adir, eliminar fichero y |
|
106 |
* el combo de selecci?n de bandas. |
|
107 |
*/ |
|
108 |
public void actionPerformed(ActionEvent e) { |
|
109 |
|
|
110 |
if (e.getSource().equals(bandSetupPanel.getFileList().getJButtonAdd())) |
|
111 |
addFileBand(); |
|
112 |
|
|
113 |
if (e.getSource().equals(bandSetupPanel.getFileList().getJButtonRemove())) |
|
114 |
delFileBand(); |
|
115 |
} |
|
116 |
|
|
117 |
protected JFileChooser createJFileChooser() { |
|
118 |
JFileChooser fileChooser = new JFileChooser( |
|
119 |
FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, |
|
120 |
JFileChooser.getLastPath(FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, null)); |
|
121 |
fileChooser.setMultiSelectionEnabled(true); |
|
122 |
fileChooser.setAcceptAllFileFilterUsed(false); |
|
123 |
|
|
124 |
fileChooser.addChoosableFileFilter(new DriverFileFilter()); |
|
125 |
return fileChooser; |
|
126 |
} |
|
127 |
|
|
128 |
protected boolean checkStoresCompatibility(RasterDataStore mainRasterStore, List<File> fileList) { |
|
129 |
for (int i = fileList.size() - 1; i >= 0; i--) { |
|
130 |
//Checks extents |
|
131 |
try { |
|
132 |
if(!checkNewFile(mainRasterStore, fileList.get(i).getAbsolutePath())) { |
|
133 |
JOptionPane.showMessageDialog(null, Messages.getText("extents_no_coincidentes") + " " + fileList.get(i).getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE); |
|
134 |
fileList.remove(i); |
|
135 |
} |
|
136 |
} catch (Exception e) { |
|
137 |
log.debug("Problems check the bounding boxes", e); |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
if(mainRasterStore.isTiled()) { |
|
142 |
if(!RasterSwingLibrary.messageBoxYesOrNot(Messages.getText("store_tiled"), this)) { |
|
143 |
return false; |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
return true; |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* Creates a multifile data provider |
|
152 |
* @param layerName |
|
153 |
* @param path |
|
154 |
* @return |
|
155 |
*/ |
|
156 |
protected MultiFileProvider createMultiFileProvider(String layerName, String path) { |
|
157 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
158 |
|
|
159 |
try { |
|
160 |
//It creates the new Multifile provider |
|
161 |
MultiFileDataParameters newParamsMultifile = (MultiFileDataParameters)dataManager.createStoreParameters(MultiFileProvider.NAME); |
|
162 |
|
|
163 |
if(!path.endsWith(File.separator)) |
|
164 |
path = path + File.separator; |
|
165 |
File fileURI = new File(path + layerName + ".mff"); |
|
166 |
File rmfURI = new File(path + layerName + ".rmf"); |
|
167 |
int counter = 0; |
|
168 |
while(fileURI.exists() || rmfURI.exists()) { |
|
169 |
fileURI = new File(path + layerName + "_" + counter + ".mff"); |
|
170 |
rmfURI = new File(path + layerName + "_" + counter + ".rmf"); |
|
171 |
counter ++; |
|
172 |
} |
|
173 |
if(counter > 0) |
|
174 |
layerName += "_" + counter; |
|
175 |
|
|
176 |
newParamsMultifile.setURI(fileURI.toURI()); |
|
177 |
|
|
178 |
return (MultiFileProvider)dataManager.createProvider(null, newParamsMultifile); |
|
179 |
} catch (Exception exc) { |
|
180 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, exc); |
|
181 |
} |
|
182 |
return null; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Comprobar si la asignacion de color es correcta para las 4 bandas. No puede |
|
187 |
* existir una banda con distintas interpretaciones de color. Se comprueban dos |
|
188 |
* casos, asignaciones en escala de grises o en RGB. |
|
189 |
* @param r |
|
190 |
* @param g |
|
191 |
* @param b |
|
192 |
* @param a |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
protected boolean isCorrectAssignedBand(int r, int g, int b, int a) { |
|
196 |
// Si es gris es correcta la asignacion |
|
197 |
if ((r == g) && (r == b) && (r >= 0)) { |
|
198 |
// Si el alpha esta asignado a la misma banda es incorrecto |
|
199 |
if (r == a) |
|
200 |
return false; |
|
201 |
// En caso contrario es correcto |
|
202 |
return true; |
|
203 |
} |
|
204 |
|
|
205 |
// Si dos bandas coinciden, se dice que no es correcta la asignacion |
Also available in: Unified diff