01: /*
02: * $RCSfile: RawTileEncoderFactory.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:56:58 $
10: * $State: Exp $
11: */package com.sun.media.jai.tilecodec;
12:
13: import java.awt.image.SampleModel;
14: import java.io.OutputStream;
15: import java.util.Vector;
16: import javax.media.jai.ParameterListDescriptorImpl;
17: import javax.media.jai.remote.NegotiableCapability;
18: import javax.media.jai.tilecodec.TileCodecParameterList;
19: import javax.media.jai.tilecodec.TileEncoder;
20: import javax.media.jai.tilecodec.TileEncoderFactory;
21:
22: /**
23: * A factory for creating <code>RawTileEncoder</code>s.
24: *
25: * <p> This class stipulates that the capabilities of the
26: * <code>TileEncoder</code> be specified by implementing the
27: * <code>getEncodingCapability()</code> method.
28: *
29: * @see javax.media.jai.remote.NegotiableCapability
30: */
31: public class RawTileEncoderFactory implements TileEncoderFactory {
32:
33: /**
34: * Creates a <code>TileEncoder</code> capable of encoding a
35: * <code>Raster</code> with the specified <code>SampleModel</code>
36: * using the specified <code>TileCodecParameterList</code>
37: * containing the encoding parameters to the given <code>OutputStream</code>.
38: *
39: * <p> This method can return null if the <code>TileEncoder</code> is not
40: * capable of producing output for the given set of parameters.
41: * For example, if a <code>TileEncoder</code> is only capable of dealing
42: * with a <code>PixelInterleavedSampleModel</code>, and the supplied
43: * <code>SampleModel</code> is not an instance of
44: * <code>PixelInterleavedSampleModel</code>, null should be
45: * returned. The supplied <code>SampleModel</code> should be used to
46: * decide whether it can be encoded by this class, and is not needed
47: * to actually construct a <code>TileEncoder</code>.
48: *
49: * <p> If the supplied <code>TileCodecParameterList</code> is null,
50: * a default <code>TileCodecParameterList</code> from the
51: * <code>TileCodecDescriptor</code> will be used to create the encoder.
52: *
53: * <p>Exceptions thrown by the <code>TileEncoder</code>
54: * will be caught by this method and will not be propagated.
55: *
56: * @param output The <code>OutputStream</code> to write the encoded
57: * data to.
58: * @param paramList The <code>TileCodecParameterList</code> containing
59: * the encoding parameters.
60: * @param sampleModel The <code>SampleModel</code> of the encoded
61: * <code>Raster</code>s.
62: * @throws IllegalArgumentException if output is null.
63: */
64: public TileEncoder createEncoder(OutputStream output,
65: TileCodecParameterList paramList, SampleModel sampleModel) {
66: if (output == null)
67: throw new IllegalArgumentException(JaiI18N
68: .getString("TileEncoder0"));
69: return new RawTileEncoder(output, paramList);
70: }
71:
72: /**
73: * Returns the capabilities of this <code>TileEncoder</code> as a
74: * <code>NegotiableCapability</code>.
75: */
76: public NegotiableCapability getEncodeCapability() {
77:
78: Vector generators = new Vector();
79: generators.add(RawTileEncoderFactory.class);
80:
81: return new NegotiableCapability("tileCodec", "raw", generators,
82: new ParameterListDescriptorImpl(null, null, null, null,
83: null), false);
84: }
85: }
|