Revision 2348
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/FLyrRaster.java | ||
---|---|---|
32 | 32 |
import org.cresques.cts.IProjection; |
33 | 33 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
34 | 34 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
35 |
import org.gvsig.fmap.dal.coverage.exception.GridException; |
|
36 | 35 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
37 | 36 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
38 | 37 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
39 | 38 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
40 |
import org.gvsig.fmap.dal.coverage.grid.Grid; |
|
41 | 39 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
42 | 40 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
43 | 41 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
... | ... | |
156 | 154 |
public int[] getTileSize(); |
157 | 155 |
|
158 | 156 |
/** |
159 |
* Obtiene el grid de la capa completa. Esta llamada devuelve un buffer de solo lectura |
|
160 |
* @param interpolated true si se solicita un grid interpolado y false si se solicita sin interpolar. |
|
161 |
* @return Grid. |
|
162 |
* @throws InterruptedException |
|
163 |
*/ |
|
164 |
public Grid getReadOnlyFullGrid(boolean interpolated) throws GridException, InterruptedException; |
|
165 |
|
|
166 |
/** |
|
167 | 157 |
* Obtiene el valor NoData asociado al raster. |
168 | 158 |
* @return double |
169 | 159 |
*/ |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java | ||
---|---|---|
56 | 56 |
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException; |
57 | 57 |
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException; |
58 | 58 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
59 |
import org.gvsig.fmap.dal.coverage.exception.GridException; |
|
60 | 59 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
61 | 60 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
62 | 61 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
... | ... | |
65 | 64 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
66 | 65 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
67 | 66 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
68 |
import org.gvsig.fmap.dal.coverage.grid.Grid; |
|
69 | 67 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
70 | 68 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
71 | 69 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
... | ... | |
74 | 72 |
import org.gvsig.fmap.dal.coverage.grid.render.VisualPropertyListener; |
75 | 73 |
import org.gvsig.fmap.dal.coverage.process.TaskEventManager; |
76 | 74 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
77 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
78 | 75 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
79 | 76 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters; |
80 | 77 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
... | ... | |
1251 | 1248 |
} |
1252 | 1249 |
|
1253 | 1250 |
/** |
1254 |
* Obtiene el grid de la capa completa. Hay que tener cuidado porque cuando se hace esta |
|
1255 |
* petici?n se carga un buffer con todos los datos de la capa. Este buffer puede ser |
|
1256 |
* cacheado o no dependiendo del tama?o de esta. |
|
1257 |
* @param interpolated true si se solicita un grid interpolado y false si se solicita sin interpolar. |
|
1258 |
* @return Grid. |
|
1259 |
* @throws InterruptedException |
|
1260 |
* @deprecated Don't use a <code>Grid</code> object. This will be removed soon |
|
1261 |
*/ |
|
1262 |
public Grid getFullGrid(boolean interpolated) throws GridException, InterruptedException { |
|
1263 |
RasterQuery query = rManager.createQuery(); |
|
1264 |
query.setAllDrawableBands(); |
|
1265 |
Buffer bf = null; |
|
1266 |
try { |
|
1267 |
query.setAreaOfInterest(); |
|
1268 |
bf = getDataStore().query(query); |
|
1269 |
} catch (QueryException e) { |
|
1270 |
throw new GridException("Error reading buffer"); |
|
1271 |
} catch (ProcessInterruptedException e) { |
|
1272 |
throw new InterruptedException("Carga interrumpida"); |
|
1273 |
} |
|
1274 |
return rManager.createGrid(bf, getDataStore(), interpolated); |
|
1275 |
} |
|
1276 |
|
|
1277 |
/** |
|
1278 |
* @deprecated Don't use a <code>Grid</code> object. This will be removed soon |
|
1279 |
*/ |
|
1280 |
public Grid getReadOnlyFullGrid(boolean interpolated) throws GridException, InterruptedException { |
|
1281 |
RasterQuery query = rManager.createQuery(); |
|
1282 |
query.setReadOnly(true); |
|
1283 |
query.setAllDrawableBands(); |
|
1284 |
Buffer bf = null; |
|
1285 |
try { |
|
1286 |
query.setAreaOfInterest(); |
|
1287 |
bf = getDataStore().query(query); |
|
1288 |
} catch (QueryException e) { |
|
1289 |
throw new GridException("Error reading buffer"); |
|
1290 |
} catch (ProcessInterruptedException e) { |
|
1291 |
throw new InterruptedException("Carga interrumpida"); |
|
1292 |
} |
|
1293 |
return rManager.createGrid(bf, getDataStore(), interpolated); |
|
1294 |
} |
|
1295 |
|
|
1296 |
/** |
|
1297 | 1251 |
* Obtiene el tama?o de celda de la fuente de datos |
1298 | 1252 |
* @return double con el tama?o de celda |
1299 | 1253 |
*/ |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/util/DefaultProviderServices.java | ||
---|---|---|
27 | 27 |
import java.lang.reflect.Constructor; |
28 | 28 |
import java.lang.reflect.InvocationTargetException; |
29 | 29 |
import java.util.ArrayList; |
30 |
import java.util.HashMap; |
|
30 | 31 |
import java.util.Iterator; |
31 | 32 |
import java.util.List; |
32 | 33 |
import java.util.Map; |
... | ... | |
70 | 71 |
import org.gvsig.raster.impl.DefaultRasterManager; |
71 | 72 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
72 | 73 |
import org.gvsig.raster.impl.provider.RasterProvider; |
74 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
75 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
73 | 76 |
import org.gvsig.raster.impl.store.WriteFileFormatFeatures; |
74 | 77 |
import org.gvsig.raster.impl.store.rmf.ClassSerializer; |
75 | 78 |
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager; |
... | ... | |
87 | 90 |
*/ |
88 | 91 |
public class DefaultProviderServices implements ProviderServices { |
89 | 92 |
public TreeMap<String, WriteFileFormatFeatures> |
90 |
fileFeature = new TreeMap<String, WriteFileFormatFeatures>(); |
|
91 |
private Logger log = LoggerFactory.getLogger(DefaultProviderServices.class); |
|
93 |
fileFeature = new TreeMap<String, WriteFileFormatFeatures>(); |
|
94 |
private Logger log = LoggerFactory.getLogger(DefaultProviderServices.class); |
|
95 |
private static List<Class<?>> tiledProviders = new ArrayList<Class<?>>(); |
|
96 |
private static Class<?> tileclass = null; |
|
97 |
private static HashMap<String, ArrayList<Class<?>>> |
|
98 |
formatsRegistry = new HashMap<String, ArrayList<Class<?>>>(); |
|
92 | 99 |
|
93 | 100 |
public DefaultRasterManager getManager() { |
94 | 101 |
return (DefaultRasterManager)RasterLocator.getManager(); |
... | ... | |
98 | 105 |
return fileFeature; |
99 | 106 |
} |
100 | 107 |
|
108 |
public RasterDataStore open(CoverageStoreProvider prov, DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
|
109 |
if(prov instanceof RasterProvider) { |
|
110 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
111 |
store.setProvider((RasterProvider)prov); |
|
112 |
try { |
|
113 |
store.intializePhase1(null, params); |
|
114 |
} catch (InitializeException e) { |
|
115 |
throw new RasterDriverException(e.getMessage()); |
|
116 |
} |
|
117 |
return store; |
|
118 |
} |
|
119 |
return null; |
|
120 |
} |
|
121 |
|
|
101 | 122 |
/** |
102 | 123 |
* Abre un dataset pasando como par�metros la proyecci�n y un objeto identificador del dataset. Este |
103 | 124 |
* objeto puede ser una ruta a un fichero en disco. En este caso la extensi�n del fichero servir� para |
... | ... | |
109 | 130 |
* @throws NotSupportedExtensionException |
110 | 131 |
* @throws RasterDriverException |
111 | 132 |
*/ |
112 |
public RasterDataStore open(DataStoreParameters param) throws NotSupportedExtensionException, RasterDriverException { |
|
113 |
return getManager().open(param); |
|
133 |
public RasterDataStore open(DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
|
134 |
if(params == null || !(params instanceof AbstractRasterDataParameters)) |
|
135 |
return null; |
|
136 |
DefaultRasterStore dSet = new DefaultRasterStore(); |
|
137 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
138 |
try { |
|
139 |
AbstractRasterProvider provider = (AbstractRasterProvider)dataManager.createProvider(dSet, (AbstractRasterDataParameters)params); |
|
140 |
dSet.setProvider(provider); |
|
141 |
} catch (InitializeException e) { |
|
142 |
throw new RasterDriverException("Error initializing provider", e); |
|
143 |
} catch (ProviderNotRegisteredException e) { |
|
144 |
throw new RasterDriverException("Provider not register error", e); |
|
145 |
} |
|
146 |
return dSet; |
|
114 | 147 |
} |
115 | 148 |
|
116 |
public RasterDataStore open(CoverageStoreProvider prov, DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
|
117 |
return getManager().open(prov, params); |
|
149 |
public RasterDataStore open(Object datasetOpenParam) throws NotSupportedExtensionException, RasterDriverException { |
|
150 |
DefaultRasterStore dSet = new DefaultRasterStore(); |
|
151 |
|
|
152 |
if (datasetOpenParam instanceof String) { |
|
153 |
AbstractRasterProvider provider = AbstractRasterProvider.singleDatasetInstance(dSet, (String)datasetOpenParam); |
|
154 |
dSet.setProvider(provider); |
|
155 |
return dSet; |
|
156 |
} |
|
157 |
|
|
158 |
/*if (datasetOpenParam instanceof String[]) { |
|
159 |
String[] param = (String[]) datasetOpenParam; |
|
160 |
try { |
|
161 |
for (int dataset = 0; dataset < param.length; dataset++) { |
|
162 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(dSet, param[dataset]) ); |
|
163 |
} |
|
164 |
} catch (OperationNotSupportedException e) { |
|
165 |
return open(param[0]); |
|
166 |
} |
|
167 |
return dSet; |
|
168 |
} |
|
169 |
|
|
170 |
if (datasetOpenParam instanceof Buffer[]) { |
|
171 |
Buffer[] param = (Buffer[]) datasetOpenParam; |
|
172 |
for (int dataset = 0; dataset < param.length; dataset++) { |
|
173 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(param[dataset])); |
|
174 |
} |
|
175 |
return dSet; |
|
176 |
} |
|
177 |
|
|
178 |
if(datasetOpenParam instanceof String[][]) { |
|
179 |
String[][] param = (String[][])datasetOpenParam; |
|
180 |
DefaultMultiRasterStore[][] mosaic = new DefaultMultiRasterStore[param.length][param[0].length]; |
|
181 |
for (int i = 0; i < param.length; i++) |
|
182 |
for (int j = 0; j < param[i].length; j++) |
|
183 |
mosaic[i][j] = (DefaultMultiRasterStore)open(param[i][j]); |
|
184 |
DefaultMosaicRasterStore cd; |
|
185 |
try { |
|
186 |
cd = new DefaultMosaicRasterStore(mosaic); |
|
187 |
} catch (MosaicNotValidException e) { |
|
188 |
return null; |
|
189 |
} |
|
190 |
return cd; |
|
191 |
}*/ |
|
192 |
|
|
193 |
return null; |
|
118 | 194 |
} |
119 | 195 |
|
120 | 196 |
public RasterDataStore open(String file) throws NotSupportedExtensionException, RasterDriverException, InitializeException, ProviderNotRegisteredException { |
... | ... | |
323 | 399 |
return result; |
324 | 400 |
} |
325 | 401 |
|
402 |
@SuppressWarnings("rawtypes") |
|
326 | 403 |
public String[] getWriteDriversType() { |
327 | 404 |
if (fileFeature.size() == 0) |
328 | 405 |
return null; |
... | ... | |
508 | 585 |
} |
509 | 586 |
|
510 | 587 |
public void addFormat(String ext, Class<?> c) { |
511 |
getManager().addFormat(ext, c); |
|
588 |
ArrayList<Class<?>> list = formatsRegistry.get(ext); |
|
589 |
if(list == null) { |
|
590 |
list = new ArrayList<Class<?>>(); |
|
591 |
list.add(c); |
|
592 |
formatsRegistry.put(ext, list); |
|
593 |
} else { |
|
594 |
if(!list.contains(c)) |
|
595 |
list.add(c); |
|
596 |
} |
|
512 | 597 |
} |
513 |
|
|
514 |
public String[] getReadOnlyFormatList() { |
|
515 |
return getManager().getReadOnlyFormatList(); |
|
516 |
} |
|
517 |
|
|
598 |
|
|
518 | 599 |
public boolean isExtensionSupported(String ext, Class<?> c) { |
519 |
return getManager().isExtensionSupported(ext, c); |
|
600 |
String extension = getManager().getFileUtils().getExtensionFromFileName(ext); |
|
601 |
|
|
602 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
|
603 |
if(list == null) { |
|
604 |
return false; |
|
605 |
} else { |
|
606 |
for (int i = 0; i < list.size(); i++) { |
|
607 |
if(c == list.get(i)) |
|
608 |
return true; |
|
609 |
} |
|
610 |
} |
|
611 |
return false; |
|
520 | 612 |
} |
521 |
|
|
613 |
|
|
522 | 614 |
public boolean isExtensionSupported(String ext) { |
523 |
return getManager().isExtensionSupported(ext); |
|
615 |
String extension = getManager().getFileUtils().getExtensionFromFileName(ext); |
|
616 |
|
|
617 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
|
618 |
if(list == null) { |
|
619 |
return false; |
|
620 |
} |
|
621 |
|
|
622 |
return true; |
|
524 | 623 |
} |
525 | 624 |
|
625 |
public String[] getReadOnlyFormatList() { |
|
626 |
return formatsRegistry.keySet().toArray(new String[0]); |
|
627 |
} |
|
628 |
|
|
526 | 629 |
public void registerFileProvidersTiled(Class<?> provider) { |
527 |
getManager().registerFileProvidersTiled(provider); |
|
630 |
if(!tiledProviders.contains(provider)) |
|
631 |
tiledProviders.add(provider); |
|
528 | 632 |
} |
529 | 633 |
|
530 | 634 |
public void registerTileProviderFormats(Class<?> c) { |
531 |
getManager().registerTileProviderFormats(c); |
|
635 |
if(tileclass == null) { |
|
636 |
if(RasterProvider.class.isAssignableFrom(c)) { |
|
637 |
List<Object> pList = getTiledProvidersInstance(); |
|
638 |
for (int i = 0; i < pList.size(); i++) { |
|
639 |
String[] fList = ((RasterProvider)pList.get(i)).getFormatList(); |
|
640 |
for (int j = 0; j < fList.length; j++) { |
|
641 |
String value = fList[j]; |
|
642 |
addFormat(value, c); |
|
643 |
} |
|
644 |
} |
|
645 |
} |
|
646 |
tileclass = c; |
|
647 |
} |
|
532 | 648 |
} |
533 | 649 |
|
650 |
private List<Object> getTiledProvidersInstance() { |
|
651 |
List<Object> list = new ArrayList<Object>(); |
|
652 |
for (int i = 0; i < tiledProviders.size(); i++) { |
|
653 |
Class<?> provider = tiledProviders.get(i); |
|
654 |
try { |
|
655 |
Constructor<?> c = provider.getConstructor(); |
|
656 |
list.add(c.newInstance()); |
|
657 |
} catch (SecurityException e) { |
|
658 |
log.info("Error SecurityException in open", e); |
|
659 |
} catch (NoSuchMethodException e) { |
|
660 |
log.info("Error NoSuchMethodException in open", e); |
|
661 |
} catch (IllegalArgumentException e) { |
|
662 |
log.info("Error IllegalArgumentException in open", e); |
|
663 |
} catch (InstantiationException e) { |
|
664 |
log.info("Error InstantiationException in open", e); |
|
665 |
} catch (IllegalAccessException e) { |
|
666 |
log.info("Error IllegalAccessException in open", e); |
|
667 |
} catch (InvocationTargetException e) { |
|
668 |
log.info("Error in open. Problemas con las librer?as nativas.", e); |
|
669 |
} |
|
670 |
} |
|
671 |
return list; |
|
672 |
} |
|
673 |
|
|
534 | 674 |
public void registerOverviewBuilderImplementation(String id, OverviewBuilder ovBuilder) { |
535 | 675 |
DefaultRasterManager.overviewBuilderRegistry.put(id, ovBuilder); |
536 | 676 |
} |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/process/vector/PotraceVectorization.java | ||
---|---|---|
22 | 22 |
package org.gvsig.raster.impl.process.vector; |
23 | 23 |
|
24 | 24 |
import java.util.ArrayList; |
25 |
import java.util.List; |
|
25 | 26 |
|
26 | 27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
27 | 28 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
... | ... | |
31 | 32 |
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization; |
32 | 33 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
33 | 34 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
35 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
36 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
34 | 37 |
import org.gvsig.jpotrace.Potrace; |
35 | 38 |
import org.gvsig.jpotrace.PotraceException; |
36 | 39 |
import org.gvsig.raster.impl.DefaultRasterManager; |
... | ... | |
110 | 113 |
* @throws ProcessInterruptedException |
111 | 114 |
*/ |
112 | 115 |
private void setFile(String file) throws QueryException, NotSupportedExtensionException, RasterDriverException, ProcessInterruptedException { |
113 |
RasterDataStore ds = DefaultRasterManager.getInstance().open(file); |
|
116 |
RasterDataStore ds = null; |
|
117 |
try { |
|
118 |
ds = DefaultRasterManager.getInstance().getProviderServices().open(file); |
|
119 |
} catch (InitializeException e) { |
|
120 |
throw new RasterDriverException("Error opening file", e); |
|
121 |
} catch (ProviderNotRegisteredException e) { |
|
122 |
throw new RasterDriverException("Error opening file", e); |
|
123 |
} |
|
114 | 124 |
setDataSource(ds); |
115 | 125 |
} |
116 | 126 |
|
... | ... | |
216 | 226 |
* main de un fichero en c) indicando la llamada entera al comando potrace. |
217 | 227 |
* @return |
218 | 228 |
*/ |
219 |
@SuppressWarnings("unchecked") |
|
220 | 229 |
private String[] getParams() { |
221 |
ArrayList params = new ArrayList();
|
|
230 |
List<String> params = new ArrayList<String>();
|
|
222 | 231 |
params.add("./potrace"); |
223 | 232 |
|
224 | 233 |
if (cornerThreshold != null) { |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/DefaultRasterManager.java | ||
---|---|---|
22 | 22 |
package org.gvsig.raster.impl; |
23 | 23 |
|
24 | 24 |
import java.awt.geom.AffineTransform; |
25 |
import java.awt.geom.Dimension2D; |
|
26 | 25 |
import java.lang.reflect.Constructor; |
27 | 26 |
import java.lang.reflect.InvocationTargetException; |
28 |
import java.util.ArrayList; |
|
29 | 27 |
import java.util.HashMap; |
30 | 28 |
import java.util.Set; |
31 | 29 |
|
32 | 30 |
import org.cresques.cts.IProjection; |
33 |
import org.gvsig.fmap.dal.DALLocator; |
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 | 31 |
import org.gvsig.fmap.dal.coverage.BufferFactory; |
36 | 32 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
37 | 33 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
38 | 34 |
import org.gvsig.fmap.dal.coverage.RasterService; |
39 | 35 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
40 | 36 |
import org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory; |
41 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
42 |
import org.gvsig.fmap.dal.coverage.datastruct.GridExtent; |
|
43 | 37 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
44 | 38 |
import org.gvsig.fmap.dal.coverage.datastruct.RasterLegend; |
45 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
|
46 | 39 |
import org.gvsig.fmap.dal.coverage.exception.FileNotExistsException; |
47 | 40 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
48 | 41 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
49 | 42 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
50 | 43 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
51 |
import org.gvsig.fmap.dal.coverage.exception.RasterBufferInvalidException; |
|
52 | 44 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
53 | 45 |
import org.gvsig.fmap.dal.coverage.exception.RasterLegendIONotFound; |
54 | 46 |
import org.gvsig.fmap.dal.coverage.filter.FilterLoader; |
55 |
import org.gvsig.fmap.dal.coverage.grid.Grid; |
|
56 | 47 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
57 | 48 |
import org.gvsig.fmap.dal.coverage.grid.render.ImageDrawer; |
58 | 49 |
import org.gvsig.fmap.dal.coverage.process.TaskEventManager; |
... | ... | |
62 | 53 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
63 | 54 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
64 | 55 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
65 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
66 | 56 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
67 | 57 |
import org.gvsig.fmap.dal.coverage.util.CRSUtils; |
68 | 58 |
import org.gvsig.fmap.dal.coverage.util.ColorConversion; |
... | ... | |
71 | 61 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
72 | 62 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
73 | 63 |
import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
74 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
75 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
76 | 64 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
77 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
|
78 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
79 | 65 |
import org.gvsig.raster.impl.buffer.DefaultDataServerWriter; |
80 | 66 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
81 | 67 |
import org.gvsig.raster.impl.buffer.RasterBuffer; |
... | ... | |
83 | 69 |
import org.gvsig.raster.impl.buffer.cache.RasterCache; |
84 | 70 |
import org.gvsig.raster.impl.buffer.cache.RasterReadOnlyBuffer; |
85 | 71 |
import org.gvsig.raster.impl.datastruct.DefaultDataStructFactory; |
86 |
import org.gvsig.raster.impl.datastruct.DefaultViewPortData; |
|
87 | 72 |
import org.gvsig.raster.impl.datastruct.legend.GimpGradients; |
88 | 73 |
import org.gvsig.raster.impl.datastruct.legend.GimpPalettes; |
89 | 74 |
import org.gvsig.raster.impl.datastruct.legend.LegendgvSIG; |
90 | 75 |
import org.gvsig.raster.impl.datastruct.legend.RasterLegendIO; |
91 |
import org.gvsig.raster.impl.grid.GridImpl; |
|
92 | 76 |
import org.gvsig.raster.impl.grid.filter.DefaultRasterFilterList; |
93 | 77 |
import org.gvsig.raster.impl.grid.filter.FilterLoaderImpl; |
94 | 78 |
import org.gvsig.raster.impl.grid.render.ImageDrawerImpl; |
... | ... | |
100 | 84 |
import org.gvsig.raster.impl.process.RasterTask; |
101 | 85 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
102 | 86 |
import org.gvsig.raster.impl.process.vector.PotraceVectorization; |
103 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
|
104 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
105 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
106 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
107 | 87 |
import org.gvsig.raster.impl.store.ParamsImpl; |
108 | 88 |
import org.gvsig.raster.impl.store.QueryableRaster; |
109 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
110 | 89 |
import org.gvsig.raster.impl.store.writer.DefaultRasterWriter; |
111 | 90 |
import org.gvsig.raster.roi.AbstractROI; |
112 | 91 |
import org.gvsig.raster.roi.ROIReader; |
... | ... | |
122 | 101 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
123 | 102 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
124 | 103 |
import org.gvsig.tools.service.ServiceException; |
125 |
import org.slf4j.Logger; |
|
126 |
import org.slf4j.LoggerFactory; |
|
127 | 104 |
|
128 | 105 |
/** |
129 | 106 |
* Default {@link RasterManager} implementation. |
... | ... | |
133 | 110 |
*/ |
134 | 111 |
public class DefaultRasterManager implements RasterManager { |
135 | 112 |
private static DefaultRasterManager internalInstance = new DefaultRasterManager(); |
136 |
private static final Logger logger = LoggerFactory.getLogger(DefaultRasterManager.class); |
|
113 |
//private static final Logger logger = LoggerFactory.getLogger(DefaultRasterManager.class);
|
|
137 | 114 |
private FileUtils file = null; |
138 | 115 |
private MathUtils math = null; |
139 | 116 |
private RasterUtils util = null; |
140 | 117 |
private ProviderServices pInfo = null; |
141 | 118 |
private DefaultColorConversion colorConversion = null; |
142 | 119 |
private DataStructFactory dataStructFactory = null; |
143 |
private static Class<?> tileclass = null; |
|
144 |
private static ArrayList<Class<?>> tiledProviders = new ArrayList<Class<?>>(); |
|
145 |
private static HashMap<String, ArrayList<Class<?>>> |
|
146 |
formatsRegistry = new HashMap<String, ArrayList<Class<?>>>(); |
|
120 |
|
|
147 | 121 |
public static HashMap<String, OverviewBuilder> |
148 | 122 |
overviewBuilderRegistry = new HashMap<String, OverviewBuilder>(); |
149 | 123 |
public static CRSUtils crsUtilRegistry = null; |
... | ... | |
222 | 196 |
return new DefaultDataServerWriter(); |
223 | 197 |
} |
224 | 198 |
|
225 |
public RasterDataStore open(CoverageStoreProvider prov, DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
|
226 |
if(prov instanceof RasterProvider) { |
|
227 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
228 |
store.setProvider((RasterProvider)prov); |
|
229 |
try { |
|
230 |
store.intializePhase1(null, params); |
|
231 |
} catch (InitializeException e) { |
|
232 |
throw new RasterDriverException(e.getMessage()); |
|
233 |
} |
|
234 |
return store; |
|
235 |
} |
|
236 |
return null; |
|
237 |
} |
|
238 |
|
|
239 |
public RasterDataStore open(DataStoreParameters params) throws NotSupportedExtensionException, RasterDriverException { |
|
240 |
if(params == null || !(params instanceof AbstractRasterDataParameters)) |
|
241 |
return null; |
|
242 |
DefaultRasterStore dSet = new DefaultRasterStore(); |
|
243 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
244 |
try { |
|
245 |
AbstractRasterProvider provider = (AbstractRasterProvider)dataManager.createProvider(dSet, (AbstractRasterDataParameters)params); |
|
246 |
dSet.setProvider(provider); |
|
247 |
} catch (InitializeException e) { |
|
248 |
throw new RasterDriverException("Error initializing provider", e); |
|
249 |
} catch (ProviderNotRegisteredException e) { |
|
250 |
throw new RasterDriverException("Provider not register error", e); |
|
251 |
} |
|
252 |
return dSet; |
|
253 |
} |
|
254 |
|
|
255 |
public RasterDataStore open(Object datasetOpenParam) throws NotSupportedExtensionException, RasterDriverException { |
|
256 |
DefaultRasterStore dSet = new DefaultRasterStore(); |
|
257 |
|
|
258 |
if (datasetOpenParam instanceof String) { |
|
259 |
AbstractRasterProvider provider = AbstractRasterProvider.singleDatasetInstance(dSet, (String)datasetOpenParam); |
|
260 |
dSet.setProvider(provider); |
|
261 |
return dSet; |
|
262 |
} |
|
263 |
|
|
264 |
/*if (datasetOpenParam instanceof String[]) { |
|
265 |
String[] param = (String[]) datasetOpenParam; |
|
266 |
try { |
|
267 |
for (int dataset = 0; dataset < param.length; dataset++) { |
|
268 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(dSet, param[dataset]) ); |
|
269 |
} |
|
270 |
} catch (OperationNotSupportedException e) { |
|
271 |
return open(param[0]); |
|
272 |
} |
|
273 |
return dSet; |
|
274 |
} |
|
275 |
|
|
276 |
if (datasetOpenParam instanceof Buffer[]) { |
|
277 |
Buffer[] param = (Buffer[]) datasetOpenParam; |
|
278 |
for (int dataset = 0; dataset < param.length; dataset++) { |
|
279 |
dSet.addDataStore(DefaultRasterProvider.singleDatasetInstance(param[dataset])); |
|
280 |
} |
|
281 |
return dSet; |
|
282 |
} |
|
283 |
|
|
284 |
if(datasetOpenParam instanceof String[][]) { |
|
285 |
String[][] param = (String[][])datasetOpenParam; |
|
286 |
DefaultMultiRasterStore[][] mosaic = new DefaultMultiRasterStore[param.length][param[0].length]; |
|
287 |
for (int i = 0; i < param.length; i++) |
|
288 |
for (int j = 0; j < param[i].length; j++) |
|
289 |
mosaic[i][j] = (DefaultMultiRasterStore)open(param[i][j]); |
|
290 |
DefaultMosaicRasterStore cd; |
|
291 |
try { |
|
292 |
cd = new DefaultMosaicRasterStore(mosaic); |
|
293 |
} catch (MosaicNotValidException e) { |
|
294 |
return null; |
|
295 |
} |
|
296 |
return cd; |
|
297 |
}*/ |
|
298 |
|
|
299 |
return null; |
|
300 |
} |
|
301 |
|
|
302 | 199 |
public RasterQuery createQuery() { |
303 | 200 |
return new DefaultRasterQuery(); |
304 | 201 |
} |
... | ... | |
330 | 227 |
return new RasterMemoryBuffer(dataType, width, height, bandNr, malloc); |
331 | 228 |
} |
332 | 229 |
|
333 |
@SuppressWarnings("unchecked") |
|
334 | 230 |
public RasterWriter createWriter(String fName) throws NotSupportedExtensionException, RasterDriverException { |
335 | 231 |
String ext = getFileUtils().getExtensionFromFileName(fName); |
336 | 232 |
DefaultRasterWriter grw = null; |
... | ... | |
341 | 237 |
if (!point.has(ext)) |
342 | 238 |
return grw; |
343 | 239 |
|
344 |
Class clase = point.get(ext).getExtension(); |
|
345 |
Class[] args = { String.class }; |
|
240 |
Class<?> clase = point.get(ext).getExtension();
|
|
241 |
Class<?>[] args = { String.class };
|
|
346 | 242 |
try { |
347 |
Constructor hazNuevo = clase.getConstructor(args); |
|
243 |
Constructor<?> hazNuevo = clase.getConstructor(args);
|
|
348 | 244 |
Object[] args2 = { fName }; |
349 | 245 |
grw = (DefaultRasterWriter) hazNuevo.newInstance(args2); |
350 | 246 |
} catch (SecurityException e) { |
... | ... | |
375 | 271 |
return createWriter(dataWriter, outFileName, nBands, at, outSizeX, outSizeY, dataType, params, proj, true); |
376 | 272 |
} |
377 | 273 |
|
378 |
@SuppressWarnings("unchecked") |
|
379 | 274 |
public RasterWriter createWriter(DataServerWriter dataWriter, |
380 | 275 |
String outFileName, |
381 | 276 |
int nBands, |
... | ... | |
394 | 289 |
if (!point.has(ext)) |
395 | 290 |
return grw; |
396 | 291 |
|
397 |
Class clase = point.get(ext).getExtension(); |
|
398 |
Class[] args = { DataServerWriter.class, String.class, Integer.class, AffineTransform.class, Integer.class, Integer.class, Integer.class, Params.class, IProjection.class, Boolean.class }; |
|
292 |
Class<?> clase = point.get(ext).getExtension();
|
|
293 |
Class<?>[] args = { DataServerWriter.class, String.class, Integer.class, AffineTransform.class, Integer.class, Integer.class, Integer.class, Params.class, IProjection.class, Boolean.class };
|
|
399 | 294 |
try { |
400 |
Constructor hazNuevo = clase.getConstructor(args); |
|
295 |
Constructor<?> hazNuevo = clase.getConstructor(args);
|
|
401 | 296 |
Object [] args2 = {dataWriter, outFileName, new Integer(nBands), at, |
402 | 297 |
new Integer(outSizeX), new Integer(outSizeY), new Integer(dataType), |
403 | 298 |
params, proj, new Boolean(geo)}; |
... | ... | |
454 | 349 |
return overviewBuilderRegistry.keySet(); |
455 | 350 |
} |
456 | 351 |
|
457 |
public ColorInterpretation createColorInterpretation(String[] colorInterp) { |
|
458 |
return new DataStoreColorInterpretation(colorInterp); |
|
459 |
} |
|
460 |
|
|
461 | 352 |
public FilterLoader createFilterLoader(int dataType) { |
462 | 353 |
return new FilterLoaderImpl(dataType); |
463 | 354 |
} |
... | ... | |
466 | 357 |
return new FilterLoaderImpl(filterList); |
467 | 358 |
} |
468 | 359 |
|
469 |
public Grid createGrid(RasterDataStore datasource, int[] bands, GridExtent windowExtent) throws RasterBufferInvalidException { |
|
470 |
return new GridImpl(datasource, bands, windowExtent); |
|
471 |
} |
|
472 |
|
|
473 |
public Grid createGrid(RasterDataStore datasource, int[] bands) throws RasterBufferInvalidException { |
|
474 |
return new GridImpl(datasource, bands); |
|
475 |
} |
|
476 |
|
|
477 |
public Grid createGrid(RasterDataStore datasource) throws RasterBufferInvalidException { |
|
478 |
return new GridImpl(datasource); |
|
479 |
} |
|
480 |
|
|
481 |
public Grid createGrid(GridExtent layerExtent, |
|
482 |
GridExtent windowExtent, |
|
483 |
int dataType, |
|
484 |
int[] bands) throws RasterBufferInvalidException { |
|
485 |
return new GridImpl(layerExtent, windowExtent, dataType, bands); |
|
486 |
} |
|
487 |
|
|
488 |
public Grid createGrid(Buffer buf, RasterDataStore datasource, boolean notInterp) { |
|
489 |
return new GridImpl(buf, datasource, notInterp); |
|
490 |
} |
|
491 |
|
|
492 | 360 |
public Historical createHistoricalService() { |
493 | 361 |
return new DefaultHistorical(); |
494 | 362 |
} |
495 | 363 |
|
496 |
public ViewPortData createViewPortData(IProjection proj, Extent extent, Dimension2D size) { |
|
497 |
return new DefaultViewPortData(proj, extent, size); |
|
498 |
} |
|
499 |
|
|
500 |
public ViewPortData createViewPortData() { |
|
501 |
return new DefaultViewPortData(); |
|
502 |
} |
|
503 |
|
|
504 | 364 |
public ColorConversion getColorConversion() { |
505 | 365 |
if(colorConversion == null) |
506 | 366 |
colorConversion = new DefaultColorConversion(); |
... | ... | |
550 | 410 |
return params; |
551 | 411 |
} |
552 | 412 |
|
553 |
public void registerFileProvidersTiled(Class<?> provider) { |
|
554 |
if(!tiledProviders.contains(provider)) |
|
555 |
tiledProviders.add(provider); |
|
556 |
} |
|
557 |
|
|
558 |
public void registerTileProviderFormats(Class<?> c) { |
|
559 |
if(tileclass == null) { |
|
560 |
if(RasterProvider.class.isAssignableFrom(c)) { |
|
561 |
ArrayList<?> pList = getTiledProvidersInstance(); |
|
562 |
for (int i = 0; i < pList.size(); i++) { |
|
563 |
String[] fList = ((RasterProvider)pList.get(i)).getFormatList(); |
|
564 |
for (int j = 0; j < fList.length; j++) { |
|
565 |
String value = fList[j]; |
|
566 |
addFormat(value, c); |
|
567 |
} |
|
568 |
} |
|
569 |
} |
|
570 |
tileclass = c; |
|
571 |
} |
|
572 |
} |
|
573 |
|
|
574 |
@SuppressWarnings("unchecked") |
|
575 |
private ArrayList<?> getTiledProvidersInstance() { |
|
576 |
ArrayList list = new ArrayList(); |
|
577 |
for (int i = 0; i < tiledProviders.size(); i++) { |
|
578 |
Class<?> provider = tiledProviders.get(i); |
|
579 |
try { |
|
580 |
Constructor c = provider.getConstructor(); |
|
581 |
list.add(c.newInstance()); |
|
582 |
} catch (SecurityException e) { |
|
583 |
logger.info("Error SecurityException in open", e); |
|
584 |
} catch (NoSuchMethodException e) { |
|
585 |
logger.info("Error NoSuchMethodException in open", e); |
|
586 |
} catch (IllegalArgumentException e) { |
|
587 |
logger.info("Error IllegalArgumentException in open", e); |
|
588 |
} catch (InstantiationException e) { |
|
589 |
logger.info("Error InstantiationException in open", e); |
|
590 |
} catch (IllegalAccessException e) { |
|
591 |
logger.info("Error IllegalAccessException in open", e); |
|
592 |
} catch (InvocationTargetException e) { |
|
593 |
logger.info("Error in open. Problemas con las librer?as nativas.", e); |
|
594 |
} |
|
595 |
} |
|
596 |
return list; |
|
597 |
} |
|
598 |
|
|
599 |
public void addFormat(String ext, Class<?> c) { |
|
600 |
ArrayList<Class<?>> list = formatsRegistry.get(ext); |
|
601 |
if(list == null) { |
|
602 |
list = new ArrayList<Class<?>>(); |
|
603 |
list.add(c); |
|
604 |
formatsRegistry.put(ext, list); |
|
605 |
} else { |
|
606 |
if(!list.contains(c)) |
|
607 |
list.add(c); |
|
608 |
} |
|
609 |
} |
|
610 |
|
|
611 |
public boolean isExtensionSupported(String ext, Class<?> c) { |
|
612 |
String extension = getFileUtils().getExtensionFromFileName(ext); |
|
613 |
|
|
614 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
|
615 |
if(list == null) { |
|
616 |
return false; |
|
617 |
} else { |
|
618 |
for (int i = 0; i < list.size(); i++) { |
|
619 |
if(c == list.get(i)) |
|
620 |
return true; |
|
621 |
} |
|
622 |
} |
|
623 |
return false; |
|
624 |
} |
|
625 |
|
|
626 |
public boolean isExtensionSupported(String ext) { |
|
627 |
String extension = getFileUtils().getExtensionFromFileName(ext); |
|
628 |
|
|
629 |
ArrayList<Class<?>> list = formatsRegistry.get(extension); |
|
630 |
if(list == null) { |
|
631 |
return false; |
|
632 |
} |
|
633 |
|
|
634 |
return true; |
|
635 |
} |
|
636 |
|
|
637 |
public String[] getReadOnlyFormatList() { |
|
638 |
return formatsRegistry.keySet().toArray(new String[0]); |
|
639 |
} |
|
640 |
|
|
641 | 413 |
public ImageDrawer createImageDrawerService() { |
642 | 414 |
return new ImageDrawerImpl(); |
643 | 415 |
} |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/convolution/ConvolutionListManager.java | ||
---|---|---|
91 | 91 |
} |
92 | 92 |
} |
93 | 93 |
|
94 |
/*public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
|
95 |
if (rf instanceof ConvolutionFilter) { |
|
96 |
filterList.add("filter.convolution.active=true"); |
|
97 |
ConvolutionFilter convolutionFilter = (ConvolutionFilter) rf; |
|
98 |
switch (convolutionFilter.ladoVentana) { |
|
99 |
case 0: |
|
100 |
filterList.add("filter.convolution.ladoVentana=3"); |
|
101 |
break; |
|
102 |
case 1: |
|
103 |
filterList.add("filter.convolution.ladoVentana=5"); |
|
104 |
break; |
|
105 |
case 2: |
|
106 |
filterList.add("filter.convolution.ladoVentana=7"); |
|
107 |
break; |
|
108 |
} |
|
109 |
|
|
110 |
filterList.add("filter.convolution.filterName=" + convolutionFilter.getName()); |
|
111 |
if (convolutionFilter.getName().equals("personalizado")) { |
|
112 |
double[][] listDouble = convolutionFilter.kernel.kernel; |
|
113 |
String listString = ""; |
|
114 |
for (int i = 0; i < listDouble.length; i++) |
|
115 |
for (int j = 0; j < listDouble[0].length; j++) |
|
116 |
listString = listString + listDouble[i][j] + " "; |
|
117 |
|
|
118 |
listString = listString.trim(); |
|
119 |
filterList.add("filter.convolution.kernel=" + listString); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
return filterList; |
|
124 |
}*/ |
|
125 |
|
|
126 |
/*public int createFilterListFromStrings(List<String> filters, String fil, int filteri) throws FilterTypeException { |
|
127 |
if ((fil.startsWith("filter.convolution.active")) && (RasterFilterListManagerImpl.getValue(fil).equals("true"))) { |
|
128 |
int ladoVentana = 0; |
|
129 |
double agudeza = 0; |
|
130 |
String name = ""; |
|
131 |
Kernel kernel = null; |
|
132 |
filters.remove(0); |
|
133 |
for (int prop = 0; prop < filters.size(); prop++) { |
|
134 |
String elem = (String) filters.get(prop); |
|
135 |
if (elem.startsWith("filter.convolution.ladoVentana")) { |
|
136 |
ladoVentana = Integer.parseInt(RasterFilterListManagerImpl.getValue(elem)); |
|
137 |
ladoVentana = (ladoVentana == 7) ? 2 : (ladoVentana == 5) ? 1 : 0; |
|
138 |
filters.remove(prop); |
|
139 |
prop--; |
|
140 |
} |
|
141 |
if (elem.startsWith("filter.convolution.filterName")) { |
|
142 |
name = RasterFilterListManagerImpl.getValue(elem); |
|
143 |
filters.remove(prop); |
|
144 |
prop--; |
|
145 |
} |
|
146 |
if (elem.startsWith("filter.convolution.kernel")) { |
|
147 |
String k = RasterFilterListManagerImpl.getValue(elem); |
|
148 |
String[] listString = k.split(" "); |
|
149 |
if (listString != null) { |
|
150 |
int lado = (ladoVentana == 0) ? 3 : (ladoVentana == 1) ? 5 : 7; |
|
151 |
double[][] listDouble = new double[lado][lado]; |
|
152 |
int cont = 0; |
|
153 |
for (int i = 0; i < lado; i++) { |
|
154 |
for (int j = 0; j < lado; j++) { |
|
155 |
try { |
|
156 |
listDouble[i][j] = Double.parseDouble(listString[cont]); |
|
157 |
cont++; |
|
158 |
} catch (NumberFormatException e) { |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
kernel = new Kernel(listDouble); |
|
163 |
} |
|
164 |
filters.remove(prop); |
|
165 |
prop--; |
|
166 |
} |
|
167 |
if (elem.startsWith("filter.convolution.agudeza")) { |
|
168 |
agudeza = Double.parseDouble(RasterFilterListManagerImpl.getValue(elem)); |
|
169 |
filters.remove(prop); |
|
170 |
prop--; |
|
171 |
} |
|
172 |
} |
|
173 |
addConvolutionFilter(name, ladoVentana, agudeza, kernel); |
|
174 |
} |
|
175 |
return filteri; |
|
176 |
}*/ |
|
177 |
|
|
178 | 94 |
public void addFilter(Class<?> classFilter, Params params) throws FilterTypeException { |
179 | 95 |
if (ConvolutionFilter.class.isAssignableFrom(classFilter)) { |
180 | 96 |
int ladoVentana = 0; |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/band/ColorTableFilter.java | ||
---|---|---|
103 | 103 |
public boolean isVisible() { |
104 | 104 |
return false; |
105 | 105 |
} |
106 |
|
|
107 |
public boolean isToConvertToRGB() { |
|
108 |
return true; |
|
109 |
} |
|
106 | 110 |
|
107 | 111 |
/** |
108 | 112 |
* Obtiene la tabla de color que se usar? para la aplicaci?n del filtro |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/GrayScaleManager.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.grid.filter.enhancement; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
30 |
import org.gvsig.fmap.dal.coverage.grid.AbstractRasterFilterManager; |
|
31 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
32 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
33 |
/** |
|
34 |
* Gestor del filtro de conversi?n a escala de grises |
|
35 |
* |
|
36 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
37 |
*/ |
|
38 |
public class GrayScaleManager extends AbstractRasterFilterManager { |
|
39 |
public static String ID = "GrayScale"; |
|
40 |
|
|
41 |
public String getManagerID() { |
|
42 |
return ID; |
|
43 |
} |
|
44 |
|
|
45 |
public static void register() { |
|
46 |
AbstractRasterFilterManager.register(ID, GrayScaleManager.class); |
|
47 |
} |
|
48 |
|
|
49 |
public boolean isDataTypeSupported(int dataType) { |
|
50 |
if(dataType != Buffer.TYPE_BYTE) |
|
51 |
return false; |
|
52 |
return true; |
|
53 |
} |
|
54 |
|
|
55 |
public Class<?> getFilterClassByID(String id) { |
|
56 |
if( id.compareTo("grayscale") == 0) |
|
57 |
return GrayScaleFilter.class; |
|
58 |
return null; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Constructor. |
|
63 |
* Asigna la lista de filtros y el managener global. |
|
64 |
* |
|
65 |
* @param filterListManager |
|
66 |
*/ |
|
67 |
public GrayScaleManager(RasterFilterList filterList) { |
|
68 |
super(filterList); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* A?ade un filtro de conversi?n de balance de color RGB. |
|
73 |
* @param type. par?metro para el filtro que indica que banda o combinaci?n de |
|
74 |
* estas es usada para la conversi?n a escala de gris. El valor de este par?mtro |
|
75 |
* est? definido en las constantes de la clase GrayScaleFilter |
|
76 |
* @throws FilterTypeException |
|
77 |
*/ |
|
78 |
public void addGrayScaleFilter(int type) throws FilterTypeException { |
|
79 |
RasterFilter filter = new GrayScaleByteFilter(); |
|
80 |
|
|
81 |
if (filter != null) { |
|
82 |
filter.addParam("typeBand", new Integer(type)); |
|
83 |
getFilterList().add(filter); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
public List<Class<?>> getRasterFilterList() { |
|
88 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
|
89 |
filters.add(GrayScaleFilter.class); |
|
90 |
return filters; |
|
91 |
} |
|
92 |
|
|
93 |
public void addFilter(Class<?> classFilter, Params params) throws FilterTypeException { |
|
94 |
if (classFilter.equals(GrayScaleFilter.class)) { |
|
95 |
int type = 0; |
|
96 |
|
|
97 |
for (int i = 0; i < params.getNumParams(); i++) { |
|
98 |
if (params.getParam(i).getId().equals("typeBand")) |
|
99 |
type = ((Integer) params.getParam(i).getDefaultValue()).intValue(); |
|
100 |
} |
|
101 |
addGrayScaleFilter(type); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
public RasterFilter createFilter(Params params) { |
|
106 |
Integer type = ((Integer) params.getParamById("typeBand").getDefaultValue()); |
|
107 |
|
|
108 |
RasterFilter filter = new GrayScaleByteFilter(); |
|
109 |
filter.addParam("typeBand", type); |
|
110 |
return filter; |
|
111 |
} |
|
112 |
|
|
113 |
public void addFilter(Params params) throws FilterTypeException { |
|
114 |
addFilter(GrayScaleFilter.class, params); |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/EnhancementStretchListManager.java | ||
---|---|---|
45 | 45 |
public class EnhancementStretchListManager extends AbstractRasterFilterManager { |
46 | 46 |
private static String ID = "EnhancementStretch"; |
47 | 47 |
private RasterFilterListManagerImpl filterListManager = null; |
48 |
//private Statistics stats = null; |
|
49 | 48 |
|
50 | 49 |
/** |
51 | 50 |
* Default constructor. Sets the filter list. |
... | ... | |
53 | 52 |
*/ |
54 | 53 |
public EnhancementStretchListManager(RasterFilterList filterList) { |
55 | 54 |
super(filterList); |
56 |
//stats = (Statistics)filterList.getEnvParam("SrcStatistics"); |
|
57 | 55 |
} |
58 | 56 |
|
59 | 57 |
public String getManagerID() { |
... | ... | |
71 | 69 |
public EnhancementStretchListManager(RasterFilterListManagerImpl filterListManager) { |
72 | 70 |
super(filterListManager.getFilterList()); |
73 | 71 |
this.filterListManager = filterListManager; |
74 |
//stats = (Statistics)getFilterList().getEnvParam("SrcStatistics"); |
|
75 | 72 |
} |
76 | 73 |
|
77 | 74 |
public Class<?> getFilterClassByID(String id) { |
... | ... | |
181 | 178 |
return filter; |
182 | 179 |
} |
183 | 180 |
|
184 |
/** |
|
185 |
* Convierte un array de dobles a una cadena |
|
186 |
* @param values |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
/*private String convertArrayToString(double[] values) { |
|
190 |
StringBuffer buffer = new StringBuffer(); |
|
191 |
for (int i = 0; i < values.length; i++) { |
|
192 |
buffer.append(values[i]); |
|
193 |
if (i < (values.length - 1)) |
|
194 |
buffer.append(","); |
|
195 |
} |
|
196 |
return buffer.toString(); |
|
197 |
}*/ |
|
198 |
|
|
199 |
/** |
|
200 |
* Convierte una array de enteros a una cadena |
|
201 |
* @param values |
|
202 |
* @return |
|
203 |
*/ |
|
204 |
/*private String convertArrayToString(int[] values) { |
|
205 |
StringBuffer buffer = new StringBuffer(); |
|
206 |
for (int i = 0; i < values.length; i++) { |
|
207 |
buffer.append(values[i]); |
|
208 |
if (i < (values.length - 1)) |
|
209 |
buffer.append(","); |
|
210 |
} |
|
211 |
return buffer.toString(); |
|
212 |
}*/ |
|
213 |
|
|
214 |
/** |
|
215 |
* Convierte una cadena a un array de enteros |
|
216 |
* @param from |
|
217 |
* @return |
|
218 |
*/ |
|
219 |
/*private int[] StringToIntegerArray(String from) { |
|
220 |
String[] valueList = from.split(","); |
|
221 |
int[] values = new int[valueList.length]; |
|
222 |
for (int i = 0; i < values.length; i++) |
|
223 |
try { |
|
224 |
values[i] = Integer.parseInt(valueList[i]); |
|
225 |
} catch (NumberFormatException e) { |
|
226 |
} |
|
227 |
return values; |
|
228 |
}*/ |
|
229 |
|
|
230 |
/** |
|
231 |
* Convierte una cadena a un array de dobles |
|
232 |
* @param from |
|
233 |
* @return |
|
234 |
*/ |
|
235 |
/*private double[] StringToDoubleArray(String from) { |
|
236 |
String[] valueList = from.split(","); |
|
237 |
double[] values = new double[valueList.length]; |
|
238 |
for (int i = 0; i < values.length; i++) |
|
239 |
try { |
|
240 |
values[i] = Double.parseDouble(valueList[i]); |
|
241 |
} catch (NumberFormatException e) { |
|
242 |
} |
|
243 |
return values; |
|
244 |
}*/ |
|
245 |
|
|
246 |
/** |
|
247 |
* Guarda en el array de valores, todos los valores del objeto Strech para ser |
|
248 |
* almacenado en el |
|
249 |
* @param filterList |
|
250 |
* @param band |
|
251 |
* @param stretch |
|
252 |
*/ |
|
253 |
/*private void putStretchBand(List<String> filterList, String band, DefaultStretch stretch) { |
|
254 |
filterList.add("filter.linearstretchenhancement." + band + ".maxValue=" + stretch.maxValue); |
|
255 |
filterList.add("filter.linearstretchenhancement." + band + ".minValue=" + stretch.minValue); |
|
256 |
if (stretch.offset != null) |
|
257 |
filterList.add("filter.linearstretchenhancement." + band + ".offset=" + convertArrayToString(stretch.offset)); |
|
258 |
if (stretch.scale != null) |
|
259 |
filterList.add("filter.linearstretchenhancement." + band + ".scale=" + convertArrayToString(stretch.scale)); |
|
260 |
if (stretch.stretchIn != null) |
|
261 |
filterList.add("filter.linearstretchenhancement." + band + ".stretchIn=" + convertArrayToString(stretch.stretchIn)); |
|
262 |
if (stretch.stretchOut != null) |
|
263 |
filterList.add("filter.linearstretchenhancement." + band + ".stretchOut=" + convertArrayToString(stretch.stretchOut)); |
|
264 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimMax=" + stretch.tailTrimMax); |
|
265 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimMin=" + stretch.tailTrimMin); |
|
266 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimValueMax=" + stretch.tailTrimValueMax); |
|
267 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimValueMin=" + stretch.tailTrimValueMin); |
|
268 |
filterList.add("filter.linearstretchenhancement." + band + ".functionType=" + stretch.functionType); |
|
269 |
filterList.add("filter.linearstretchenhancement." + band + ".valueFunction=" + stretch.valueFunction); |
|
270 |
}*/ |
|
271 |
|
|
272 |
/** |
|
273 |
* Obtiene un Array de Strings a partir de una pila de filtros. Cada elemento |
|
274 |
* del array tendr� la forma de elemento=valor. |
|
275 |
*/ |
|
276 |
/*public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
|
277 |
if (rf instanceof LinearStretchEnhancementFilter) { |
|
278 |
LinearStretchEnhancementFilter filter = (LinearStretchEnhancementFilter) rf; |
|
279 |
DefaultLinearStretchParams stretchs = (DefaultLinearStretchParams) filter.getParam("stretchs"); |
|
280 |
int [] renderBands = (int[]) filter.getParam("renderBands"); |
|
281 |
|
|
282 |
filterList.add("filter.linearstretchenhancement.active=true"); |
|
283 |
filterList.add("filter.linearstretchenhancement.removeends=" + filter.getRemoveEnds()); |
|
284 |
putStretchBand(filterList, "red", stretchs.red); |
|
285 |
putStretchBand(filterList, "green", stretchs.green); |
|
286 |
putStretchBand(filterList, "blue", stretchs.blue); |
|
287 |
filterList.add("filter.linearstretchenhancement.renderbands=" + convertArrayToString(renderBands)); |
|
288 |
filterList.add("filter.linearstretchenhancement.RGB=" + Boolean.valueOf(stretchs.rgb).toString()); |
|
289 |
} |
|
290 |
|
|
291 |
return filterList; |
|
292 |
}*/ |
|
293 |
|
|
294 |
/** |
|
295 |
* Configura algun parametro del objeto Stretch, respecto a una banda, su |
|
296 |
* propiedad y el valor, en caso de no encontrar la propiedad o no ser dicha |
|
297 |
* banda, devuelve false. Es util para usarlo para extraer los valores de |
|
298 |
* createFilterListFromStrings |
|
299 |
* @param band |
|
300 |
* @param property |
|
301 |
* @param value |
|
302 |
* @param stretch |
|
303 |
* @return |
|
304 |
*/ |
|
305 |
/*private boolean getStretchBand(String band, String property, String value, DefaultStretch stretch) { |
|
306 |
if (property.startsWith("filter.linearstretchenhancement." + band)) { |
|
307 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".maxValue")) { |
|
308 |
stretch.maxValue = Double.parseDouble(value); |
|
309 |
return true; |
|
310 |
} |
|
311 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".minValue")) { |
|
312 |
stretch.minValue = Double.parseDouble(value); |
|
313 |
return true; |
|
314 |
} |
|
315 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".offset")) { |
|
316 |
stretch.offset = StringToDoubleArray(value); |
|
317 |
return true; |
|
318 |
} |
|
319 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".scale")) { |
|
320 |
stretch.scale = StringToDoubleArray(value); |
|
321 |
return true; |
|
322 |
} |
|
323 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".stretchIn")) { |
|
324 |
stretch.stretchIn = StringToDoubleArray(value); |
|
325 |
return true; |
|
326 |
} |
|
327 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".stretchOut")) { |
|
328 |
stretch.stretchOut = StringToIntegerArray(value); |
|
329 |
return true; |
|
330 |
} |
|
331 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimMax")) { |
|
332 |
stretch.tailTrimMax = Double.parseDouble(value); |
|
333 |
return true; |
|
334 |
} |
|
335 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimMin")) { |
|
336 |
stretch.tailTrimMin = Double.parseDouble(value); |
|
337 |
return true; |
|
338 |
} |
|
339 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimValueMax")) { |
|
340 |
stretch.tailTrimValueMax = Double.parseDouble(value); |
|
341 |
return true; |
|
342 |
} |
|
343 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimValueMin")) { |
|
344 |
stretch.tailTrimValueMin = Double.parseDouble(value); |
|
345 |
return true; |
|
346 |
} |
|
347 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".functionType")) { |
|
348 |
stretch.functionType = Integer.parseInt(value); |
|
349 |
return true; |
|
350 |
} |
|
351 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".valueFunction")) { |
|
352 |
stretch.valueFunction = Double.parseDouble(value); |
|
353 |
return true; |
|
354 |
} |
|
355 |
} |
|
356 |
return false; |
|
357 |
} |
|
358 |
|
|
359 |
public int createFilterListFromStrings(List<String> filters, String fil, int filteri) throws FilterTypeException { |
|
360 |
String pkgBase = "filter.linearstretchenhancement."; |
|
361 |
if (fil.startsWith(pkgBase + "active")) { |
|
362 |
boolean exec = true; |
|
363 |
boolean removeEnds = false; |
|
364 |
if ((RasterFilterListManagerImpl.getValue(fil).equals("false"))) |
|
365 |
exec = false; |
|
366 |
filters.remove(0); |
|
367 |
int[] renderBands = new int[] { 0, 0, 0 }; |
|
368 |
DefaultLinearStretchParams stretchParams = new DefaultLinearStretchParams(); |
|
369 |
|
|
370 |
for (int propFilter = 0; propFilter < filters.size(); propFilter++) { |
|
371 |
String elem = (String) filters.get(propFilter); |
|
372 |
String value = RasterFilterListManagerImpl.getValue(elem); |
|
373 |
|
|
374 |
if (elem.startsWith("filter.linearstretchenhancement.renderbands")) { |
|
375 |
renderBands = StringToIntegerArray(value); |
|
376 |
continue; |
|
377 |
} |
|
378 |
|
|
379 |
if (elem.startsWith("filter.linearstretchenhancement.RGB")) { |
|
380 |
stretchParams.rgb = Boolean.parseBoolean(value); |
|
381 |
continue; |
|
382 |
} |
|
383 |
|
|
384 |
if (elem |
|
385 |
.startsWith("filter.linearstretchenhancement.removeends")) { |
|
386 |
removeEnds = Boolean.parseBoolean(value); |
|
387 |
continue; |
|
388 |
} |
|
389 |
|
|
390 |
if (getStretchBand("red", elem, value, stretchParams.red)) |
|
391 |
continue; |
|
392 |
if (getStretchBand("green", elem, value, stretchParams.green)) |
|
393 |
continue; |
|
394 |
if (getStretchBand("blue", elem, value, stretchParams.blue)) |
|
395 |
continue; |
|
396 |
} |
|
397 |
|
|
398 |
getFilterList().remove(LinearStretchEnhancementFilter.class); |
|
399 |
addEnhancedStretchFilter(stretchParams, stats, renderBands, |
|
400 |
removeEnds); |
|
401 |
|
|
402 |
LinearStretchEnhancementFilter lsef = (LinearStretchEnhancementFilter) getFilterList().getFilterByBaseClass(LinearStretchEnhancementFilter.class); |
|
403 |
lsef.setExec(exec); |
|
404 |
} |
|
405 |
return filteri; |
|
406 |
}*/ |
|
407 |
|
|
408 |
/** |
|
409 |
* Asigna el objeto con las estadisticas. |
|
410 |
* @param stats |
|
411 |
*/ |
|
412 |
/*public void setStatistics(Statistics stats) { |
|
413 |
this.stats = stats; |
|
414 |
}*/ |
|
415 |
|
|
416 | 181 |
public List<Class<?>> getRasterFilterList() { |
417 | 182 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
418 | 183 |
filters.add(LinearStretchEnhancementFilter.class); |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/BrightnessContrastListManager.java | ||
---|---|---|
123 | 123 |
return filter; |
124 | 124 |
} |
125 | 125 |
|
126 |
/*public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
|
127 |
|
|
128 |
if ((rf instanceof BrightnessFilter) || (rf instanceof ContrastFilter)) { |
|
129 |
filterList.add("filter.brightCont.active=true"); |
|
130 |
} |
|
131 |
|
|
132 |
if (rf instanceof BrightnessFilter) { |
|
133 |
BrightnessFilter bright = (BrightnessFilter) rf; |
|
134 |
filterList.add("filter.brightness.incrBrillo=" + bright.incrBrillo); |
|
135 |
} else if (rf instanceof ContrastFilter) { |
|
136 |
ContrastFilter contrast = (ContrastFilter) rf; |
|
137 |
filterList.add("filter.contrast.incrContraste=" + contrast.incrContraste); |
|
138 |
} |
|
139 |
|
|
140 |
return filterList; |
|
141 |
} |
|
142 |
|
|
143 |
public int createFilterListFromStrings(List<String> filters, String fil, int filteri) throws FilterTypeException { |
|
144 |
if ((fil.startsWith("filter.brightCont.active")) && (RasterFilterListManagerImpl.getValue(fil).equals("true"))) { |
|
145 |
|
|
146 |
int incrBrillo = 0; |
|
147 |
int incrContraste = 0; |
|
148 |
filters.remove(0); |
|
149 |
|
|
150 |
for (int prop = 0; prop < filters.size(); prop++) { |
|
151 |
String elem = (String) filters.get(prop); |
|
152 |
if (elem.startsWith("filter.brightness.incrBrillo")) { |
|
153 |
incrBrillo = Integer.parseInt(RasterFilterListManagerImpl.getValue(elem)); |
|
154 |
addBrightnessFilter(incrBrillo); |
|
155 |
filters.remove(prop); |
|
156 |
prop--; |
|
157 |
} |
|
158 |
|
|
159 |
if (elem.startsWith("filter.contrast.incrContraste")) { |
|
160 |
incrContraste = Integer.parseInt(RasterFilterListManagerImpl.getValue(elem)); |
|
161 |
addContrastFilter(incrContraste); |
|
162 |
filters.remove(prop); |
|
163 |
prop--; |
|
164 |
} |
|
165 |
} |
|
166 |
filteri = -1; |
|
167 |
} |
|
168 |
return filteri; |
|
169 |
}*/ |
|
170 |
|
|
171 | 126 |
public List<Class<?>> getRasterFilterList() { |
172 | 127 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
173 | 128 |
filters.add(BrightnessFilter.class); |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/GrayScaleFilter.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.grid.filter.enhancement; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
25 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
26 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
27 |
import org.gvsig.fmap.dal.coverage.exception.FilterAddException; |
|
28 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
|
29 |
/** |
|
30 |
* <P> |
|
31 |
* Clase base para los filtros de conversi?n a escala de gris |
|
32 |
* </P> |
|
33 |
* |
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
35 |
*/ |
|
36 |
public class GrayScaleFilter extends BaseRasterFilter { |
|
37 |
public static final int R = 0; |
|
38 |
public static final int G = 1; |
|
39 |
public static final int B = 2; |
|
40 |
public static final int RGB = 3; |
|
41 |
public static final int GRAY = 4; |
|
42 |
public static final int UNDEFINED = -1; |
|
43 |
public static String[] names = new String[] { GrayScaleManager.ID }; |
|
44 |
protected int type = UNDEFINED; |
|
45 |
|
|
46 |
/** |
|
47 |
* Constructor |
|
48 |
*/ |
|
49 |
public GrayScaleFilter() { |
|
50 |
super(); |
|
51 |
setName(names[0]); |
|
52 |
} |
|
53 |
|
|
54 |
public void pre() throws FilterAddException { |
|
55 |
super.pre(); |
|
56 |
|
|
57 |
type = ((Integer)params.get("typeBand")).intValue(); |
|
58 |
|
|
59 |
if(type == RGB && raster.getBandCount() < 3) |
|
60 |
type = R; |
|
61 |
|
|
62 |
createARGBBufferResult(); |
|
63 |
} |
|
64 |
|
|
65 |
public String getGroup() { |
|
66 |
return "colores"; |
|
67 |
} |
|
68 |
|
|
69 |
public String[] getNames() { |
|
70 |
return names; |
|
71 |
} |
|
72 |
|
|
73 |
public Params getUIParams(String nameFilter) { |
|
74 |
if(type == UNDEFINED) { |
|
75 |
if(this.params != null) { |
|
76 |
Object obj = this.params.get("typeBand"); |
|
77 |
if(obj != null) |
|
78 |
type = ((Integer)obj).intValue(); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
Params params = RasterLocator.getManager().createParams( |
|
83 |
"typeBand", |
|
84 |
new Integer(R), |
|
85 |
Params.CHOICE, |
|
86 |
new String[]{ "R", "G", "B", "RGB", "GRAY"}); |
|
87 |
|
|
88 |
return params; |
|
89 |
} |
|
90 |
|
|
91 |
public void post() { |
|
92 |
} |
|
93 |
|
|
94 |
public void process(int x, int y) { |
|
95 |
} |
|
96 |
|
|
97 |
public int getOutRasterDataType() { |
|
98 |
return Buffer.TYPE_BYTE; |
|
99 |
} |
|
100 |
|
|
101 |
public boolean isVisible() { |
|
102 |
return true; |
|
103 |
} |
|
104 |
|
|
105 |
public int getInRasterDataType() { |
|
106 |
return Buffer.TYPE_BYTE; |
|
107 |
} |
|
108 |
} |
|
0 | 109 |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/LinearStretchEnhancementFilter.java | ||
---|---|---|
138 | 138 |
median += tailTrimList[i]; |
139 | 139 |
return new Double(nValues > 0 ? median / nValues : median); |
140 | 140 |
} |
141 |
|
|
142 |
public boolean isToConvertToRGB() { |
|
143 |
return true; |
|
144 |
} |
|
141 | 145 |
|
142 | 146 |
public int getOutRasterDataType() { |
143 | 147 |
return Buffer.TYPE_BYTE; |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/grid/filter/enhancement/GrayScaleByteFilter.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 |
Also available in: Unified diff