001: /*
002: * $RCSfile: GZIPTileCodecDescriptor.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:57:54 $
010: * $State: Exp $
011: */package javax.media.jai.tilecodec;
012:
013: import java.awt.image.SampleModel;
014: import javax.media.jai.ParameterListDescriptor;
015: import javax.media.jai.ParameterListDescriptorImpl;
016: import javax.media.jai.PropertyGenerator;
017:
018: /**
019: * <p>This class is the descriptor for the "GZIP" tile codec. This codec
020: * scheme uses "gzip" as the method of compressing tile data. This is a
021: * lossless tile codec. The format name for the gzip tile codec is "gzip".
022: * The encoded stream contains the <code>SampleModel</code> and the tile's
023: * upper left corner position, thus the <code>includesSampleModelInfo()</code>
024: * and <code>includesLocationInfo()</code> methods in this descriptor return
025: * true.
026: *
027: * <p> The "gzip" codec scheme does not support any parameters.
028: *
029: * <p><table border=1>
030: * <caption>Resource List</caption>
031: * <tr><th>Name</th> <th>Value</th></tr>
032: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
033: * <tr><td>Description</td> <td>A descriptor to describe the lossless "gzip"
034: * codec scheme. </td></tr>
035: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/tilecodec/GZIPTileCodecDescriptor.html</td></tr>
036: * <tr><td>Version</td> <td>1.2</td></tr>
037: * </table></p>
038: *
039: * <p><table border=1>
040: * <caption>Parameter List</caption>
041: * <tr><th>Name</th> <th>Class Type</th>
042: * <th>Default Value</th></tr>
043: * </table></p>
044: *
045: * @since JAI 1.1
046: */
047: public class GZIPTileCodecDescriptor extends TileCodecDescriptorImpl {
048:
049: private static ParameterListDescriptorImpl pld = new ParameterListDescriptorImpl();
050:
051: /**
052: * Creates a <code>GZIPTileCodecDescriptor</code>
053: */
054: public GZIPTileCodecDescriptor() {
055: super ("gzip", true, true);
056: }
057:
058: /**
059: * Returns a <code>TileCodecParameterList</code> valid for the
060: * specified modeName and compatible with the supplied
061: * <code>TileCodecParameterList</code>. For example, given a
062: * <code>TileCodecParameterList</code> used to encode a tile with
063: * the modeName being specified as "tileDecoder", this method will
064: * return a <code>TileCodecParameterList</code>
065: * sufficient to decode that same tile. For the gzip tile codec,
066: * no parameters are used. So null will be returned for any valid
067: * modeName specified.
068: *
069: * @param modeName The registry mode to return a valid parameter
070: * list for.
071: * @param otherParamList The parameter list for which a compatible
072: * parameter list for the complementary modeName is
073: * to be found.
074: *
075: * @throws IllegalArgumentException if <code>modeName</code> is null.
076: * @throws IllegalArgumentException if <code>modeName</code> is not
077: * one of the modes valid for this descriptor, i.e those returned
078: * from the getSupportedNames() method.
079: */
080: public TileCodecParameterList getCompatibleParameters(
081: String modeName, TileCodecParameterList otherParamList) {
082: if (modeName == null)
083: throw new IllegalArgumentException(JaiI18N
084: .getString("TileCodecDescriptorImpl1"));
085:
086: String validNames[] = getSupportedModes();
087: boolean valid = false;
088:
089: for (int i = 0; i < validNames.length; i++) {
090: if (modeName.equalsIgnoreCase(validNames[i])) {
091: valid = true;
092: break;
093: }
094: }
095:
096: if (valid == false) {
097: throw new IllegalArgumentException(JaiI18N
098: .getString("TileCodec1"));
099: }
100:
101: return null;
102: }
103:
104: /**
105: * Returns the default parameters for the specified modeName as an
106: * instance of the <code>TileCodecParameterList</code>. For the
107: * gzip tile codec, no parameters are used. So null will be
108: * returned for any valid modeName specified.
109: *
110: * @param modeName The registry mode to return a valid parameter
111: * list for.
112: *
113: * @throws IllegalArgumentException if <code>modeName</code> is null.
114: * @throws IllegalArgumentException if <code>modeName</code> is not
115: * one of the modes valid for this descriptor, i.e those returned
116: * from the getSupportedNames() method.
117: */
118: public TileCodecParameterList getDefaultParameters(String modeName) {
119: if (modeName == null)
120: throw new IllegalArgumentException(JaiI18N
121: .getString("TileCodecDescriptorImpl1"));
122:
123: String validNames[] = getSupportedModes();
124: boolean valid = false;
125:
126: for (int i = 0; i < validNames.length; i++) {
127: if (modeName.equalsIgnoreCase(validNames[i])) {
128: valid = true;
129: break;
130: }
131: }
132:
133: if (valid == false) {
134: throw new IllegalArgumentException(JaiI18N
135: .getString("TileCodec1"));
136: }
137:
138: return null;
139: }
140:
141: /**
142: * Returns the default parameters for the specified modeName as an
143: * instance of the <code>TileCodecParameterList</code>, adding a
144: * "sampleModel" parameter with the specified value to the parameter
145: * list. For the gzip tile codec, no parameters are used. So null will be
146: * returned for any valid modeName specified.
147: *
148: * <p> This method should be used when includesSampleModelInfo()
149: * returns false. If includesSampleModelInfo() returns true, the
150: * supplied <code>SampleModel</code> is ignored.
151: *
152: * <p> If a parameter named "sampleModel" exists in the default
153: * parameter list, the supplied SampleModel will override the value
154: * associated with this default parameter.
155: *
156: * @param modeName The registry mode to return a valid parameter list for.
157: * @param sm The <code>SampleModel</code> used to create the
158: * default decoding parameter list.
159: *
160: * @throws IllegalArgumentException if <code>modeName</code> is null.
161: * @throws IllegalArgumentException if <code>modeName</code> is not
162: * one of the modes valid for this descriptor, i.e those returned
163: * from the getSupportedNames() method.
164: */
165: public TileCodecParameterList getDefaultParameters(String modeName,
166: SampleModel sm) {
167: if (modeName == null)
168: throw new IllegalArgumentException(JaiI18N
169: .getString("TileCodecDescriptorImpl1"));
170:
171: String validNames[] = getSupportedModes();
172: boolean valid = false;
173:
174: for (int i = 0; i < validNames.length; i++) {
175: if (modeName.equalsIgnoreCase(validNames[i])) {
176: valid = true;
177: break;
178: }
179: }
180:
181: if (valid == false) {
182: throw new IllegalArgumentException(JaiI18N
183: .getString("TileCodec1"));
184: }
185:
186: return null;
187: }
188:
189: /**
190: * Returns the <code>ParameterListDescriptor</code> that describes
191: * the associated parameters (NOT sources). This method returns
192: * null if there are no parameters for the specified modeName.
193: * If the specified modeName supports parameters but the
194: * implementing class does not have parameters, then this method
195: * returns a non-null <code>ParameterListDescriptor</code> whose
196: * <code>getNumParameters()</code> returns 0.
197: *
198: * @param modeName The mode to get the ParameterListDescriptor for.
199: *
200: * @throws IllegalArgumentException if <code>modeName</code> is null.
201: *
202: * @throws IllegalArgumentException if <code>modeName</code> is null.
203: * @throws IllegalArgumentException if <code>modeName</code> is not
204: * one of the modes valid for this descriptor, i.e those returned
205: * from the getSupportedNames() method.
206: */
207: public ParameterListDescriptor getParameterListDescriptor(
208: String modeName) {
209:
210: if (modeName == null)
211: throw new IllegalArgumentException(JaiI18N
212: .getString("TileCodecDescriptorImpl1"));
213:
214: String validNames[] = getSupportedModes();
215: boolean valid = false;
216:
217: for (int i = 0; i < validNames.length; i++) {
218: if (modeName.equalsIgnoreCase(validNames[i])) {
219: valid = true;
220: break;
221: }
222: }
223:
224: if (valid == false) {
225: throw new IllegalArgumentException(JaiI18N
226: .getString("TileCodec1"));
227: }
228:
229: return pld;
230: }
231: }
|