Class SampleModelFactory
java.lang.Object
org.apache.sis.internal.coverage.j2d.SampleModelFactory
A factory for
SampleModel instances. This class provides a convenient way to get the properties
of an existing sample model, modify them, then create a new sample model with the modified properties.- Since:
- 1.1
- Version:
- 1.1
- Author:
- Martin Desruisseaux (Geomatys)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSampleModelFactory(SampleModel model) Creates a new factory initialized to the value of given sample model.SampleModelFactory(DataType type, int width, int height, int numBands, int bitsPerSample, boolean isBanded) Creates a factory initialized to the given values. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a sample model based on current factory configuration.voidsubsetAndCompress(int[] bands) Requests a sample model with only a subset of the bands of the original sample model.
-
Constructor Details
-
SampleModelFactory
public SampleModelFactory(DataType type, int width, int height, int numBands, int bitsPerSample, boolean isBanded) Creates a factory initialized to the given values.- Parameters:
type- type of sample values.width- tile width in pixels.height- tile height in pixels.numBands- number of bands.bitsPerSample- number of bits per sample values.isBanded-trueif each band is stored in a separated bank.- Throws:
RasterFormatException- if the arguments imply a sample model of unsupported type.
-
SampleModelFactory
Creates a new factory initialized to the value of given sample model.- Parameters:
model- the sample model from which to copy values.- Throws:
RasterFormatException- if the type of the given sample model is not supported.
-
-
Method Details
-
subsetAndCompress
public void subsetAndCompress(int[] bands) Requests a sample model with only a subset of the bands of the original sample model. Special cases:- For
SinglePixelPackedSampleModel, this method may change the data type if decreasing the number of bands make possible to store pixels in smaller integers.
Comparison with standard method
The standardSampleModel.createSubsetSampleModel(int[])method also selects a subset of the bands. However, that standard method creates a sample model accepting the sameDataBufferthan the originalSampleModel, which is useful for creating a view of image data that are already in memory. By contrast, thisBandSelectorcompresses bank indices or pixel masks for leaving no empty space between them. This is useful when done before loading data from a file in order to avoid consuming space for bands that were not requested.- Parameters:
bands- bands to keep.- See Also:
- For
-
build
Builds a sample model based on current factory configuration. The factory is still valid after this method call.- Returns:
- the sample model built from current factory configuration.
- Throws:
IllegalArgumentException- if an error occurred while building a sample model.
-