01: /*
02: * $RCSfile: GZIPTileEncoderFactory.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:57 $
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 java.util.zip.GZIPOutputStream;
17: import javax.media.jai.ParameterListDescriptorImpl;
18: import javax.media.jai.remote.NegotiableCapability;
19: import javax.media.jai.tilecodec.TileCodecParameterList;
20: import javax.media.jai.tilecodec.TileEncoder;
21: import javax.media.jai.tilecodec.TileEncoderFactory;
22:
23: /**
24: * A factory for creating <code>GZIPTileEncoder</code>s.
25: *
26: * <p> This class stipulates that the capabilities of the
27: * <code>TileEncoder</code> be specified by implementing the
28: * <code>getEncodingCapability()</code> method.
29: *
30: * @see javax.media.jai.remote.NegotiableCapability
31: */
32: public class GZIPTileEncoderFactory implements TileEncoderFactory {
33:
34: /**
35: * Creates a <code>TileEncoder</code> capable of encoding a
36: * <code>Raster</code> with the specified <code>SampleModel</code>
37: * using the specified <code>TileCodecParameterList</code>
38: * containing the encoding parameters to the given <code>OutputStream</code>.
39: *
40: * <p> This method can return null if the <code>TileEncoder</code> is not
41: * capable of producing output for the given set of parameters.
42: * For example, if a <code>TileEncoder</code> is only capable of dealing
43: * with a <code>PixelInterleavedSampleModel</code>, and the supplied
44: * <code>SampleModel</code> is not an instance of
45: * <code>PixelInterleavedSampleModel</code>, null should be
46: * returned. The supplied <code>SampleModel</code> should be used to
47: * decide whether it can be encoded by this class, and is not needed
48: * to actually construct a <code>TileEncoder</code>.
49: *
50: * <p> If the supplied <code>TileCodecParameterList</code> is null,
51: * a default <code>TileCodecParameterList</code> from the
52: * <code>TileCodecDescriptor</code> will be used to create the encoder.
53: *
54: * <p>Exceptions thrown by the <code>TileEncoder</code>
55: * will be caught by this method and will not be propagated.
56: *
57: * @param output The <code>OutputStream</code> to write the encoded
58: * data to.
59: * @param paramList The <code>TileCodecParameterList</code> containing
60: * the encoding parameters.
61: * @param sampleModel The <code>SampleModel</code> of the encoded
62: * <code>Raster</code>s.
63: * @throws IllegalArgumentException if output is null.
64: */
65: public TileEncoder createEncoder(OutputStream output,
66: TileCodecParameterList paramList, SampleModel sampleModel) {
67: if (output == null)
68: throw new IllegalArgumentException(JaiI18N
69: .getString("TileEncoder0"));
70:
71: return new GZIPTileEncoder(output, paramList);
72: }
73:
74: /**
75: * Returns the capabilities of this <code>TileEncoder</code> as a
76: * <code>NegotiableCapability</code>.
77: */
78: public NegotiableCapability getEncodeCapability() {
79:
80: Vector generators = new Vector();
81: generators.add(GZIPTileEncoderFactory.class);
82:
83: return new NegotiableCapability("tileCodec", "gzip",
84: generators, new ParameterListDescriptorImpl(null, null,
85: null, null, null), false);
86: }
87: }
|