Proposal : TileCodec API ~~~~~~~~~~~~~~~~~~~~~~~~ Aastha Bhardwaj Created: July 7, 2000 Revised: Oct 2, 2000 Revised: Dec 18, 2000 1. Motivation The motivation for a TileCodec API can be summarized as follows: a) To provide a means of persistent storage of tiles. b) To be able to encode and decode tiles on the ends of a network transmission for bandwidth conservation and security reasons. 2. API Classes Here's all the major classes that are used in the API. 2.1 Interface TileCodecDescriptor package javax.media.jai.tilecodec; /** * A class to describe a particular tile codec format. The getName * method of RegistryElementDescriptor should be implemented * to return the name of the format in an implementation of this interface. * This name is also the String with which this * TileCodecDescriptor is associated in the * OperationRegistry. There are two * complemetary modes that TileCodecs are expected to function in, the * decoding mode specified by the "tileDecoder" String and the encoding * mode specified by the "tileEncoder" String. It is not recommended that * separate classes be used to implement the different modes, but if this * is done, then includesSampleModelInfo() and * includesLocationInfo() methods must return the same values * from both the implementing classes. * *

In order to successfully decode an encoded tile data stream into a * decoded Raster, at the very least, a Point * specifying the top left corner of the Raster, a * SampleModel specifying the data layout described minimally * by the dataType, number of bands, width and height and a * DataBuffer with the decoded pixel data are needed. The * DataBuffer can be created from the information from the * SampleModel and the decoded data. Therefore the absolute * minimum information that is required in order to create a * Raster upon decoding (aside from the decoded data itself) * is the Point specifying the top left corner of the * Raster, the SampleModel specifying the data * layout. Some formats include this information about the layout of the * tile while others don't. The formats that do include this information * needed to create a SampleModel and a Point * should return true from the includesSampleModelInfo() and * includesLocationInfo() methods respectively. The formats * that do not include this information in the encoded stream should return * false. For decoding, the TileCodecParameterList providing the * decoding parameters will in this case be expected to contain a parameter * named "sampleModel" with a non-null SampleModel as its value. * This SampleModel will be used to create the decoded * Raster and is expected to be the same as the * SampleModel of the tiles to be encoded. * *

All Strings are treated in a case-retentive and * case-insensitive manner. * * @see TileDecoder * @see TileEncoder * @since 1.1 */ public interface TileCodecDescriptor extends RegistryElementDescriptor { /** * Returns true if the format encodes layout information generally * specified via the SampleModel in the encoded data stream. */ boolean includesSampleModelInfo(); /** * Returns true if the format encodes in the data stream the location of * the Raster with respect to its enclosing image. */ boolean includesLocationInfo(); /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ TileCodecParameterList getDefaultParameters(String modeName); /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList, adding a * "sampleModel" parameter with the specified value to the parameter * list. * *

This method should be used when includesSampleModelInfo() * returns false. If includesSampleModelInfo() returns true, the * supplied SampleModel is ignored. * *

If a parameter named "sampleModel" exists in the default * parameter list, the supplied SampleModel will override * the value associated with this default parameter. * * @param sm The SampleModel used to create the * default decoding parameter list. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ TileCodecParameterList getDefaultParameters(String modeName, SampleModel sm); /** * Returns a TileCodecParameterList valid for the * specified modeName and compatible with the supplied * TileCodecParameterList. * For example, given a TileCodecParameterList used to * encode a tile with the modeName being specified as "tileDecoder", this * method will return a TileCodecParameterList sufficient * to decode that same encoded tile. * * @param modeName The registry mode to return a valid parameter * list for. * @param otherParamList The parameter list for which a compatible * parameter list for the specified modeName is * to be returned. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ TileCodecParameterList getCompatibleParameters(String modeName, TileCodecParameterList otherParamList); } 2.2 Abstract class TileCodecDescriptorImpl package javax.media.jai.tilecodec; /** * An abstract class that implements the TileCodecDescriptor * interface and is suitable for subclassing. This class provides default * implementations for some of the methods from * TileCodecDescriptor. Subclasses should override these methods * if they do not wish to retain the default implementation. * * All Strings are treated in a case-retentive and * case-insensitive manner. * * @since 1.1 */ public abstract class TileCodecDescriptorImpl implements TileCodecDescriptor { /** * Creates a TileCodecDescriptorImpl with the given * format name and booleans to specify whether layout * information is included in the encoded stream. * * @param formatName The name of the format. This is also * the name under which this descriptor * will be registered under in the * OperationRegistry. * @param includesSampleModelInfo Whether the format encodes the tile's * SampleModel or equivalent * information into the encoded stream. * @param includesLocationInfo Whether the format encodes the tile's * upper left corner position or equivalent * information into the encoded stream. * @throws IllegalArgumentException if formatName is null. */ public TileCodecDescriptorImpl(String formatName, boolean includesSampleModelInfo, boolean includesLocationInfo) {} /** * Returns the name of the format. */ public String getName() {} /** * Returns the registry modes supported by this descriptor. The * default implementation of this method in this class returns a * String array containing the "tileDecoder" and * "tileEncoder" strings. If the subclass does not support any of * these modes, it should override this method to return the names of * those modes that it supports. * * @see javax.media.jai.RegistryMode */ public String[] getSupportedModes() {} /** * This method is implemented to return true if the specified * registryModeName is either "tileDecoder" or "tileEncoder". If * the subclass doesn't support any one of these modes, it should * override this method to return true only for the supported mode(s). * * @param registryModeName The name of the registry mode to check * support for. * @throws IllegalArgumentException if registryModeName is null. */ public boolean isModeSupported(String registryModeName) {} /** * Whether this descriptor supports properties. * * @return true, if the implementation of this descriptor supports * properties. false otherwise. Since tile codecs do not support * properties, so this default implementation returns false. * * @see PropertyGenerator */ public boolean arePropertiesSupported() {} /** * Returns an array of PropertyGenerators implementing * the property inheritance for this operation. Since neither * TileEncoder or TileDecoder supports * properties, the default implementation throws an * UnsupportedOperationException. Subclasses should * override this method if they wish to produce inherited properties. * * @throws IllegalArgumentException if modeName is null. * @throws UnsupportedOperationException if * arePropertiesSupported() returns false */ public PropertyGenerator[] getPropertyGenerators(String modeName) {} /** * Returns true if the format encodes layout information generally * specified via the SampleModel in the encoded data stream. */ public boolean includesSampleModelInfo() {} /** * Returns true if the format encodes in the data stream the location of * the Raster with respect to its enclosing image. */ public boolean includesLocationInfo() {} } 2.3 Class TileDecoderRegistryMode package javax.media.jai.registry; /** * A class which provides information about the "tileDecoder" registry * mode. * * @since 1.1 */ public class TileDecoderRegistryMode extends RegistryMode { public static final String MODE_NAME = "tileDecoder"; /** * Creates a TileDecoderRegistryMode for describing * the "tileDecoder" registry mode. */ public TileDecoderRegistryMode() {} } 2.4 Class TileEncoderRegistryMode package javax.media.jai.registry; /** * A class which provides information about the "tileEncoder" registry * mode. * * @since 1.1 */ public class TileEncoderRegistryMode extends RegistryMode { public static final String MODE_NAME = "tileEncoder"; /** * Creates a TileEncoderRegistryMode for describing * the "tileEncoder" registry mode. */ public TileEncoderRegistryMode() {} } 2.5 Class TileCodecParameterList package javax.media.jai.tilecodec; /** * A subclass of ParameterListImpl that is specific to * tile codecs. This class functions in either one or both of the two * registry modes supported by the TileCodecDescriptor * - "tileEncoder" and "tileDecoder". * *

This class is not intended to be subclassed for each individual * TileEncoder or TileDecoder. This is a generic * class which can be used as is for representing a parameter list for * any tile encoding/decoding format. The ParameterListDescriptor * provided as argument to the constructor should be the one returned from * the getParameterListDescriptor() method of the * TileCodecDescriptor for the given format name. * *

If the associated TileCodecDescriptor's * includesSampleModelInfo() method returns false, then for the * "tileDecoder" mode, this class will be expected to contain a parameter * named "sampleModel" with a non-null SampleModel as its value. * * @since 1.1 */ public class TileCodecParameterList extends ParameterListImpl { /** * Creates a TileCodecParameterList. The * validModes argument specifies the registry modes valid * for this TileCodecParameterList. This should contain * the "tileEncoder" registry mode or the "tileDecoder" registry * mode or both. The supplied descriptor object specifies the names * and number of the valid parameters, their Class types, * as well as the Range of valid values for each parameter. * * @param formatName The name of the format, parameters for which are * specified through this parameter list. * @param validModes An array of String objects specifying * which registry modes are valid for this parameter list. * @param descriptor The ParameterListDescriptor object that * describes all valid parameters for this format. This * must be the the same descriptor that is returned from * the getParameterListDescriptor() method of * the TileCodecDescriptor for the given * formatName. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if validModes is null. * @throws IllegalArgumentException if descriptor is null. */ public TileCodecParameterList(String formatName, String validModes[], ParameterListDescriptor descriptor) {} /** * Returns the name of the format which this parameter list describes. */ public String getFormatName() {} /** * Returns true if the parameters in this * TileCodecParameterList are valid for the specified * registry mode name, false otherwise. The valid modes for * this class are the "tileEncoder" registry mode, and the * "tileDecoder" registry mode. */ public boolean isValidForMode(String registryModeName) {} /** * Returns all the modes that this TileCodecParameterList * is valid for, as a String array. */ public String[] getValidModes() {} } 2.6 Interface TileDecoder package javax.media.jai.tilecodec; /** * An interface describing objects that transform an InputStream * into a Raster. * *

This interface is designed to allow decoding of formats that * include information about the format of the encoded tile as well as ones * that don't. In order to create a Raster, at the very least, * a Point specifying the top left corner of the * Raster, a SampleModel specifying the data layout * and a DataBuffer with the decoded pixel data are * needed. The DataBuffer can be created from the * information from the SampleModel and the decoded data. * Therefore the absolute minimum information that is required in order to * create a Raster on decoding (aside from the decoded data * itself) is a Point specifying the top left corner of the * Raster and a SampleModel specifying the data * layout. The formats that do include this information should return true * from the includesSampleModelInfo() and * includesLocationInfo() from the associated * TileCodecDescriptor if they include information needed to * create a SampleModel and information needed to * create the Point respectively. The formats that do not * include this information in the encoded stream should return false. The * TileCodecParameterList providing the decoding parameters * will in this case be expected to contain a parameter named "sampleModel" * with a non-null SampleModel as its value. This * SampleModel will be used to create the decoded * Raster. * *

The formats that return true from includesSampleModelInfo() * should use the decode() method to cause the decoding to take * place, the ones that return false should specify the Point * location to the decoding process by using the decode(Point) * method. Similarly the SampleModel must be specified as a * parameter with a non-null value on the TileCodecParameterList * passed to this TileDecoder if * includesSampleModelInfo() returns false. It is expected that * the SampleModel specified in the parameter list is the * SampleModel of the encoded tiles, in order to get a * decoded Raster that is equivalent to the one encoded. If the * SampleModel specified through the parameter list is different * from those of the encoded tiles, the result of decoding is undefined. * *

If includesSampleModelInfo() returns true, the * SampleModel (if present) on the * TileCodecParameterList is ignored. * * @see TileCodecDescriptor * @see TileEncoder * * @since 1.1 */ public interface TileDecoder { /** * Returns the name of the format. */ String getFormatName(); /** * Returns the current parameters as an instance of the * TileCodecParameterList interface. */ TileCodecParameterList getDecodeParameterList(); /** * Returns the InputStream containing the encoded data. */ InputStream getInputStream(); /** * Returns a Raster that contains the decoded contents * of the InputStream associated with this * TileDecoder. * *

This method can perform the decoding correctly only when * includesLocationInfo() returns true. * * @throws IOException if an I/O error occurs while reading from the * associated InputStream. * @throws IllegalArgumentException if the associated * TileCodecDescriptor's includesLocationInfo() returns false. */ Raster decode() throws IOException; /** * Returns a Raster that contains the decoded contents * of the InputStream associated with this * TileDecoder. * *

This method should be used when includesLocationInfo() * returns false. If includesLocationInfo() returns true, then * the supplied Point is ignored. * * @param location The Point specifying the upper * left corner of the Raster. * @throws IOException if an I/O error occurs while reading from the * associated InputStream. * @throws IllegalArgumentException if includesLocationInfo() returns false * and location is null. */ Raster decode(Point location) throws IOException; } 2.7 Abstract Class TileDecoderImpl package javax.media.jai.tilecodec; /** * A partial implementation of the TileDecoder interface * useful for subclassing. * * @since 1.1 */ public abstract class TileDecoderImpl implements TileDecoder { /** * The name of the format. */ protected String formatName; /** * The InputStream containing the encoded data to decode. */ protected InputStream inputStream; /** * The TileCodecParameterList object containing the * decoding parameters. */ protected TileCodecParameterList paramList; /** * Constructs a TileDecoderImpl. An * IllegalArgumentException will be thrown if * param's getParameterListDescriptor() * method does not return the same descriptor as that from * the associated TileCodecDescriptor's * getParameterListDescriptor method for the "tileDecoder" * registry mode. * *

If param is null, then the default parameter list for decoding * as defined by the associated TileCodecDescriptor's * getDefaultParameters() method will be used for decoding. * If this too is null, an IllegalArgumentException will * be thrown if the ParameterListDescriptor associated * with the associated TileCodecDescriptor for the * "tileDecoder" registry mode, reports that the number of parameters * for this format is non-zero. * * @param formatName The name of the format. * @param input The InputStream to decode data from. * @param param The object containing the tile decoding parameters. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if input is null. * @throws IllegalArgumentException if param's getFormatName() method does * not return the same formatName as the one specified to this method. * @throws IllegalArgumentException if the ParameterListDescriptor * associated with the param and the associated TileCodecDescriptor are * not equal. * @throws IllegalArgumentException if param does not have "tileDecoder" * as one of the valid modes that it supports. * @throws IllegalArgumentException if the associated TileCodecDescriptor's * includesSampleModelInfo() returns false and a non-null value for the * "sampleModel" parameter is not supplied in the supplied parameter list. */ public TileDecoderImpl(String formatName, InputStream input, TileCodecParameterList param) {} /** * Returns the format name. */ public String getFormatName() {} /** * Returns the current parameters as an instance of the * TileCodecParameterList interface. */ public TileCodecParameterList getDecodeParameterList() {} /** * Returns the InputStream associated with this * TileDecoder. */ public InputStream getInputStream() {} } 2.8 Interface TileEncoder package javax.media.jai.tilecodec; /** * An interface describing objects that transform a Raster * into an OutputStream. * * If the TileCodecDescriptor for this format returns true from * its includesSampleModelInfo() and * includesLocationInfo() methods, then the encoder must encode * this information in the encoded tiles. If these methods return false, then * this information (needed to create a Raster on decoding) must * be provided to the TileDecoder by setting the * SampleModel on the TileCodecParameterList supplied * to the TileDecoder and supplying the tile upper left corner * location to the TileDecoder via the TileDecoder's * decode(Point location) method. The SampleModel * value set on the TileCodecParameterList for the * TileDecoder should be the same as that of the * Raster to be encoded, in order to get a Raster * on decoding that is equivalent to the one being encoded. * * @see TileCodecDescriptor * @see TileDecoder */ public interface TileEncoder { /** * Returns the format name of the encoding scheme. */ String getFormatName(); /** * Returns the current parameters as an instance of the * TileCodecParameterList interface. */ TileCodecParameterList getEncodeParameterList(); /** * Returns the OutputStream to which the encoded data * will be written. */ public OutputStream getOutputStream(); /** * Encodes a Raster and writes the output * to the OutputStream associated with this * TileEncoder. * * @param ras the Raster to encode. * @throws IOException if an I/O error occurs while writing to the * OutputStream. * @throws IllegalArgumentException if ras is null. */ public void encode(Raster ras) throws IOException; } 2.9 Abstract Class TileEncoderImpl package javax.media.jai.tilecodec; /** * A partial implementation of the TileEncoder interface * useful for subclassing. */ public abstract class TileEncoderImpl implements TileEncoder { /** * The name of the format. */ protected String formatName; /** * The OutputStream to write the encoded data to. */ protected OutputStream outputStream; /** * The TileCodecParameterList object containing the * encoding parameters. */ protected TileCodecParameterList paramList; /** * Constructs an TileEncoderImpl. An * IllegalArgumentException will be thrown if * param's getParameterListDescriptor() method * does not return the same descriptor as that from the associated * TileCodecDescriptor's * getParameterListDescriptor method for the "tileEncoder" * registry mode. * *

If param is null, then the default parameter list for encoding * as defined by the associated TileCodecDescriptor's * getDefaultParameters() method will be used for encoding. * If this too is null, an IllegalArgumentException will * be thrown if the ParameterListDescriptor associated * with the associated TileCodecDescriptor for the * "tileEncoder" registry mode, reports that the number of parameters * for this format is non-zero. * * @param formatName The name of the format. * @param output The OutputStream to write encoded data to. * @param param The object containing the tile encoding parameters. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if output is null. * @throws IllegalArgumentException if param's getFormatName() method does * not return the same formatName as the one specified to this method. * @throws IllegalArgumentException if the ParameterListDescriptors * associated with the param and the associated TileCodecDescriptor are * not equal. * @throws IllegalArgumentException if param does not have "tileEncoder" * as one of the valid modes that it supports. */ public TileEncoderImpl(String formatName, OutputStream output, TileCodecParameterList param) {} /** * Returns the format name of the encoding scheme. */ public String getFormatName() {} /** * Returns the current parameters as an instance of the * TileCodecParameterList interface. */ public TileCodecParameterList getEncodeParameterList() {} /** * Returns the OutputStream to which the encoded data will * be written. */ public OutputStream getOutputStream() {} } 2.10 TileDecoderFactory package javax.media.jai.tilecodec; /** * A factory for creating TileDecoders. * *

This class stipulates that the capabilities of the * TileDecoder be specified by implementing the * getDecodingCapability() method. * * @see javax.media.jai.remote.NegotiableCapability */ public interface TileDecoderFactory { /** * Creates a TileDecoder capable of decoding the encoded * data from the given InputStream using the specified * TileCodecParameterList containing the decoding * parameters to be used. * *

This method can return null if the TileDecoder is * not capable of producing output for the given set of parameters. * For example, if a TileDecoder is only capable of dealing * with a jpeg quality factor of 0.5, and the associated * TileCodecParameterList specifies a quality factor of 0.75, * null should be returned. * *

It is recommended that the data in the supplied * InputStream not be used as a factor in determining * whether this InputStream can be successfully decoded, * unless the supplied InputStream is known to be rewindable * (i.e. its markSupported() method returns true or it has * additional functionality that allows backward seeking). It is required * that the InputStream contain the same data on * returning from this method as before this method was called. * In other words, the InputStream should only be used as a * discriminator if it can be rewound to its starting position * before returning from this method. Note that wrapping the * incoming InputStream in a PushbackInputStream * and then rewinding the PushbackInputStream before returning * does not rewind the wrapped InputStream. * *

If the supplied TileCodecParameterList is null, * a default TileCodecParameterList from the * TileCodecDescriptor will be used to create the decoder. * *

Exceptions thrown by the TileDecoder will be * caught by this method and will not be propagated. * * @param input The InputStream containing the encoded data * to decode. * @param param The parameters to be be used in the decoding process. * @throws IllegalArgumentException if input is null. */ TileDecoder createDecoder(InputStream input, TileCodecParameterList param); /** * Returns the capabilities of this TileDecoder as a * NegotiableCapability. * * @see javax.media.jai.remote.NegotiableCapability */ NegotiableCapability getDecodeCapability(); } 2.11 TileEncoderFactory package javax.media.jai.tilecodec; /** * A factory for creating TileEncoders. * *

This class stipulates that the capabilities of the * TileEncoder be specified by implementing the * getEncodingCapability() method. * * @see javax.media.jai.remote.NegotiableCapability */ public interface TileEncoderFactory { /** * Creates a TileEncoder capable of encoding a * Raster with the specified SampleModel * using the encoding parameters specified via the * TileCodecParameterList, to the given * OutputStream. * *

This method can return null if the TileEncoder is not * capable of producing output for the given set of parameters. * For example, if a TileEncoder is only capable of dealing * with a PixelInterleavedSampleModel, and the supplied * SampleModel is not an instance of * PixelInterleavedSampleModel, null should be * returned. The supplied SampleModel should be used to * decide whether it can be encoded by this class, and is not needed * to actually construct a TileEncoder. * *

If the supplied TileCodecParameterList is null, * a default TileCodecParameterList from the * TileCodecDescriptor will be used to create the encoder. * *

Exceptions thrown by the TileEncoder * will be caught by this method and will not be propagated. * * @param output The OutputStream to write the encoded * data to. * @param paramList The TileCodecParameterList containing * the encoding parameters. * @param sampleModel The SampleModel of the * Raster to be encoded. * * @throws IllegalArgumentException if output is null. * @throws IllegalArgumentException if sampleModel is null. */ TileEncoder createEncoder(OutputStream output, TileCodecParameterList paramList, SampleModel sampleModel); /** * Returns the capabilities of this TileEncoder as a * NegotiableCapability. * * @see javax.media.jai.remote.NegotiableCapability */ NegotiableCapability getEncodeCapability(); } 2.12 Class TileDecoderRegistry package javax.media.jai.registry; /** * Utility class to provide type-safe interaction with the * OperationRegistry for TileDecoderFactory objects. * * If the OperationRegistry specified as an argument to the * methods in this class is null, then JAI.getOperationRegistry() * will be used. */ public final class TileDecoderRegistry { /** * Registers the given TileDecoderFactory with the given * OperationRegistry under the given formatName and * productName. * * @param registry The OperationRegistry to register the * TileDecoderFactory with. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The formatName to register the * TileDecoderFactory under. * @param productName The productName to register the * TileDecoderFactory under. * @param tdf The TileDecoderFactory to register. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if tdf is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName */ public static void register(OperationRegistry registry, String formatName, String productName, TileDecoderFactory tdf) {} /** * Unregisters the given TileDecoderFactory previously * registered under the given formatName and productName in the given * OperationRegistry. * * @param registry The OperationRegistry to unregister the * TileDecoderFactory from. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The formatName to unregister the * TileDecoderFactory from. * @param productName The productName to unregister the * TileDecoderFactory from. * @param tdf The TileDecoderFactory to unregister. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if tdf is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName * @throws IllegalArgumentException if the tdf was not previously * registered against the given formatName and productName. */ public static void unregister(OperationRegistry registry, String formatName, String productName, TileDecoderFactory tdf) {} /** * Sets a preference between the given two TileDecoderFactory * objects in the given OperationRegistry under the given * formatName and productName. * * @param registry The OperationRegistry to set * preferences on. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The formatName of the two * TileDecoderFactorys. * @param productName The productName of the two * TileDecoderFactorys. * @param preferredTDF The preferred TileDecoderFactory. * @param otherTDF The other TileDecoderFactory. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if preferredTDF is null. * @throws IllegalArgumentException if otherTDF is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName * @throws IllegalArgumentException if either of the two tdf's was * not previously registered against the given formatName and productName. */ public static void setPreference(OperationRegistry registry, String formatName, String productName, TileDecoderFactory preferredTDF, TileDecoderFactory otherTDF) {} /** * Unsets a preference previously set amongst the given two * TileDecoderFactory objects in the given * OperationRegistry under the given formatName * and productName. * * @param registry The OperationRegistry to unset * preferences on. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The formatName of the two * TileDecoderFactorys. * @param productName The productName of the two * TileDecoderFactorys. * @param preferredTDF The preferred TileDecoderFactory. * @param otherTDF The other TileDecoderFactory. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if preferredTDF is null. * @throws IllegalArgumentException if otherTDF is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName * @throws IllegalArgumentException if either of the two tdf's was * not previously registered against the given formatName and productName. */ public static void unsetPreference(OperationRegistry registry, String formatName, String productName, TileDecoderFactory preferredTDF, TileDecoderFactory otherTDF) {} /** * Clears all preferences set for registered * TileDecoderFactorys under the given formatName and * productName in the given OperationRegistry. * * @param registry The OperationRegistry to clear * preferences from. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name to clear preferences under. * @param productName The productName to clear preferences under. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static void clearPreferences(OperationRegistry registry, String formatName, String productName) {} /** * Returns a List of the TileDecoderFactorys registered in * the given OperationRegistry under the given formatName * and productName, in an ordering that satisfies all of the pairwise * preferences that have been set. Cycles will be broken in an * arbitrary manner. * * @param registry The OperationRegistry to clear * preferences from. If this is * null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name to clear preferences under. * @param productName The productName to clear preferences under. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static List getOrderedList(OperationRegistry registry, String formatName, String productName) {} /** * Returns an Iterator over all * TileDecoderFactory objects registered under the * given format name over all products. The order of the * TileDecoderFactory objects in the iteration will * be according to the pairwise preferences among products and * TileDecoderFactory objects within a product. The * remove() method of the Iterator * may not be implemented. * * @param registry The OperationRegistry to use. If * this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name. * * @return an Iterator over TileDecoderFactory * objects. * * @throws IllegalArgumentException if formatName is null * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. * * @since JAI 1.1 */ public static Iterator getIterator(OperationRegistry registry, String formatName) {} /** * Returns the the most preferred TileDecoderFactory * object registered against the given format name. This * method will return the first TileDecoderFactory that * would be encountered by the Iterator returned by the * getIterator() method. * * @param registry The OperationRegistry to use. * If this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name as a String * * @return a registered TileDecoderFactory object * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against * the formatName */ public static TileDecoderFactory get(OperationRegistry registry, String formatName) {} /** * Creates a TileDecoder for the specified format that is * capable of handling the supplied arguments. * *

The preferences set amongst the TileDecoderFactory * objects registered with the OperationRegistry are used * to select the most prefered TileDecoderFactory whose * createDecoder() method returns a non-null value. * *

In order to do the decoding correctly, the caller should * retrieve the TileCodecDescriptor associated with the * returned TileDecoder from the * OperationRegistry and use it's * includesLocationInfo() method's return value to decide * which of the two versions of the decode() method on the * returned TileDecoder should be used. * * @param registry The OperationRegistry to use to create * the TileDecoder. If * this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format for which the TileDecoder is * to be created. * @param input The InputStream to read encoded data from. * @param paramList The object containing the tile decoding parameters. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if input is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static TileDecoder create(OperationRegistry registry, String formatName, InputStream input, TileCodecParameterList paramList) {} // Decode methods /** * Decodes the data from the specified InputStream * using the given formatName and TileCodecParameterList. * The TileDecoder which performs the decoding is the * one created from the most prefered TileDecoderFactory * whose create method returns a non-null result. * *

An IllegalArgumentException will be thrown if * the specified format's TileCodecDescriptor's * includesLocationInfo() method returns false, as no * location information is provided in this method. * *

If the specified TileCodecParameterList is null, the * default TileCodecParameterList retrieved by the specific * TileDecoder.getDefaultParameters() method for the * "tileDecoder" registry mode will be used. * *

For the specified format, if the associated * TileCodecDescriptor's includesSampleModelInfo() * method returns false, and either the specified * TileCodecParameterList is null or if it doesn't contain * a non-value for the "sampleModel" parameter, an * IllegalArgumentException will be thrown. * *

If there are no TileDecoder objects that can decode * the specified InputStream according to the decoding * parameters supplied, null will be returned from this method. * *

If multiple tiles are to be decoded from the same * InputStream in the same format using the same * TileCodecParameterList, it is advisable to create a * TileDecoder object and use the decode() method * on this decoder for each tile, thus creating and using only a single * TileDecoder object. The decode() * method on TileDecoderRegistry creates a new * TileDecoder object each time it is called. * * @param registry The OperationRegistry to use to create * the TileDecoder. If * this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name associated with the decoder. * @param input The InputStream containing the data * to be decoded. * @param param The TileCodecParameterList to be used. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if input is null. * @throws IllegalArgumentException if the specified format does not * encode the location information into the encoded data stream. * @throws IllegalArgumentException if the associated TileCodecDescriptor's * includesSampleModelInfo() returns false and a non-null value for the * "sampleModel" parameter is not supplied in the supplied parameter list. * @return The associated TileDecoder, or null. * @throws IOException if an I/O error occurs while reading from the * associated InputStream. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static Raster decode(OperationRegistry registry, String formatName, InputStream input, TileCodecParameterList param) throws IOException {} /** * Decodes the data from the specified InputStream * using the given formatName and TileCodecParameterList. * The TileDecoder which performs the decoding is the * one created from the most prefered TileDecoderFactory * whose create method returns a non-null result. If * there are no TileDecoder objects that can decode * the specified InputStream according to the decoding * parameters supplied, null will be returned from this method. * *

If the specified TileCodecParameterList is null, the * default TileCodecParameterList retrieved by the specific * TileDecoder.getDefaultParameters() method will be used. * *

If the specified location is null, and the associated * TileCodecDescriptor's includesLocationInfo() * method returns false, IllegalArgumentException will be thrown. * *

For the specified format, if the associated * TileCodecDescriptor's includesSampleModelInfo() * method returns false, and if the specified * TileCodecParameterList is null or if it doesn't contain * a non-value for the "sampleModel" parameter, an * IllegalArgumentException will be thrown. * *

If multiple tiles are to be decoded from the same * InputStream in the same format using the same * TileCodecParameterList, it is advisable to create a * TileDecoder object and use the decode() method * on this decoder for each tile, thus creating and using only a single * TileDecoder object. The decode() * method on TileDecoderRegistry creates a new * TileDecoder object each time it is called. * * @param registry The OperationRegistry to use to create * the TileDecoder. If * this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name associated with the decoder. * @param input The InputStream containing the data to * be decoded. * @param param The TileCodecParameterList to be used. * @param location The Point specifying the upper left * corner of the Raster. * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if input is null. * @throws IOException if an input/output error occurs during decoding. * @throws IllegalArgumentException if includesLocationInfo() returns false * and location is null. * @throws IllegalArgumentException if the associated TileCodecDescriptor's * includesSampleModelInfo() returns false and a non-null value for the * "sampleModel" parameter is not supplied in the supplied parameter list. * @return The associated TileDecoder, or null. * @throws IOException if an I/O error occurs while reading from the * associated InputStream. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static Raster decode(OperationRegistry registry, String formatName, InputStream input, TileCodecParameterList param, Point location) throws IOException {} } 2.13 Class TileEncoderRegistry package javax.media.jai.registry; /** * Utility class to provide type-safe interaction with the * OperationRegistry for TileEncoderFactory objects. * * If the OperationRegistry specified as an argument to the * methods in this class is null, then JAI.getOperationRegistry() * will be used. */ public final class TileEncoderRegistry { /** * Registers the given TileEncoderFactory with the given * OperationRegistry under the given formatName and * productName. * * @param registry The OperationRegistry to register the * TileEncoderFactory with. * @param formatName The formatName to register the * TileEncoderFactory under. * @param productName The productName to register the * TileEncoderFactory under. * @param tef The TileEncoderFactory to register. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if tef is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static void register(OperationRegistry registry, String formatName, String productName, TileEncoderFactory tef) {} /** * Unregisters the given TileEncoderFactory previously * registered under the given formatName and productName in the given * OperationRegistry. * * @param registry The OperationRegistry to unregister the * TileEncoderFactory from. * @param formatName The formatName to unregister the * TileEncoderFactory from. * @param productName The productName to unregister the * TileEncoderFactory from. * @param tef The TileEncoderFactory to unregister. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if tef is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. * @throws IllegalArgumentException if the tef was not previously * registered against the given formatName and productName. */ public static void unregister(OperationRegistry registry, String formatName, String productName, TileEncoderFactory tef) {} /** * Sets a preference between the given two TileEncoderFactory * objects in the given OperationRegistry under the given * formatName and productName. * * @param registry The OperationRegistry to set * preferences on. * @param formatName The formatName of the two * TileEncoderFactorys. * @param productName The productName of the two * TileEncoderFactorys. * @param preferredTEF The preferred TileEncoderFactory. * @param otherTEF The other TileEncoderFactory. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if preferredTEF is null. * @throws IllegalArgumentException if otherTEF is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. * @throws IllegalArgumentException if either of the two tef's * was not previously registered against formatName and productName. */ public static void setPreference(OperationRegistry registry, String formatName, String productName, TileEncoderFactory preferredTEF, TileEncoderFactory otherTEF) {} /** * Unsets a preference previously set amongst the given two * TileEncoderFactory objects in the given * OperationRegistry under the given formatName and productName. * * @param registry The OperationRegistry to unset * preferences on. * @param formanName The formatName of the two * TileEncoderFactorys. * @param productName The productName of the two * TileEncoderFactorys. * @param preferredTEF The preferred TileEncoderFactory. * @param otherTEF The other TileEncoderFactory. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if preferredTEF is null. * @throws IllegalArgumentException if otherTEF is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. * @throws IllegalArgumentException if either of the two tef's * was not previously registered against formatName and productName. */ public static void unsetPreference(OperationRegistry registry, String formatName, String productName, TileEncoderFactory preferredTEF, TileEncoderFactory otherTEF) {} /** * Clears all preferences set for registered TileEncoderFactorys * under the given formatName and productName in the given * OperationRegistry. * * @param registry The OperationRegistry to clear * preferences from. * @param formatName The format name to clear preferences under. * @param productName The productName to clear preferences under. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static void clearPreferences(OperationRegistry registry, String formatName, String productName) {} /** * Returns a List of the TileEncoderFactorys registered in * the given OperationRegistry under the given formatName * and productName, in an ordering that satisfies all of the pairwise * preferences that have been set. Cycles will be broken in an * arbitrary manner. * * @param registry The OperationRegistry to clear * preferences from. * @param formatName The format name to clear preferences under. * @param productName The productName to clear preferences under. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if productName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static List getOrderedList(OperationRegistry registry, String formatName, String productName) {} /** * Returns an Iterator over all * TileEncoderFactory objects registered under the * given format name over all products. The order of the * TileEncoderFactory objects in the iteration will * be according to the pairwise preferences among products and * TileEncoderFactory objects within a product. The * remove() method of the Iterator * may not be implemented. * * @param registry The OperationRegistry to use. * @param formatName The format name. * * @return an Iterator over TileEncoderFactory * objects. * * @throws IllegalArgumentException if formatName is null * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against * the formatName. * * @since JAI 1.1 */ public static Iterator getIterator(OperationRegistry registry, String formatName) {} /** * Returns the the most preferred TileEncoderFactory * object registered against the given format name. This * method will return the first TileEncoderFactory that * would be encountered by the Iterator returned by the * getIterator() method. * * @param registry The OperationRegistry to use. * If this is null, then * JAI.getDefaultInstance().getOperationRegistry() * will be used. * @param formatName The format name as a String * * @return a registered TileEncoderFactory object * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the formatName */ public static TileEncoderFactory get(OperationRegistry registry, String formatName) {} /** * Creates a TileEncoder for the specified format that is * capable of handling the supplied arguments. * *

The preferences set amongst the TileEncoderFactory * objects registered with the OperationRegistry are used * to select the most prefered TileEncoderFactory whose * createEncoder() method returns a non-null value. * * @param registry The OperationRegistry to use to create * the TileEncoder. * @param formatName The format for which the TileEncoder is * to be created. * @param output The OutputStream to write encoded data to. * @param paramList The object containing the tile encoding parameters. * @param sampleModel The SampleModel of the * Raster to be encoded. * * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if output is null. * @throws IllegalArgumentException if sampleModel is null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static TileEncoder create(OperationRegistry registry, String formatName, OutputStream output, TileCodecParameterList paramList, SampleModel sampleModel) {} /** * Encodes the given Raster using the given formatName and * TileCodecParameterList and writes the encoded data to the * specified OutputStream. * The TileEncoder which performs the encoding is the * one created from the most prefered TileEncoderFactory * whose create method returns a non-null result. If * there are no TileEncoder objects that can encode * the specified Raster according to the encoding * parameters supplied, nothing will be written to the specified * OutputStream. * *

If the specified TileCodecParameterList is null, the * default TileCodecParameterList retrieved by the specific * TileEncoder.getDefaultParameters() method for the * "tileEncoder" registry mode will be used. * *

If multiple tiles are to be encoded to the same * OutputStream in the same format using the same * TileCodecParameterList, it is advisable to create a * TileEncoder object and use the encode() method * on this encoder to encode each tile, thus creating and using only a * single TileEncoder object. The encode() * method on TileEncoderRegistry creates a new * TileEncoder object each time it is called. * * @param registry The OperationRegistry to use to create * the TileEncoder. * @param formatName The name of the format to encode the data in. * @param raster The Raster to be encoded. * @param output The OutputStream to write the encoded * data to. * @param param The TileCodecParameterList to be used. * @throws IllegalArgumentException if formatName is null. * @throws IllegalArgumentException if raster is null. * @throws IllegalArgumentException if output is null. * @throws IOException if an input/output error occurs during the encoding. * @return The associated TileEncoder, or null. * @throws IllegalArgumentException if there is no * TileCodecDescriptor registered against the * given formatName. */ public static void encode(OperationRegistry registry, String formatName, Raster raster, OutputStream output, TileCodecParameterList param) throws IOException {} } 3. Format specific TileCodecDescriptors 3.1 GZIPTileCodecDescriptor package javax.media.jai.tilecodec; /** *

This class is the descriptor for the "GZIP" tile codec. This codec * scheme uses "gzip" as the method of compressing tile data. This is a * lossless tile codec. The format name for the gzip tile codec is "gzip". * The encoded stream contains the SampleModel and the tile's * upper left corner position, thus the includesSampleModelInfo() * and includesLocationInfo() methods in this descriptor return * true. * *

The "gzip" codec scheme does not support any parameters. * *

* * * * * * *
Resource List
Name Value
Vendor com.sun.media.jai
Description A descriptor to describe the lossless "gzip" * codec scheme.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/tilecodec/GZIPTileCodecDescriptor.html
Version 1.2

* *

* * * *
Parameter List
Name Class TypeDefault Value

* * @since 1.1 */ public class GZIPTileCodecDescriptor extends TileCodecDescriptorImpl { /** * Creates a GZIPTileCodecDescriptor */ public GZIPTileCodecDescriptor() {} /** * Returns a TileCodecParameterList valid for the * specified modeName and compatible with the supplied * TileCodecParameterList. For example, given a * TileCodecParameterList used to encode a tile with * the modeName being specified as "tileDecoder", this method will * return a TileCodecParameterList * sufficient to decode that same tile. For the gzip tile codec, * no parameters are used. So null will be returned for any valid * modeName specified. * * @param modeName The registry mode to return a valid parameter * list for. * @param otherParamList The parameter list for which a compatible * parameter list for the complementary modeName is * to be found. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getCompatibleParameters( String modeName, TileCodecParameterList otherParamList) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList. For the * gzip tile codec, no parameters are used. So null will be * returned for any valid modeName specified. * * @param modeName The registry mode to return a valid parameter * list for. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList, adding a * "sampleModel" parameter with the specified value to the parameter * list. For the gzip tile codec, no parameters are used. So null will be * returned for any valid modeName specified. * *

This method should be used when includesSampleModelInfo() * returns false. If includesSampleModelInfo() returns true, the * supplied SampleModel is ignored. * *

If a parameter named "sampleModel" exists in the default * parameter list, the supplied SampleModel will override the value * associated with this default parameter. * * @param modeName The registry mode to return a valid parameter list for. * @param sm The SampleModel used to create the * default decoding parameter list. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName, SampleModel sm) {} /** * Returns the ParameterListDescriptor that describes * the associated parameters (NOT sources). This method returns * null if there are no parameters for the specified modeName. * If the specified modeName supports parameters but the * implementing class does not have parameters, then this method * returns a non-null ParameterListDescriptor whose * getNumParameters() returns 0. * * @param modeName The mode to get the ParameterListDescriptor for. * * @throws IllegalArgumentException if modeName is null. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public ParameterListDescriptor getParameterListDescriptor(String modeName) {} } 3.2 JPEGTileCodecDescriptor package javax.media.jai.tilecodec; /** * This class is the descriptor for the "JPEG" tile codec. "jpeg" is a * lossy tile codec, which involves compressing the tile data using the * jpeg standard. The format name for the jpeg tile codec is "jpeg". * The encoded stream contains the SampleModel and the * tile's upper left corner position, thus the * includesSampleModelInfo() and * includesLocationInfo() methods in this descriptor return * true. * *

This JPEG tile codec works well only on byte type images with 1, * 3 or 4 bands. * *

While both the "tileDecoder" and "tileEncoder" registry modes for * the "jpeg" tile codec scheme have the same set of parameters, the * parameters for the "tileDecoder" mode are read-only and will be * ignored if values are set for them in the * TileCodecParameterList passed to the TileDecoder. * The reason for this is that the parameter values needed to control * the decoding process are included in the encoded stream, therefore * parameter values specified externally are ignored. Once the decoding * is completed, the parameter values in the * TileCodecParameterList are updated to reflect the values * specified in the encoded stream. * *

* * * * * * * * * * * * * * * * * * * *
Resource List
Name Value
Vendor com.sun.media.jai
Description A descriptor to describe the lossy "jpeg" codec * scheme.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/tilecodec/JPEGTileCodecDescriptor.html
Version 1.2
quality *

A factor that relates to the desired tradeoff * between image quality and the image data * compression ratio. The range of this parameter * is from 0.0 to 1.0. A setting of 1.0 produces the * highest quality image at a lower compression * rate. A setting of 0.0 produces the highest * compression ratio, with a sacrifice to image * quality. The default value is 0.75.

In JPEG, * compression, there are two ways to control the * quantization quality: one is define quantization * table for each image component; the other is * define the quality. The later overrides the * former. If neither the quality nor quantization * tables are set, the default setting is used. *

When the quality is set, a group of * quantization tables are generated by rescaling * the default quantization tables. For more * infomation, please refer to the links below. *

qualitySet A boolean used to indicate that the * parameter quality is set or * not.
horizontalSubsampling The subsampling rate in the * horizontal direction applied to each image * component to reduce their resolution * prior to encoding.
verticalSubsampling The subsampling rate in the * vertical direction applied to each image * component to reduce their resolution * prior to encoding.
quantizationTableMapping In JPEG compression, several * image components may share one quantization * table. This is the mapping between the * image component and the quantization * tables.
quantizationTable0 A quantization table for JPEG codec * is an array of 64 (8x8) expressed in zig-zag * order (see the JPEG spec section K.1). Since * this descriptor defines a JPEG scheme where the * tile has at most 4 components, so at most 4 * quantization tables will * be used. This parameter is the first * quantization table.
quantizationTable1 The second quantization table.
quantizationTable2 The third quantization table.
quantizationTable3 The fourth quantization table.
restartInterval JPEG images use restart markers to define * multiple strips or tiles. The restart markers * are inserted periodically into the image data * to delineate image segments known as restart * intervals. To limit the effect of bitstream * errors to a single restart interval, JAI * provides methods to set the restart interval * in JPEG Minimum Coded Units (MCUs). * The default is zero (no restart interval * markers).
writeImageInfo A boolean instructs the encoder to * write the image data to the output * stream.
writeTableInfo A boolean instructs the encoder to * write the table data to the output * stream.
writeJFIFHeader The JPEG File Interchange Format (JFIF) * is a minimal file format that enables JPEG * bitstreams to be exchanged between a wide * variety of platforms and applications. * The parameter instructs the encoder to write * the output stream in the JFIF format.

* *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Parameter List
Name Class TypeDefault Value
quality java.lang.Float0.75
qualitySet java.lang.Booleantrue
horizontalSubsampling integer array{1,1,1}
verticalSubsampling integer array{1,1,1}
quantizationTableMapping integer array{0,1,1}
quantizationTable0 integer arrayThe default Luminance table as defined in * section K.1 of the JPEG specification.
quantizationTable1 integer arrayThe default Chrominance table as defined in * section K.1 of the JPEG specification.
quantizationTable2 integer arrayThe default Chrominance table as defined in * section K.1 of the JPEG specification.
quantizationTable3 integer arrayThe default Chrominance table as defined in * section K.1 of the JPEG specification.
restartInterval java.lang.Integer0
writeImageInfo java.lang.Booleantrue
writeTableInfo java.lang.Booleantrue
writeJFIFHeader java.lang.Booleanfalse

* * @see com.sun.image.codec.jpeg.JPEGQTable * @see com.sun.image.codec.jpeg.JPEGDecodeParam * @see com.sun.image.codec.jpeg.JPEGEncodeParam * * @since 1.1 */ public class JPEGTileCodecDescriptor extends TileCodecDescriptorImpl { /** * Creates a JPEGTileCodecDescriptor */ public JPEGTileCodecDescriptor() {} /** * Returns a TileCodecParameterList valid for the * specified modeName and compatible with the supplied * TileCodecParameterList. For example, given a * TileCodecParameterList used to encode a tile with * the modeName being specified as "tileDecoder", this method will return * a TileCodecParameterList sufficient to decode that * same tile. * *

If the supplied modeName is one of the valid mode names as * ascertained from the getSupportedNames() method, * this method returns a TileCodecParameterList that * contains values that are compatible for the supplied mode name. * * @param modeName The registry mode to return a valid parameter * list for. * @param otherParamList The parameter list for which a compatible * parameter list for the complementary modeName is * to be found. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getCompatibleParameters( String modeName, TileCodecParameterList otherParamList) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList. If the supplied * modeName is one of the valid mode names as ascertained from the * getSupportedNames() method, this method returns the * default parameters for that mode. * * @param modeName The mode to return the default parameters for. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList, adding a * "sampleModel" parameter with the specified value to the parameter * list. If the supplied modeName is one of the valid mode names as * ascertained from the getSupportedNames() method, this * method returns the default parameters for that mode. * *

This method should be used when includesSampleModelInfo() * returns false. If includesSampleModelInfo() returns true, the * supplied SampleModel is ignored. * *

For the JPEG codec, includesSampleModelInfo() returns true, so * the supplied SampleModel is ignored. * * @param modeName The mode to return the default parameters for. * @param sm The SampleModel used to create the * default decoding parameter list. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName, SampleModel sm) {} /** * Returns the ParameterListDescriptor that describes * the associated parameters (NOT sources). If the supplied modeName * is one of the valid mode names as ascertained from the * getSupportedNames() method, this method returns a * non-null ParameterListDescriptor with the appropriate * parameters. * * @param modeName The mode to return the ParameterListDescriptor for. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public ParameterListDescriptor getParameterListDescriptor(String modeName) {} } 3.3 RawTileCodecDescriptor package javax.media.jai.tilecodec ; /** * This class is the descriptor for the "Raw" tile codec. The "Raw" tile * codec scheme involves simply writing out the raw pixel data to the * encoded stream. The format name for the raw tile codec is "raw". * Since the encoded stream contains the Raster, it * automatically contains the SampleModel and the tile's * upper left corner position. Therefore the * includesSampleModelInfo() and * includesLocationInfo() methods in this descriptor return * true. * *

The "Raw" codec scheme does not support any parameters. * *

* * * * * * *
Resource List
Name Value
Vendor com.sun.media.jai
Description A descriptor to describe the lossless * "raw" codec scheme.
DocURL http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/tilecodec/RawTileCodecDescriptor.html
Version 1.2

* *

* * * *
Parameter List
Name Class TypeDefault Value

* * @since 1.1 */ public class RawTileCodecDescriptor extends TileCodecDescriptorImpl { /** * Creates a RawTileCodecDescriptor. */ public RawTileCodecDescriptor( ) {} /** * Returns a TileCodecParameterList valid for the * specified modeName and compatible with the supplied * TileCodecParameterList. For example, given a * TileCodecParameterList used to encode a tile with * the modeName being specified as "tileDecoder", this method will return * a TileCodecParameterList sufficient to decode that * same tile. For the raw tile codec, no parameters are used. So null * will be returned for any valid modeName specified. * * @param modeName The registry mode to return a valid parameter * list for. * @param otherParamList The parameter list for which a compatible * parameter list for the complementary modeName is * to be found. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getCompatibleParameters( String modeName, TileCodecParameterList otherParamList) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList. For the * raw tile codec, no parameters are used. So null will be * returned for any valid modeName specified. * * @param modeName The registry mode to return a valid parameter * list for. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName) {} /** * Returns the default parameters for the specified modeName as an * instance of the TileCodecParameterList, adding a * "sampleModel" parameter with the specified value to the parameter * list. For the raw tile codec, no parameters is used. So null will be * returned for any valid modeName specified. * *

This method should be used when includesSampleModelInfo() * returns false. If includesSampleModelInfo() returns true, the * supplied SampleModel is ignored. * *

If a parameter named "sampleModel" exists in the default * parameter list, the supplied SampleModel will override the value * associated with this default parameter. * * @param modeName The registry mode to return a valid parameter list for. * @param sm The SampleModel used to create the * default decoding parameter list. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public TileCodecParameterList getDefaultParameters(String modeName, SampleModel sm) {} /** * Returns the ParameterListDescriptor that describes * the associated parameters (NOT sources). This method returns * null if there are no parameters for the specified modeName. * If the specified modeName supports parameters but the * implementing class does not have parameters, then this method * returns a non-null ParameterListDescriptor whose * getNumParameters() returns 0. * * @param modeName The mode to return a ParameterListDescriptor for. * * @throws IllegalArgumentException if modeName is null. * * @throws IllegalArgumentException if modeName is null. * @throws IllegalArgumentException if modeName is not * one of the modes valid for this descriptor, i.e those returned * from the getSupportedNames() method. */ public ParameterListDescriptor getParameterListDescriptor(String modeName) {} }