Revision 463
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/tool/SaveRasterListenerImpl.java | ||
---|---|---|
24 | 24 |
import java.awt.Image; |
25 | 25 |
import java.awt.geom.Rectangle2D; |
26 | 26 |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 | 27 |
import org.gvsig.fmap.geom.primitive.Envelope; |
29 | 28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
30 | 29 |
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
... | ... | |
39 | 38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
40 | 39 |
*/ |
41 | 40 |
public class SaveRasterListenerImpl implements RectangleListener { |
42 |
private final Image isaveraster = PluginServices.getIconTheme().get("rect-select-cursor").getImage(); |
|
43 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(isaveraster, |
|
44 |
// new Point(16, 16), ""); |
|
45 | 41 |
protected MapControl mapCtrl; |
46 | 42 |
|
47 | 43 |
protected Rectangle2D pixelRect = null; |
... | ... | |
79 | 75 |
return true; |
80 | 76 |
} |
81 | 77 |
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getImageCursor() |
|
85 |
*/ |
|
86 | 78 |
public Image getImageCursor() { |
87 |
return isaveraster;
|
|
79 |
return null;
|
|
88 | 80 |
} |
81 |
|
|
89 | 82 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/FLyrRaster.java | ||
---|---|---|
125 | 125 |
* Obtiene la proyecci?n del fichero. |
126 | 126 |
* @return IProjection |
127 | 127 |
*/ |
128 |
public IProjection readProjection(); |
|
128 |
public IProjection readProjection() throws RasterDriverException;
|
|
129 | 129 |
|
130 | 130 |
/** |
131 | 131 |
* Gets the tile size |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/GeorefPanListenerImpl.java | ||
---|---|---|
25 | 25 |
import java.awt.geom.Point2D; |
26 | 26 |
import java.awt.geom.Rectangle2D; |
27 | 27 |
|
28 |
import org.gvsig.andami.PluginServices; |
|
29 | 28 |
import org.gvsig.fmap.geom.GeometryLocator; |
30 | 29 |
import org.gvsig.fmap.geom.GeometryManager; |
31 | 30 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
... | ... | |
51 | 50 |
private static final Logger logger = LoggerFactory.getLogger(GeorefPanListenerImpl.class); |
52 | 51 |
// private final Image ipan = new ImageIcon(MapControl.class.getResource( |
53 | 52 |
// "images/CruxCursor.png")).getImage(); |
54 |
private final Image ipan = PluginServices.getIconTheme().get("crux-cursor").getImage(); |
|
55 | 53 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan, |
56 | 54 |
// new Point(16, 16), ""); |
57 | 55 |
private MapControl mapControl; |
... | ... | |
139 | 137 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getImageCursor() |
140 | 138 |
*/ |
141 | 139 |
public Image getImageCursor() { |
142 |
return ipan;
|
|
140 |
return null;
|
|
143 | 141 |
} |
144 | 142 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/StatusLayerRaster.java | ||
---|---|---|
24 | 24 |
import java.util.ArrayList; |
25 | 25 |
import java.util.List; |
26 | 26 |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
30 | 27 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
31 | 28 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
32 | 29 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
... | ... | |
43 | 40 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
44 | 41 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
45 | 42 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
43 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
46 | 44 |
import org.gvsig.tools.ToolsLocator; |
47 | 45 |
import org.gvsig.tools.dynobject.DynStruct; |
48 | 46 |
import org.gvsig.tools.persistence.PersistenceManager; |
... | ... | |
275 | 273 |
} |
276 | 274 |
|
277 | 275 |
//Refrescamos todas las vistas |
278 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
276 |
layer.getMapContext().invalidate(); |
|
277 |
/*IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
279 | 278 |
for (int i = 0; i < w.length; i++) { |
280 | 279 |
if(w[i] != null && w[i] instanceof AbstractViewPanel) |
281 | 280 |
((AbstractViewPanel)w[i]).getMapControl().getMapContext().invalidate(); |
282 |
} |
|
281 |
}*/
|
|
283 | 282 |
} |
284 | 283 |
|
285 | 284 |
/** |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java | ||
---|---|---|
97 | 97 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
98 | 98 |
import org.gvsig.fmap.dal.exception.ReadException; |
99 | 99 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
100 |
import org.gvsig.fmap.dal.raster.impl.DefaultCoverageStore;
|
|
100 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices;
|
|
101 | 101 |
import org.gvsig.fmap.geom.GeometryLocator; |
102 | 102 |
import org.gvsig.fmap.geom.GeometryManager; |
103 | 103 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
... | ... | |
119 | 119 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener; |
120 | 120 |
import org.gvsig.raster.fmap.legend.ColorTableLegend; |
121 | 121 |
import org.gvsig.raster.util.RasterNotLoadException; |
122 |
import org.gvsig.raster.util.RasterToolsUtil; |
|
123 | 122 |
import org.gvsig.tools.ToolsLocator; |
124 | 123 |
import org.gvsig.tools.dynobject.DynClass; |
125 | 124 |
import org.gvsig.tools.dynobject.DynObjectManager; |
... | ... | |
261 | 260 |
if(isClosed()) |
262 | 261 |
enableAwake(); |
263 | 262 |
} catch (NotAvailableStateException e) { |
264 |
RasterToolsUtil.messageBoxError("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), this, e);
|
|
263 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), this, e);
|
|
265 | 264 |
} |
266 | 265 |
} |
267 | 266 |
|
... | ... | |
339 | 338 |
try { |
340 | 339 |
this.init(); |
341 | 340 |
} catch (FilePaletteException e) { |
342 |
RasterToolsUtil.messageBoxError(e.getMessage(), this, e);
|
|
341 |
throw new LoadLayerException("", e);
|
|
343 | 342 |
} |
344 | 343 |
} |
345 | 344 |
|
... | ... | |
365 | 364 |
try { |
366 | 365 |
enableOpen(); |
367 | 366 |
} catch (NotAvailableStateException e) { |
368 |
RasterToolsUtil.messageBoxError("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
|
|
367 |
throw new LoadLayerException("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), e);
|
|
369 | 368 |
} |
370 | 369 |
} |
371 | 370 |
|
... | ... | |
373 | 372 |
* (non-Javadoc) |
374 | 373 |
* @see org.gvsig.raster.fmap.layers.FLyrRaster#readProjection() |
375 | 374 |
*/ |
376 |
public IProjection readProjection() { |
|
375 |
public IProjection readProjection() throws RasterDriverException {
|
|
377 | 376 |
try { |
378 | 377 |
crsUtil.setCRSFactory(CRSFactory.cp); |
379 | 378 |
if( dataStore == null ) |
380 | 379 |
return null; |
381 | 380 |
return crsUtil.convertWktToIProjection(dataStore.getWktProjection()); |
382 |
} catch (RasterDriverException e) { |
|
383 |
RasterToolsUtil.messageBoxError("Problemas accediendo a getWktProjection. Driver no inicializado", this, e); |
|
384 | 381 |
} catch (Exception e) { |
385 |
RasterToolsUtil.debug("Problems converting from WKT to IProjection", this, e); |
|
386 |
e.printStackTrace(); |
|
387 |
return null; |
|
382 |
throw new RasterDriverException("Problems converting from WKT to IProjection", e); |
|
388 | 383 |
} catch (Error e) { |
389 | 384 |
e.printStackTrace(); |
390 | 385 |
return null; |
391 | 386 |
} |
392 |
return null; |
|
393 | 387 |
} |
394 | 388 |
|
395 | 389 |
/** |
... | ... | |
478 | 472 |
getRender().setLastTransparency(gridTransparency); |
479 | 473 |
} catch (FilterTypeException e) { |
480 | 474 |
//Ha habido un error en la asignaci?n de filtros por los que no se a?ade ninguno. |
481 |
RasterToolsUtil.debug("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e);
|
|
475 |
logger.error("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e);
|
|
482 | 476 |
} catch (FilterManagerException e) { |
483 | 477 |
//Ha habido un error en la asignaci?n de filtros por los que no se a?ade ninguno. |
484 |
RasterToolsUtil.debug("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e);
|
|
478 |
logger.error("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e);
|
|
485 | 479 |
} |
486 | 480 |
} |
487 | 481 |
|
... | ... | |
1196 | 1190 |
try { |
1197 | 1191 |
dataStore.saveGeoreferencingToRmf(); |
1198 | 1192 |
} catch (RmfSerializerException e) { |
1199 |
RasterToolsUtil.messageBoxError("error_salvando_rmf", this, e);
|
|
1193 |
logger.error("error_salvando_rmf", this, e);
|
|
1200 | 1194 |
} |
1201 | 1195 |
|
1202 | 1196 |
if (this.isRemoveRasterFlag()) { |
... | ... | |
2166 | 2160 |
} |
2167 | 2161 |
|
2168 | 2162 |
public void setOpenRasterStore(DataStore dataStore, int type) throws LoadLayerException { |
2169 |
if(dataStore instanceof DefaultCoverageStore) {
|
|
2163 |
if(dataStore instanceof CoverageStoreProviderServices) {
|
|
2170 | 2164 |
try { |
2171 |
this.dataStore = rManager.open(((DefaultCoverageStore) dataStore).getProvider(), type, dataStore.getParameters());
|
|
2165 |
this.dataStore = rManager.open(((CoverageStoreProviderServices) dataStore).getProvider(), type, dataStore.getParameters());
|
|
2172 | 2166 |
} catch (NotSupportedExtensionException e) { |
2173 | 2167 |
throw new LoadLayerException("Extension not supported", e); |
2174 | 2168 |
} catch (RasterDriverException e) { |
... | ... | |
2179 | 2173 |
try { |
2180 | 2174 |
enableAwake(); |
2181 | 2175 |
} catch (NotAvailableStateException e) { |
2182 |
RasterToolsUtil.messageBoxError("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), this, e);
|
|
2176 |
throw new LoadLayerException("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), e);
|
|
2183 | 2177 |
} |
2184 | 2178 |
setProjection(this.dataStore.getProjection()); |
2185 | 2179 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/roi/VectorialROIsWriter.java | ||
---|---|---|
35 | 35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
37 | 37 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
38 |
import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureType; |
|
39 | 38 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
40 | 39 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
41 | 40 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
188 | 187 |
private void create(String filename, IProjection crs, int geometryType) { |
189 | 188 |
File newFile=new File(filename); |
190 | 189 |
try { |
191 |
EditableFeatureType featureType = getFeatureType(); |
|
192 |
|
|
193 |
EditableFeatureAttributeDescriptor efad=featureType.add("GEOMETRY", DataTypes.GEOMETRY); |
|
194 |
efad.setGeometryType(geometryType); |
|
195 |
featureType.setDefaultGeometryAttributeName("GEOMETRY"); |
|
196 |
|
|
197 |
|
|
198 |
DataManager datamanager=DALLocator.getDataManager(); |
|
190 |
DataManager datamanager = DALLocator.getDataManager(); |
|
199 | 191 |
FilesystemServerExplorerParameters explorerParams; |
200 | 192 |
|
201 | 193 |
explorerParams = (FilesystemServerExplorerParameters) datamanager.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
... | ... | |
203 | 195 |
explorerParams.setRoot(newFile.getParent()); |
204 | 196 |
FilesystemServerExplorer explorer=(FilesystemServerExplorer) datamanager.createServerExplorer(explorerParams); |
205 | 197 |
NewFeatureStoreParameters newParams = (NewFeatureStoreParameters) explorer.getAddParameters(newFile); |
198 |
|
|
199 |
EditableFeatureType featureType = getFeatureType(newParams); |
|
200 |
EditableFeatureAttributeDescriptor efad=featureType.add("GEOMETRY", DataTypes.GEOMETRY); |
|
201 |
efad.setGeometryType(geometryType); |
|
202 |
featureType.setDefaultGeometryAttributeName("GEOMETRY"); |
|
206 | 203 |
|
204 |
explorer.add(newParams.getDataStoreName(), newParams, true); |
|
207 | 205 |
|
208 |
newParams.setDefaultFeatureType(featureType); |
|
209 |
explorer.add(newParams.getDataStoreName(),newParams, true); |
|
210 |
DataManager manager = DALLocator.getDataManager(); |
|
211 |
|
|
212 | 206 |
switch (geometryType) { |
213 | 207 |
case Geometry.TYPES.SURFACE: |
214 |
surfaceFS=(FeatureStore) manager.createStore(newParams); |
|
208 |
surfaceFS=(FeatureStore) datamanager.createStore(newParams);
|
|
215 | 209 |
surfaceFS.edit(FeatureStore.MODE_APPEND); |
216 | 210 |
break; |
217 | 211 |
|
218 | 212 |
case Geometry.TYPES.POINT: |
219 |
pointFS=(FeatureStore) manager.createStore(newParams); |
|
213 |
pointFS=(FeatureStore) datamanager.createStore(newParams);
|
|
220 | 214 |
pointFS.edit(FeatureStore.MODE_APPEND); |
221 | 215 |
break; |
222 | 216 |
|
223 | 217 |
case Geometry.TYPES.CURVE: |
224 |
curveFS=(FeatureStore) manager.createStore(newParams); |
|
218 |
curveFS=(FeatureStore) datamanager.createStore(newParams);
|
|
225 | 219 |
curveFS.edit(FeatureStore.MODE_APPEND); |
226 | 220 |
break; |
227 | 221 |
|
... | ... | |
234 | 228 |
|
235 | 229 |
} |
236 | 230 |
|
237 |
private EditableFeatureType getFeatureType(){
|
|
238 |
EditableFeatureType eft=new DefaultEditableFeatureType();
|
|
231 |
private EditableFeatureType getFeatureType(NewFeatureStoreParameters newParams) {
|
|
232 |
EditableFeatureType eft = (EditableFeatureType)newParams.getDefaultFeatureType();
|
|
239 | 233 |
|
240 | 234 |
eft.add("name", DataTypes.STRING, 20); |
241 | 235 |
|
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/RasterToolsUtil.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.util; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.Point; |
|
27 |
import java.io.File; |
|
28 |
import java.util.ArrayList; |
|
29 |
|
|
30 |
import javax.swing.ImageIcon; |
|
31 |
import javax.swing.JOptionPane; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
35 |
import org.gvsig.app.project.Project; |
|
36 |
import org.gvsig.app.project.ProjectManager; |
|
37 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
|
39 |
import org.gvsig.fmap.dal.DataManager; |
|
40 |
import org.gvsig.fmap.dal.DataStore; |
|
41 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
42 |
import org.gvsig.fmap.dal.coverage.datastruct.Param; |
|
43 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
44 |
import org.gvsig.fmap.dal.coverage.store.RasterDataParameters; |
|
45 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
46 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
47 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
48 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
49 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
51 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
52 |
import org.gvsig.gui.beans.propertiespanel.PropertiesComponent; |
|
53 |
import org.gvsig.gui.beans.propertiespanel.PropertyStruct; |
|
54 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
55 |
import org.slf4j.LoggerFactory; |
|
56 |
|
|
57 |
/** |
|
58 |
* Herramientas de uso general y que son dependientes de gvSIG, FMap o de |
|
59 |
* libUIComponents. En caso de no serlo existe una clase independiente de |
|
60 |
* cualquier proyecto dentro de libRaster para este tipo de funciones. |
|
61 |
* |
|
62 |
* @version 31/05/2007 |
|
63 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
64 |
*/ |
|
65 |
public class RasterToolsUtil { |
|
66 |
|
|
67 |
/** |
|
68 |
* Obtiene la lista de capas del TOC y devuelve las raster. Si hay capas agrupadas lo tiene en cuenta y mira |
|
69 |
* dentro de la agrupaci?n. |
|
70 |
* @param srcLyrs FLayers de la vista |
|
71 |
* @param destLyrs Lista de capas |
|
72 |
* @return ArrayList con la lista de capas raster agrupadas o no. El orden en que aparecen |
|
73 |
* en la lista es de abajo a arriba las que aparecen en el TOC. |
|
74 |
*/ |
|
75 |
public static ArrayList<FLayer> getRasterLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
76 |
if(destLyrs == null) |
|
77 |
destLyrs = new ArrayList<FLayer>(); |
|
78 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
79 |
if(srcLyrs.getLayer(i) instanceof DefaultFLyrRaster) |
|
80 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
81 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
82 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
83 |
} |
|
84 |
return destLyrs; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Obtiene la lista de capas del TOC y devuelve las raster. Si hay capas agrupadas lo tiene en cuenta y mira |
|
89 |
* dentro de la agrupaci?n. |
|
90 |
* @param srcLyrs FLayers de la vista |
|
91 |
* @param destLyrs Lista de capas |
|
92 |
* @return ArrayList con la lista de capas raster agrupadas o no. El orden en que aparecen |
|
93 |
* en la lista es de abajo a arriba las que aparecen en el TOC. |
|
94 |
*/ |
|
95 |
public static ArrayList<FLayer> getLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
96 |
if(destLyrs == null) |
|
97 |
destLyrs = new ArrayList<FLayer>(); |
|
98 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
99 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
100 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
101 |
else |
|
102 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
103 |
} |
|
104 |
return destLyrs; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Obtiene el nombre de la vista donde est? cargada la capa que se pasa por par?metro |
|
109 |
* @param layer Capa cargada en una vista |
|
110 |
* @return Nombre de la vista donde est? cargada la capa. |
|
111 |
*/ |
|
112 |
public static String getView(FLayer layer) { |
|
113 |
// Project p = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject(); |
|
114 |
Project p = ProjectManager.getInstance().getCurrentProject(); |
|
115 |
return p.getViewName(layer); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Devuelve la traducci?n de un texto. En caso de no existir la traducci?n al idioma seleccionado |
|
120 |
* devolver? la cadena de entrada. |
|
121 |
* @param parent Ventana padre que contiene el objeto con la traducci?n |
|
122 |
* @param text Texto a traducir |
|
123 |
* @return Texto traducido o cadena de entrada en caso de no encontrar una traducci?n |
|
124 |
*/ |
|
125 |
public static String getText(Object parent, String text) { |
|
126 |
return PluginServices.getText(parent, text); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Obtiene un icono definido por la etiqueta que se especifica en el |
|
131 |
* par?metro |
|
132 |
* @param ico Etiqueta del icono |
|
133 |
* @return Icono |
|
134 |
*/ |
|
135 |
public static ImageIcon getIcon(String ico) { |
|
136 |
return PluginServices.getIconTheme().get(ico); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* A?ade una ventana al gestor de ventanas |
|
141 |
* @param window |
|
142 |
*/ |
|
143 |
public static void addWindow(IWindow window) { |
|
144 |
PluginServices.getMDIManager().addWindow(window); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Elimina una ventana al gestor de ventanas |
|
149 |
* @param window |
|
150 |
*/ |
|
151 |
public static void closeWindow(IWindow window) { |
|
152 |
PluginServices.getMDIManager().closeWindow(window); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* Selecciona los controles del panel de propiedades a partir de los par?mtros |
|
157 |
* obtenidos del driver. Este m?todo realiza una transformaci?n entre Params |
|
158 |
* obtenido del driver de escritura y los par?metros del panel de propiedades. |
|
159 |
* @param panel Panel de propiedades |
|
160 |
* @param params Par?metros del driver |
|
161 |
* @param notTakeIntoAccount Nombre de par?metros que no hay que tener en cuenta. Si es null se tienen en cuenta todos. |
|
162 |
*/ |
|
163 |
public static void loadPropertiesFromWriterParams(PropertiesComponent pComp, Params params, String[] notTakeIntoAccount) { |
|
164 |
for (int i = 0; i < params.getNumParams(); i++) { |
|
165 |
Param p = params.getParam(i); |
|
166 |
String name = getText(null, p.getId()); |
|
167 |
String key = p.getId(); |
|
168 |
|
|
169 |
//Miramos si el par?metro coincide con alguno en la lista de parametros que no hay que |
|
170 |
//tener en cuenta. Si es as? no lo a?adimos |
|
171 |
if(notTakeIntoAccount != null && notTakeIntoAccount.length > 0) { |
|
172 |
boolean jump = false; |
|
173 |
for (int j = 0; j < notTakeIntoAccount.length; j++) { |
|
174 |
if (key.equals(notTakeIntoAccount[j])) |
|
175 |
jump = true; |
|
176 |
} |
|
177 |
if(jump) |
|
178 |
continue; |
|
179 |
} |
|
180 |
|
|
181 |
Object[] types = null; |
|
182 |
int selectedValue = 0; |
|
183 |
|
|
184 |
switch (p.getType()) { |
|
185 |
case Params.CHECK: |
|
186 |
pComp.addValue(name, key, p.getDefaultValue(), types); |
|
187 |
break; |
|
188 |
case Params.CHOICE: |
|
189 |
ArrayList<String> list = new ArrayList<String>(); |
|
190 |
for (int j = 0; j < p.getList().length; j++) { |
|
191 |
list.add(p.getList()[j]); |
|
192 |
if (p.getDefaultValue() instanceof Integer) |
|
193 |
if (((Integer) p.getDefaultValue()).intValue() == j) |
|
194 |
selectedValue = j; |
|
195 |
} |
|
196 |
types = new Object[] { new Integer(PropertiesComponent.TYPE_COMBO), list }; |
|
197 |
pComp.addValue(name, key, new Integer(selectedValue), types); |
|
198 |
break; |
|
199 |
case Params.SLIDER: |
|
200 |
types = new Object[] { new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(p.getList()[0]), new Integer(p.getList()[1]) }; |
|
201 |
pComp.addValue(name, key, p.getDefaultValue(), types); |
|
202 |
break; |
|
203 |
default: |
|
204 |
pComp.addValue(getText(null, ((Param)params.getParam(i)).getId()), params.getParam(i).getId(), params.getParam(i).getDefaultValue(), null); |
|
205 |
break; |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* Carga los par?metros del escritor WriterParams con los valores obtenidos |
|
212 |
* de la ventana de propiedades. |
|
213 |
*/ |
|
214 |
@SuppressWarnings("unchecked") |
|
215 |
public static void loadWriterParamsFromPropertiesPanel(PropertiesComponent pComp, Params params) { |
|
216 |
ArrayList<PropertyStruct> values = pComp.getValues(); |
|
217 |
for (int iParam = 0; iParam < params.getNumParams(); iParam++) { |
|
218 |
Param p = params.getParam(iParam); |
|
219 |
for (int iValue = 0; iValue < values.size(); iValue++) { |
|
220 |
PropertyStruct prop = values.get(iValue); |
|
221 |
if (p.getId().compareTo(prop.getKey()) == 0) { |
|
222 |
switch (p.getType()) { |
|
223 |
case Params.CHECK: |
|
224 |
p.setDefaultValue((Boolean) prop.getNewValue()); |
|
225 |
break; |
|
226 |
case Params.CHOICE: |
|
227 |
p.setDefaultValue(((Integer) prop.getNewValue()));//p.list[((Integer) prop.getNewValue()).intValue()]; |
|
228 |
break; |
|
229 |
case Params.SLIDER: |
|
230 |
try { |
|
231 |
p.setDefaultValue((Integer)prop.getNewValue()); |
|
232 |
} catch (NumberFormatException e) {} |
|
233 |
} |
|
234 |
break; |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Funci?n que devuelve true si se tiene permiso de escritura en la ruta |
|
242 |
* indicada en el par?metro path y false si no los tiene. |
|
243 |
* @param path Ruta a comprobar los permisosv |
|
244 |
* @param pluginObject si es distinto de null se obtiene un mensaje de |
|
245 |
* advertencia y sirve como par?metro para getText de la traducci?n. |
|
246 |
* Si es null no se mostrar? ventana de advertencia |
|
247 |
* @return true si se tiene permiso de escritura en la ruta indicada en el |
|
248 |
* par?metro path y false si no los tiene. |
|
249 |
*/ |
|
250 |
public static boolean canWrite(String path, Object pluginObject) { |
|
251 |
File f = new File(path); |
|
252 |
if(f.exists() && f.canWrite()) |
|
253 |
return true; |
|
254 |
else { |
|
255 |
if(pluginObject != null) |
|
256 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
257 |
PluginServices.getText(pluginObject, "error_escritura")); |
|
258 |
return false; |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* Muestra un dialogo con un texto y un bot?n Si o No. |
|
264 |
* @param msg Mensaje a mostrar en el dialogo. |
|
265 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
266 |
* @return El bot?n seleccionado por el usuario. true si ha seleccionado "si" |
|
267 |
* y false si ha seleccionado "no" |
|
268 |
*/ |
|
269 |
public static boolean messageBoxYesOrNot(String msg, Object parentWindow){ |
|
270 |
String string1 = PluginServices.getText(parentWindow, "yes"); |
|
271 |
String string2 = PluginServices.getText(parentWindow, "no"); |
|
272 |
Object[] options = {string1, string2}; |
|
273 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
|
274 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>", |
|
275 |
PluginServices.getText(parentWindow, "confirmacion"), |
|
276 |
JOptionPane.YES_NO_OPTION, |
|
277 |
JOptionPane.QUESTION_MESSAGE, |
|
278 |
null, |
|
279 |
options, |
|
280 |
string1); |
|
281 |
if (n == JOptionPane.YES_OPTION) |
|
282 |
return true; |
|
283 |
else |
|
284 |
return false; |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* Muestra un dialogo de error con un texto y un bot?n de aceptar. |
|
289 |
* @param msg Mensaje a mostrar en el dialogo. |
|
290 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
291 |
*/ |
|
292 |
public static void messageBoxError(String msg, Object parentWindow){ |
|
293 |
String string = PluginServices.getText(parentWindow, "accept"); |
|
294 |
Object[] options = {string}; |
|
295 |
JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
|
296 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>", |
|
297 |
PluginServices.getText(parentWindow, "confirmacion"), |
|
298 |
JOptionPane.OK_OPTION, |
|
299 |
JOptionPane.ERROR_MESSAGE, |
|
300 |
null, |
|
301 |
options, |
|
302 |
string); |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* Muestra un dialogo de informaci?n con un texto y un bot?n de aceptar. |
|
307 |
* @param msg Mensaje a mostrar en el dialogo. Identificador de la cadena a traducir |
|
308 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
309 |
*/ |
|
310 |
public static void messageBoxInfo(String msg, Object parentWindow){ |
|
311 |
String string = PluginServices.getText(parentWindow, "accept"); |
|
312 |
Object[] options = {string}; |
|
313 |
JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
|
314 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>", |
|
315 |
PluginServices.getText(parentWindow, "confirmacion"), |
|
316 |
JOptionPane.OK_OPTION, |
|
317 |
JOptionPane.INFORMATION_MESSAGE, |
|
318 |
null, |
|
319 |
options, |
|
320 |
string); |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* Registra un mensaje de error en el log de gvSIG |
|
325 |
* @param msg Mensaje a guardar en el log |
|
326 |
* @param parent Objeto que hizo disparar el mensaje |
|
327 |
* @param exception Excepcion que ha sido recogida |
|
328 |
*/ |
|
329 |
public static void debug(String msg, Object parent, Exception exception) { |
|
330 |
if(parent != null) |
|
331 |
LoggerFactory |
|
332 |
.getLogger(parent.getClass()).debug(PluginServices.getText(parent, msg), exception); |
|
333 |
} |
|
334 |
|
|
335 |
/** |
|
336 |
* Muestra un dialogo de error con un texto y un bot?n de aceptar. El error es |
|
337 |
* registrado en el log de gvSIG con la excepcion que se le pase por parametro |
|
338 |
* @param msg Mensaje a mostrar en el dialogo. |
|
339 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
340 |
* @param exception Excepcion que ha sido recogida |
|
341 |
*/ |
|
342 |
public static void messageBoxError(String msg, Object parentWindow, Exception exception) { |
|
343 |
debug(msg, parentWindow, exception); |
|
344 |
messageBoxError(msg, parentWindow); |
|
345 |
} |
|
346 |
|
|
347 |
/** |
|
348 |
* Muestra un dialogo de error con un texto y un bot?n de aceptar. Se le pasa como ?ltimo par?metros |
|
349 |
* una lista de excepciones que ser?n guardadas en el log |
|
350 |
* @param msg Mensaje a mostrar en el dialogo. |
|
351 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
352 |
* @param exception Excepcion que ha sido recogida |
|
353 |
*/ |
|
354 |
public static void messageBoxError(String msg, Object parentWindow, ArrayList<Exception> exception) { |
|
355 |
for (int i = 0; i < exception.size(); i++) |
|
356 |
debug(msg, parentWindow, exception.get(i)); |
|
357 |
messageBoxError(msg, parentWindow); |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* Muestra un dialogo de informaci?n con un texto y un bot?n de aceptar. El |
|
362 |
* mensaje informativo es registrado en el log de gvSIG con la excepcion que |
|
363 |
* se le pase por parametro. |
|
364 |
* @param msg Mensaje a mostrar en el dialogo. Identificador de la cadena a |
|
365 |
* traducir |
|
366 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
367 |
* @param exception Excepcion que ha sido recogida |
|
368 |
*/ |
|
369 |
public static void messageBoxInfo(String msg, Object parentWindow, Exception exception) { |
|
370 |
debug(msg, parentWindow, exception); |
|
371 |
messageBoxInfo(msg, parentWindow); |
|
372 |
} |
|
373 |
|
|
374 |
/** |
|
375 |
* Muestra un dialogo con un texto y un bot?n Si o No. El mensaje es |
|
376 |
* registrado en el log de gvSIG con la excepcion que se le pase por |
|
377 |
* parametro. |
|
378 |
* @param msg Mensaje a mostrar en el dialogo. |
|
379 |
* @param parentWindow Ventana desde la que se lanza el dialogo |
|
380 |
* @return El bot?n seleccionado por el usuario. true si ha seleccionado "si" |
|
381 |
* y false si ha seleccionado "no" |
|
382 |
*/ |
|
383 |
public static boolean messageBoxYesOrNot(String msg, Object parentWindow, Exception exception) { |
|
384 |
debug(msg, parentWindow, exception); |
|
385 |
return messageBoxYesOrNot(msg, parentWindow); |
|
386 |
} |
|
387 |
|
|
388 |
/** |
|
389 |
* Carga una capa raster en una vista de gvSIG. |
|
390 |
* @param viewName Nombre de la vista donde ha de cargarse. Si vale null se cargar? en la |
|
391 |
* primera vista que encuentre que est? activa. Si no hay ninguna saltar? una excepci?n. |
|
392 |
* @param fileName Nombre del fichero a cargar. No debe ser nulo nunca. |
|
393 |
* @param layerName Nombre de la capa. Si es null se asignar? el nombre del |
|
394 |
* fichero sin extensi?n. |
|
395 |
* @throws RasterNotLoadException Excepci?n que se lanza cuando no se ha podido cargar la capa |
|
396 |
* por alg?n motivo. |
|
397 |
*/ |
|
398 |
@SuppressWarnings("deprecation") |
|
399 |
public static FLayer loadLayer(String viewName, String fileName, String layerName) throws RasterNotLoadException { |
|
400 |
if(fileName == null) |
|
401 |
return null; |
|
402 |
|
|
403 |
//Seleccionamos la vista de gvSIG |
|
404 |
DefaultViewPanel theView = null; |
|
405 |
try { |
|
406 |
IWindow[] allViews = PluginServices.getMDIManager().getAllWindows(); |
|
407 |
if(viewName != null) { |
|
408 |
for (int i = 0; i < allViews.length; i++) { |
|
409 |
if (allViews[i] instanceof DefaultViewPanel |
|
410 |
&& PluginServices.getMDIManager().getWindowInfo((DefaultViewPanel) allViews[i]).getTitle().equals(viewName)) |
|
411 |
theView = (DefaultViewPanel) allViews[i]; |
|
412 |
} |
|
413 |
} else { |
|
414 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
415 |
for (int i = 0; i < allViews.length; i++) { |
|
416 |
if (allViews[i] instanceof DefaultViewPanel && ((DefaultViewPanel)allViews[i]) == activeWindow) //En la primera vista activa |
|
417 |
theView = (DefaultViewPanel) allViews[i]; |
|
418 |
} |
|
419 |
if(theView == null) { |
|
420 |
for (int i = 0; i < allViews.length; i++) { |
|
421 |
if (allViews[i] instanceof DefaultViewPanel) //En la primera vista |
|
422 |
theView = (DefaultViewPanel) allViews[i]; |
|
423 |
} |
|
424 |
} |
|
425 |
} |
|
426 |
|
|
427 |
if (theView == null) |
|
428 |
throw new RasterNotLoadException("Imposible cargar la capa."); |
|
429 |
} catch (ClassCastException ex) { |
|
430 |
throw new RasterNotLoadException("No se puede hacer un casting de esa IWindow a View."); |
|
431 |
} |
|
432 |
|
|
433 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
434 |
|
|
435 |
DefaultFLyrRaster lyr = null; |
|
436 |
try { |
|
437 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
438 |
RasterDataParameters storeParameters = provServ.createParameters(fileName, -1); |
|
439 |
storeParameters.setSRS(theView.getProjection()); |
|
440 |
|
|
441 |
DataManager dataManager = DALLocator.getDataManager(); |
|
442 |
DataStore dataStore = null; |
|
443 |
try { |
|
444 |
dataStore = dataManager.createStore(storeParameters); |
|
445 |
} catch (ValidateDataParametersException e) { |
|
446 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
447 |
} catch (InitializeException e) { |
|
448 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
449 |
} catch (ProviderNotRegisteredException e) { |
|
450 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
451 |
} |
|
452 |
|
|
453 |
lyr = new DefaultFLyrRaster(); |
|
454 |
|
|
455 |
if(layerName == null) { |
|
456 |
int endIndex = fileName.lastIndexOf("."); |
|
457 |
if (endIndex < 0) |
|
458 |
endIndex = fileName.length(); |
|
459 |
|
|
460 |
lyr.setName(fileName.substring(fileName.lastIndexOf(File.separator) + 1, endIndex)); |
|
461 |
lyr.setDataStore(dataStore); |
|
462 |
} else { |
|
463 |
lyr.setName(layerName); |
|
464 |
lyr.setDataStore(dataStore); |
|
465 |
} |
|
466 |
|
|
467 |
} catch (LoadLayerException e) { |
|
468 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
469 |
} |
|
470 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
471 |
theView.getMapControl().getMapContext().invalidate(); |
|
472 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
473 |
return lyr; |
|
474 |
} |
|
475 |
|
|
476 |
/** |
|
477 |
* Carga una capa raster en una vista de gvSIG. |
|
478 |
* @param viewName Nombre de la vista donde ha de cargarse. Si vale null se cargar? en la |
|
479 |
* primera vista que encuentre que est? activa. Si no hay ninguna saltar? una excepci?n. |
|
480 |
* @param fileName Nombre del fichero a cargar. No debe ser nulo nunca. |
|
481 |
* @param layerName Nombre de la capa. Si es null se asignar? el nombre del |
|
482 |
* fichero sin extensi?n. |
|
483 |
* @throws RasterNotLoadException Excepci?n que se lanza cuando no se ha podido cargar la capa |
|
484 |
* por alg?n motivo. |
|
485 |
*/ |
|
486 |
public static FLayer loadLayer(String viewName, FLayer lyr) throws RasterNotLoadException { |
|
487 |
if(lyr == null) |
|
488 |
return null; |
|
489 |
|
|
490 |
//Seleccionamos la vista de gvSIG |
|
491 |
DefaultViewPanel theView = null; |
|
492 |
try { |
|
493 |
IWindow[] allViews = PluginServices.getMDIManager().getAllWindows(); |
|
494 |
if(viewName != null) { |
|
495 |
for (int i = 0; i < allViews.length; i++) { |
|
496 |
if (allViews[i] instanceof DefaultViewPanel |
|
497 |
&& PluginServices.getMDIManager().getWindowInfo((DefaultViewPanel) allViews[i]).getTitle().equals(viewName)) |
|
498 |
theView = (DefaultViewPanel) allViews[i]; |
|
499 |
} |
|
500 |
} else { |
|
501 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
502 |
for (int i = 0; i < allViews.length; i++) { |
|
503 |
if (allViews[i] instanceof DefaultViewPanel && ((DefaultViewPanel)allViews[i]) == activeWindow) //En la primera vista activa |
|
504 |
theView = (DefaultViewPanel) allViews[i]; |
|
505 |
} |
|
506 |
if(theView == null) { |
|
507 |
for (int i = 0; i < allViews.length; i++) { |
|
508 |
if (allViews[i] instanceof DefaultViewPanel) //En la primera vista |
|
509 |
theView = (DefaultViewPanel) allViews[i]; |
|
510 |
} |
|
511 |
} |
|
512 |
} |
|
513 |
|
|
514 |
if (theView == null) |
|
515 |
throw new RasterNotLoadException("Imposible cargar la capa."); |
|
516 |
} catch (ClassCastException ex) { |
|
517 |
throw new RasterNotLoadException("No se puede hacer un casting de esa IWindow a View."); |
|
518 |
} |
|
519 |
|
|
520 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
521 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
522 |
theView.getMapControl().getMapContext().invalidate(); |
|
523 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
524 |
return lyr; |
|
525 |
} |
|
526 |
|
|
527 |
/** |
|
528 |
* Calculo de las coordenadas de una ventana IWindow para que quede centrada sobre el |
|
529 |
* MainFrame. Estas coordenadas solo valen para un IWindow ya que andami mete las ventanas |
|
530 |
* con coordenadas relativas a su ventanta principal. |
|
531 |
* @param widthWindow Ancho de la ventana a a?adir |
|
532 |
* @param heightWindow Alto de la ventana a a?adir |
|
533 |
* @return Array con el ancho y el alto |
|
534 |
*/ |
|
535 |
public static Point iwindowPosition(int widthWindow, int heightWindow) { |
|
536 |
int posWindowX = 0; |
|
537 |
int posWindowY = 0; |
|
538 |
Dimension dim = null; |
|
539 |
Point pos = null; |
|
540 |
if(PluginServices.getMainFrame() instanceof Component) { |
|
541 |
dim = ((Component)PluginServices.getMainFrame()).getSize(); |
|
542 |
pos = ((Component)PluginServices.getMainFrame()).getLocation(); |
|
543 |
if(dim != null && pos != null) { |
|
544 |
posWindowX = ((dim.width >> 1) - (widthWindow >> 1)); |
|
545 |
posWindowY = ((dim.height >> 1) - (heightWindow >> 1) - 70); |
|
546 |
return new Point(posWindowX, posWindowY); |
|
547 |
} |
|
548 |
} |
|
549 |
return null; |
|
550 |
} |
|
551 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/BasePanel.java | ||
---|---|---|
30 | 30 |
import javax.swing.AbstractButton; |
31 | 31 |
import javax.swing.JPanel; |
32 | 32 |
|
33 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
33 | 37 |
/** |
34 | 38 |
* Clase base para los paneles gr?ficos. |
35 | 39 |
* |
... | ... | |
43 | 47 |
public static final int KEYLISTENER = 0; |
44 | 48 |
public static final int ACTIONLISTENER = 1; |
45 | 49 |
public static final int MOUSELISTENER = 2; |
50 |
private static final Logger logger = LoggerFactory.getLogger(DefaultFLyrRaster.class); |
|
46 | 51 |
|
47 | 52 |
/** |
48 | 53 |
* Obtiene una instancia de una clase generica que hereda de BasePanel |
... | ... | |
58 | 63 |
* @param text Cadena a traducir |
59 | 64 |
* @return Cadena de texto traducida |
60 | 65 |
*/ |
61 |
public String getText(Object parent, String text) { |
|
62 |
return RasterToolsUtil.getText(parent, text); |
|
66 |
public String getText(Object parent, String key) { |
|
67 |
if (key == null) |
|
68 |
return null; |
|
69 |
String translation = org.gvsig.i18n.Messages.getText(key, false); |
|
70 |
if (translation != null) |
|
71 |
return translation; |
|
72 |
else { |
|
73 |
logger.debug("Can't find translation for ''{1}''.", key); |
|
74 |
return key; |
|
75 |
} |
|
63 | 76 |
} |
64 | 77 |
|
65 | 78 |
/** |
... | ... | |
68 | 81 |
* @return Cadena de texto traducida |
69 | 82 |
*/ |
70 | 83 |
public String getText(String text) { |
71 |
return RasterToolsUtil.getText(this, text);
|
|
84 |
return getText(this, text); |
|
72 | 85 |
} |
73 | 86 |
|
74 | 87 |
/** |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/ExtendedFileFilter.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import javax.swing.filechooser.FileFilter; |
28 | 28 |
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 | 29 |
|
31 | 30 |
/** |
32 | 31 |
* ExtendedFileFilter es una clase para usarla junto a los JFileChooser. |
... | ... | |
158 | 157 |
format2 = format2 + "*." + extensions.get(j).toString().toLowerCase(); |
159 | 158 |
} |
160 | 159 |
if (description == null) |
161 |
return PluginServices.getText(this, "files") + " " + format1 + " (" + format2 + ")";
|
|
160 |
return "files" + " " + format1 + " (" + format2 + ")";
|
|
162 | 161 |
|
163 | 162 |
return description + " (" + format2 + ")"; |
164 | 163 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/pom.xml | ||
---|---|---|
46 | 46 |
</dependency> |
47 | 47 |
<dependency> |
48 | 48 |
<groupId>org.gvsig</groupId> |
49 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
50 |
<classifier>impl</classifier> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.andami</artifactId> |
|
56 |
<scope>compile</scope> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.gvsig</groupId> |
|
60 | 49 |
<artifactId>org.gvsig.projection</artifactId> |
61 | 50 |
<scope>compile</scope> |
62 | 51 |
</dependency> |
... | ... | |
76 | 65 |
<classifier>store.shp</classifier> |
77 | 66 |
<scope>compile</scope> |
78 | 67 |
</dependency> |
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.app</artifactId> |
|
82 |
<version>2.0-SNAPSHOT</version> |
|
83 |
<scope>compile</scope> |
|
84 |
</dependency> |
|
85 | 68 |
<dependency> |
86 | 69 |
<groupId>org.gvsig</groupId> |
87 | 70 |
<artifactId>org.gvsig.utils</artifactId> |
... | ... | |
123 | 106 |
<classifier>store.dbf</classifier> |
124 | 107 |
<scope>compile</scope> |
125 | 108 |
</dependency> |
126 |
<!-- |
|
127 |
<dependency> |
|
128 |
<groupId>org.gvsig</groupId> |
|
129 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
109 |
<dependency> |
|
110 |
<groupId>org.gvsig</groupId> |
|
111 |
<artifactId>org.gvsig.i18n</artifactId> |
|
130 | 112 |
<scope>compile</scope> |
131 |
</dependency> |
|
132 |
<dependency> |
|
133 |
<groupId>org.gvsig</groupId> |
|
134 |
<artifactId>org.gvsig.symbology</artifactId> |
|
135 |
<classifier>impl</classifier> |
|
136 |
<scope>compile</scope> |
|
137 |
</dependency> |
|
138 |
<dependency> |
|
139 |
<groupId>org.gvsig</groupId> |
|
140 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
141 |
<classifier>spi</classifier> |
|
142 |
<scope>compile</scope> |
|
143 |
</dependency> |
|
144 |
<dependency> |
|
145 |
<groupId>org.gvsig</groupId> |
|
146 |
<artifactId>org.gvsig.fmap.dal.file</artifactId> |
|
147 |
<scope>compile</scope> |
|
148 |
</dependency> |
|
149 |
--> |
|
113 |
</dependency> |
|
150 | 114 |
</dependencies> |
151 | 115 |
</project> |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/buffer/BufferInterpolation.java | ||
---|---|---|
1078 | 1078 |
public boolean isPausable() { |
1079 | 1079 |
return false; |
1080 | 1080 |
} |
1081 |
|
|
1082 |
/* |
|
1083 |
* (non-Javadoc) |
|
1084 |
* @see org.gvsig.fmap.dal.coverage.process.BaseIncrementableTask#setPercent(int) |
|
1085 |
*/ |
|
1086 |
public void setPercent(int value) { |
|
1087 |
this.percent = value; |
|
1088 |
} |
|
1081 | 1089 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/MemoryMatrixBuffer.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.impl.provider; |
|
23 |
|
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
30 |
import org.gvsig.raster.cache.tile.Tile; |
|
31 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
32 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
33 |
|
|
34 |
/** |
|
35 |
* Buffer composed by a list of tiles and its extents. |
|
36 |
* It will expose a method getWindow to read a window of data from the tile list. |
|
37 |
* The list of tiles have to make a square. |
|
38 |
* |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public class MemoryMatrixBuffer { |
|
42 |
private Buffer[] bufferList = null; |
|
43 |
private Rectangle2D[] extentList = null; |
|
44 |
private int nRows = 0; |
|
45 |
private int nCols = 0; |
|
46 |
private Extent bbox = null; |
|
47 |
|
|
48 |
/** |
|
49 |
* Constructor using an array of tiles. It will compute the number |
|
50 |
* of rows and columns and the complete bounding box |
|
51 |
* @param tileList |
|
52 |
*/ |
|
53 |
public MemoryMatrixBuffer(Tile[] tileList) { |
|
54 |
bufferList = new Buffer[tileList.length]; |
|
55 |
extentList = new Rectangle2D[tileList.length]; |
|
56 |
for (int i = 0; i < extentList.length; i++) { |
|
57 |
bufferList[i] = (Buffer)tileList[i].getData()[0]; |
|
58 |
extentList[i] = tileList[i].getExtent(); |
|
59 |
} |
|
60 |
int r = tileList[0].getRow(); |
|
61 |
int c = tileList[0].getCol(); |
|
62 |
for (int i = 0; i < tileList.length; i++) { |
|
63 |
if(tileList[i].getRow() == r) |
|
64 |
nRows ++; |
|
65 |
if(tileList[i].getCol() == c) |
|
66 |
nCols ++; |
|
67 |
} |
|
68 |
bbox = calculateBBox(); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Constructor using an ArrayList of tiles. It will compute the number |
|
73 |
* of rows and columns and the complete bounding box |
|
74 |
* @param tileList |
|
75 |
*/ |
|
76 |
public MemoryMatrixBuffer(ArrayList<Tile> tileList) { |
|
77 |
bufferList = new Buffer[tileList.size()]; |
|
78 |
extentList = new Rectangle2D[tileList.size()]; |
|
79 |
for (int i = 0; i < extentList.length; i++) { |
|
80 |
bufferList[i] = (Buffer)tileList.get(i).getData()[0]; |
|
81 |
extentList[i] = tileList.get(i).getExtent(); |
|
82 |
} |
|
83 |
int r = tileList.get(0).getRow(); |
|
84 |
int c = tileList.get(0).getCol(); |
|
85 |
for (int i = 0; i < tileList.size(); i++) { |
|
86 |
if(tileList.get(i).getRow() == r) |
|
87 |
nRows ++; |
|
88 |
if(tileList.get(i).getCol() == c) |
|
89 |
nCols ++; |
|
90 |
} |
|
91 |
bbox = calculateBBox(); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Builds the complete bounding box of the tile list |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
private Extent calculateBBox() { |
|
99 |
double minX = Double.MAX_VALUE; |
|
100 |
double minY = Double.MAX_VALUE; |
|
101 |
double maxX = 0; |
|
102 |
double maxY = 0; |
|
103 |
for (int i = 0; i < extentList.length; i++) { |
|
104 |
if(extentList[i].getX() < minX) |
|
105 |
minX = extentList[i].getX(); |
|
106 |
if((extentList[i].getY() - extentList[i].getHeight()) < minY) |
|
107 |
minY = (extentList[i].getY() - extentList[i].getHeight()); |
|
108 |
if((extentList[i].getX() + extentList[i].getWidth()) > maxX) |
|
109 |
maxX = (extentList[i].getX() + extentList[i].getWidth()); |
|
110 |
if(extentList[i].getY() > maxY) |
|
111 |
maxY = extentList[i].getY(); |
|
112 |
} |
|
113 |
return new ExtentImpl(minX, minY, maxX, maxY); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Gets a window from tiles |
|
118 |
* @param ext |
|
119 |
* @param buf |
|
120 |
* @return |
|
121 |
*/ |
|
122 |
public Buffer getWindow(Extent ext, Buffer buf) { |
|
123 |
//Crea un buffer a escala de la lista de tiles pero q ser? el buffer final |
|
124 |
Buffer sourceWithoutResampling = createBufferWithoutResampling(ext, buf.getDataType(), buf.getBandCount()); |
|
125 |
for (int i = 0; i < bufferList.length; i++) { |
|
126 |
//1-Calcular las coordenadas pixel del tile de entrada |
|
127 |
int[] points = getClipPoints(extentList[i], bufferList[i], ext); |
|
128 |
|
|
129 |
//2-Ajustar peti?n al extent del tile |
|
130 |
Extent adjustedRequestExtent = getAdjustedExtent(extentList[i], ext); |
|
131 |
|
|
132 |
if((points[0] == 0 && points[1] == 0) || (points[2] == 0 && points[3] == 0)) |
|
133 |
continue; |
|
134 |
|
|
135 |
//3-Calcular coordenada pixel de inicio del buffer |
|
136 |
double wcX1 = Math.abs(adjustedRequestExtent.getMin().getX() - ext.getMin().getX()); |
|
137 |
double wcY1 = Math.abs(ext.getMax().getY() - adjustedRequestExtent.getMax().getY()); |
|
138 |
int initXPxBuf = (int)Math.ceil((wcX1 * (sourceWithoutResampling.getWidth())) / ext.width()); |
|
139 |
int initYPxBuf = (int)Math.ceil((wcY1 * (sourceWithoutResampling.getHeight())) / ext.height()); |
|
140 |
|
|
141 |
//4-Copiar recorte al buffer |
|
142 |
Rectangle2D rTile = new Rectangle2D.Double(points[0], points[2], (points[1] - points[0]) + 1, (points[3] - points[2]) + 1); |
|
143 |
loadBuffer(sourceWithoutResampling, bufferList[i], rTile, initXPxBuf, initYPxBuf); |
|
144 |
} |
|
145 |
//Devuelve el buffer pero reescalandolo antes al tama?o en pixeles de la petici?n |
|
146 |
try { |
|
147 |
return sourceWithoutResampling.getAdjustedWindow(buf.getWidth(), buf.getHeight(), Buffer.INTERPOLATION_NearestNeighbour); |
|
148 |
} catch (ProcessInterruptedException e) { |
|
149 |
} |
|
150 |
return buf; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* Builds a buffer in the same resolution as the list of tiles. When the operation |
|
155 |
* ends this buffer should be resampled. |
|
156 |
* @return |
|
157 |
*/ |
|
158 |
private Buffer createBufferWithoutResampling(Extent ext, int dataType, int bands) { |
|
159 |
int w = 0; |
|
160 |
int h = 0; |
|
161 |
for (int i = 0; i < bufferList.length; i++) { |
|
162 |
int[] points = getClipPoints(extentList[i], bufferList[i], ext); |
|
163 |
w += (points[1] - points[0]) + 1; |
|
164 |
h += (points[3] - points[2]) + 1; |
|
165 |
} |
|
166 |
|
|
167 |
//Si todos los tiles de la lista no cubren completamente el buffer pedido habr? que calcular cuantos |
|
168 |
//pixeles quedan fuera para a?adirlos al nuevo buffer que estamos construyendo |
|
169 |
double mtsPx = extentList[0].getWidth() / bufferList[0].getWidth(); |
|
170 |
double distanceUp = (ext.getMax().getY() - bbox.getMax().getY()) <= 0 ? 0 : (ext.getMax().getY() - bbox.getMax().getY()); |
|
171 |
double distanceDown = (bbox.getMin().getY() - ext.getMin().getY()) <= 0 ? 0 : (bbox.getMin().getY() - ext.getMin().getY()); |
|
172 |
double distanceLeft = (bbox.getMin().getX() - ext.getMin().getX()) <= 0 ? 0 : (bbox.getMin().getX() - ext.getMin().getX()); |
|
173 |
double distanceRight = (ext.getMax().getX() - bbox.getMax().getX()) <= 0 ? 0 : (ext.getMax().getX() - bbox.getMax().getX()); |
|
174 |
int distanceUpPx = (int)(distanceUp / mtsPx); |
|
175 |
int distanceDownPx = (int)(distanceDown / mtsPx); |
|
176 |
int distanceLeftPx = (int)(distanceLeft / mtsPx); |
|
177 |
int distanceRightPx = (int)(distanceRight / mtsPx); |
|
178 |
return DefaultRasterManager.getInstance().createBuffer(dataType, |
|
179 |
(int)((w / nCols) + distanceLeftPx + distanceRightPx), |
|
180 |
(int)((h / nRows) + distanceUpPx + distanceDownPx), |
|
181 |
bands, |
|
182 |
true); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Gets the point list to clip the tile |
|
187 |
* @param r Bounding box of the tile |
|
188 |
* @param b Buffer of the tile |
|
189 |
* @param extentRequest |
|
190 |
* @return |
|
191 |
*/ |
|
192 |
private int[] getClipPoints(Rectangle2D r, Buffer b, Extent extentRequest) { |
|
193 |
double widthWCTile = r.getWidth(); |
|
194 |
double widthPXTile = b.getWidth(); |
|
195 |
double heightWCTile = r.getHeight(); |
|
196 |
double heightPXTile = b.getHeight(); |
|
197 |
|
|
198 |
//1-Ajustar peti?n al extent del tile |
|
199 |
Extent adjustedRequestExtent = getAdjustedExtent(r, extentRequest); |
|
200 |
|
|
201 |
//2-Obtener el punto inicial y final del recorte del tile en pixeles |
|
202 |
double wcX1 = adjustedRequestExtent.getMin().getX() - r.getX(); |
|
203 |
double wcX2 = adjustedRequestExtent.getMax().getX() - r.getX(); |
|
204 |
double wcY1 = r.getY() - adjustedRequestExtent.getMax().getY(); |
|
205 |
double wcY2 = r.getY() - adjustedRequestExtent.getMin().getY(); |
|
206 |
int initXPxTile = (int)((wcX1 * widthPXTile) / widthWCTile); |
|
207 |
int endXPxTile = (int)((wcX2 * widthPXTile) / widthWCTile) - 1; |
|
208 |
int initYPxTile = (int)((wcY1 * heightPXTile) / heightWCTile); |
|
209 |
int endYPxTile = (int)((wcY2 * heightPXTile) / heightWCTile) - 1; |
|
210 |
return new int[]{initXPxTile, |
|
211 |
endXPxTile >= widthPXTile ? endXPxTile - 1 : endXPxTile, |
|
212 |
initYPxTile, |
|
213 |
endYPxTile >= heightPXTile ? endYPxTile - 1 : endYPxTile}; |
|
214 |
} |
|
215 |
|
|
216 |
/** |
|
217 |
* Adjust the request to the tile bounding box |
|
218 |
* @param tileExtent |
|
219 |
* @param extentRequest |
|
220 |
* @return |
|
221 |
*/ |
|
222 |
private Extent getAdjustedExtent(Rectangle2D tileExtent, Extent extentRequest) { |
|
223 |
double x1 = Math.max(extentRequest.getMin().getX(), tileExtent.getX()); |
|
224 |
double y1 = Math.min(extentRequest.getMax().getY(), tileExtent.getY()); |
|
225 |
double x2 = Math.min(extentRequest.getMax().getX(), (tileExtent.getX() + tileExtent.getWidth())); |
|
226 |
double y2 = Math.max(extentRequest.getMin().getY(), (tileExtent.getY() - tileExtent.getHeight())); |
|
227 |
return new ExtentImpl(x1, y1, x2, y2); |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* Write data in the source buffer taking into account the view shift |
|
232 |
* @param sourceBuf |
|
233 |
* @param tileBuf |
|
234 |
* @param rTile |
|
235 |
* @param initXPxBuf |
|
236 |
* @param initYPxBuf |
|
237 |
*/ |
|
238 |
private void loadBuffer(Buffer sourceBuf, Buffer tileBuf, Rectangle2D rTile, int initXPxBuf, int initYPxBuf) { |
|
239 |
int r = initXPxBuf; |
|
240 |
int c = initYPxBuf; |
|
241 |
if(tileBuf.getDataType() == Buffer.TYPE_BYTE) { |
|
242 |
for (int band = 0; band < sourceBuf.getBandCount(); band++) { |
|
243 |
r = initYPxBuf; |
|
244 |
for (int row = (int)rTile.getMinY(); row < (int)rTile.getMaxY(); row++) { |
|
245 |
c = initXPxBuf; |
|
246 |
for (int col = (int)rTile.getMinX(); col < (int)rTile.getMaxX(); col++) { |
|
247 |
sourceBuf.setElem(r, c, band, tileBuf.getElemByte(row, col, band)); |
|
248 |
c++; |
|
249 |
} |
|
250 |
r++; |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
if(tileBuf.getDataType() == Buffer.TYPE_SHORT) { |
|
255 |
for (int band = 0; band < sourceBuf.getBandCount(); band++) { |
|
256 |
r = initYPxBuf; |
|
257 |
for (int row = (int)rTile.getMinY(); row < (int)rTile.getMaxY(); row++) { |
|
258 |
c = initXPxBuf; |
|
259 |
for (int col = (int)rTile.getMinX(); col < (int)rTile.getMaxX(); col++) { |
|
260 |
sourceBuf.setElem(r, c, band, tileBuf.getElemShort(row, col, band)); |
|
261 |
c++; |
|
262 |
} |
|
263 |
r++; |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
if(tileBuf.getDataType() == Buffer.TYPE_INT) { |
|
268 |
for (int band = 0; band < sourceBuf.getBandCount(); band++) { |
|
269 |
r = initYPxBuf; |
|
270 |
for (int row = (int)rTile.getMinY(); row < (int)rTile.getMaxY(); row++) { |
|
271 |
c = initXPxBuf; |
|
272 |
for (int col = (int)rTile.getMinX(); col < (int)rTile.getMaxX(); col++) { |
|
273 |
sourceBuf.setElem(r, c, band, tileBuf.getElemInt(row, col, band)); |
|
274 |
c++; |
|
275 |
} |
|
276 |
r++; |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
if(tileBuf.getDataType() == Buffer.TYPE_FLOAT) { |
|
281 |
for (int band = 0; band < sourceBuf.getBandCount(); band++) { |
|
282 |
r = initYPxBuf; |
|
283 |
for (int row = (int)rTile.getMinY(); row < (int)rTile.getMaxY(); row++) { |
|
284 |
c = initXPxBuf; |
|
285 |
for (int col = (int)rTile.getMinX(); col < (int)rTile.getMaxX(); col++) { |
|
286 |
sourceBuf.setElem(r, c, band, tileBuf.getElemFloat(row, col, band)); |
|
287 |
c++; |
|
288 |
} |
|
289 |
r++; |
|
290 |
} |
|
291 |
} |
|
292 |
} |
|
293 |
if(tileBuf.getDataType() == Buffer.TYPE_DOUBLE) { |
|
294 |
for (int band = 0; band < sourceBuf.getBandCount(); band++) { |
|
295 |
r = initYPxBuf; |
|
296 |
for (int row = (int)rTile.getMinY(); row < (int)rTile.getMaxY(); row++) { |
|
297 |
c = initXPxBuf; |
|
298 |
for (int col = (int)rTile.getMinX(); col < (int)rTile.getMaxX(); col++) { |
|
299 |
sourceBuf.setElem(r, c, band, tileBuf.getElemDouble(row, col, band)); |
|
300 |
c++; |
|
301 |
} |
|
302 |
r++; |
|
303 |
} |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
|
|
309 |
/*private double clip(double value) { |
|
310 |
return math.clipDecimals(value, 5); |
|
311 |
} |
|
312 |
|
|
313 |
private double round(double value) { |
|
314 |
double a = (value - (int)value); |
|
315 |
return (a > 0.95 || a < 0.05) ? Math.round(value) : value; |
|
316 |
}*/ |
|
317 |
|
|
318 |
} |
|
0 | 319 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/RasterProvider.java | ||
---|---|---|
439 | 439 |
* Selects the subdataset. |
440 | 440 |
*/ |
441 | 441 |
public void selectSubdataset(); |
442 |
|
|
443 |
/** |
|
444 |
* Registers the provider selected to support the same formats that this one |
|
445 |
* @param point |
|
446 |
*/ |
|
447 |
public void registerTileProviderFormats(Class<RasterProvider> c); |
|
442 | 448 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/process/overview/GdalOverviewBuilder.java | ||
---|---|---|
25 | 25 |
import org.gvsig.addo.IOverviewIncrement; |
26 | 26 |
import org.gvsig.addo.Jaddo; |
27 | 27 |
import org.gvsig.addo.WritingException; |
28 |
import org.gvsig.fmap.dal.coverage.exception.OverviewException; |
|
29 |
import org.gvsig.fmap.dal.coverage.process.BaseIncrementableTask; |
|
28 | 30 |
import org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder; |
29 | 31 |
|
30 | 32 |
/** |
... | ... | |
36 | 38 |
public class GdalOverviewBuilder implements OverviewBuilder { |
37 | 39 |
private Jaddo build = new Jaddo(); |
38 | 40 |
private int value = 0; |
41 |
|
|
42 |
/** |
|
43 |
* Bindings between an IOverviewIncrement and a BaseIncrementableTask |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
*/ |
|
46 |
class ProcessBinding implements IOverviewIncrement { |
|
47 |
private BaseIncrementableTask task = null; |
|
48 |
|
|
49 |
public ProcessBinding(BaseIncrementableTask task) { |
|
50 |
this.task = task; |
|
51 |
} |
|
52 |
|
|
53 |
public int getPercent() { |
|
54 |
return task.getPercent(); |
|
55 |
} |
|
56 |
|
|
57 |
public void setPercent(int value) { |
|
58 |
task.setPercent(value); |
|
59 |
} |
|
60 |
} |
|
39 | 61 |
|
40 | 62 |
/* |
41 | 63 |
* (non-Javadoc) |
42 | 64 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#buildOverviews(int, java.lang.String, int[]) |
43 | 65 |
*/ |
44 | 66 |
public void buildOverviews(int resamplingAlg, String file, int[] overviews) |
45 |
throws BuildingOverviewsException, WritingException { |
|
46 |
build.buildOverviews(resamplingAlg, file, overviews); |
|
67 |
throws OverviewException { |
|
68 |
try { |
|
69 |
build.buildOverviews(resamplingAlg, file, overviews); |
|
70 |
} catch (BuildingOverviewsException e) { |
|
71 |
throw new OverviewException("Error building overviews", e); |
|
72 |
} catch (WritingException e) { |
|
73 |
throw new OverviewException("Error writing overviews", e); |
|
74 |
} |
|
47 | 75 |
} |
48 | 76 |
|
49 | 77 |
/* |
... | ... | |
58 | 86 |
* (non-Javadoc) |
59 | 87 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#setIncrementListener(org.gvsig.addo.IOverviewIncrement) |
60 | 88 |
*/ |
61 |
public void setIncrementListener(IOverviewIncrement incr) {
|
|
62 |
build.setIncrementListener(incr);
|
|
89 |
public void setIncrementListener(BaseIncrementableTask incr) {
|
|
90 |
build.setIncrementListener(new ProcessBinding(incr));
|
|
63 | 91 |
} |
64 | 92 |
|
65 | 93 |
/* |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/DefaultRasterManager.java | ||
---|---|---|
25 | 25 |
import java.awt.geom.Dimension2D; |
26 | 26 |
import java.lang.reflect.Constructor; |
27 | 27 |
import java.lang.reflect.InvocationTargetException; |
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Iterator; |
|
28 | 30 |
|
29 | 31 |
import org.cresques.cts.IProjection; |
30 | 32 |
import org.gvsig.fmap.dal.DataStoreParameters; |
... | ... | |
664 | 666 |
list); |
665 | 667 |
return params; |
666 | 668 |
} |
669 |
|
|
670 |
/* |
|
671 |
* (non-Javadoc) |
|
672 |
* @see org.gvsig.fmap.dal.coverage.RasterManager#registerTiledProviders(org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider) |
|
673 |
*/ |
|
674 |
public void registerFileProvidersTiled(String name, Class<?> provider) { |
|
675 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
676 |
ExtensionPoint point = extensionPoints.add("TiledProvider"); |
|
677 |
point.append(name, "", provider); |
|
678 |
} |
|
679 |
|
|
680 |
/* |
|
681 |
* (non-Javadoc) |
|
682 |
* @see org.gvsig.fmap.dal.coverage.RasterManager#registerTileProviderFormats(java.lang.Class) |
|
683 |
*/ |
|
684 |
@SuppressWarnings("unchecked") |
|
685 |
public void registerTileProviderFormats(Class<?> c) { |
|
686 |
if(c.isAssignableFrom(RasterProvider.class)) { |
|
687 |
try { |
|
688 |
ArrayList<?> pList = getTiledProviders(); |
|
689 |
for (int i = 0; i < pList.size(); i++) { |
|
690 |
((RasterProvider)pList.get(i)).registerTileProviderFormats((Class<RasterProvider>)c); |
|
691 |
} |
|
692 |
} catch (InstantiationException e) { |
|
693 |
} |
|
694 |
} |
|
695 |
} |
|
696 |
|
|
697 |
/* |
|
698 |
* (non-Javadoc) |
|
699 |
* @see org.gvsig.fmap.dal.coverage.RasterManager#getTiledProviders() |
|
700 |
*/ |
|
701 |
@SuppressWarnings("unchecked") |
|
702 |
private ArrayList<?> getTiledProviders() throws InstantiationException { |
|
703 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
704 |
ExtensionPoint point = extensionPoints.get("TiledProvider"); |
|
705 |
ArrayList list = new ArrayList(); |
|
706 |
Iterator it = point.iterator(); |
|
707 |
while(it.hasNext()) { |
|
708 |
Class<CoverageStoreProvider> provider = (Class<CoverageStoreProvider>)it.next(); |
|
709 |
try { |
|
710 |
Constructor c = provider.getConstructor(); |
|
711 |
list.add(c.newInstance()); |
|
712 |
} catch (SecurityException e) { |
|
713 |
throw new InstantiationException("Error SecurityException in open"); |
|
714 |
} catch (NoSuchMethodException e) { |
|
715 |
throw new InstantiationException("Error NoSuchMethodException in open"); |
|
716 |
} catch (IllegalArgumentException e) { |
|
717 |
throw new InstantiationException("Error IllegalArgumentException in open"); |
|
718 |
} catch (InstantiationException e) { |
|
719 |
throw new InstantiationException("Error InstantiationException in open"); |
|
720 |
} catch (IllegalAccessException e) { |
Also available in: Unified diff