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