001: /*
002: * $RCSfile: URLDescriptor.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:46 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import com.sun.media.jai.codec.ImageDecodeParam;
015: import java.awt.RenderingHints;
016: import java.awt.image.RenderedImage;
017: import java.awt.image.renderable.ParameterBlock;
018: import java.net.URL;
019: import javax.media.jai.JAI;
020: import javax.media.jai.OperationDescriptorImpl;
021: import javax.media.jai.ParameterBlockJAI;
022: import javax.media.jai.RenderedOp;
023: import javax.media.jai.registry.RenderedRegistryMode;
024:
025: /**
026: * An <code>OperationDescriptor</code> describing the "URL" operation.
027: *
028: * <p> The URL operation creates an output image whose source is
029: * specified by a Uniform Resource Locator (URL).
030: *
031: * <p> The allowable formats are those registered with the
032: * <code>com.sun.media.jai.codec.ImageCodec</code> class.
033: *
034: * <p> The second parameter contains an instance of
035: * <code>ImageDecodeParam</code> to be used during the decoding.
036: * It may be set to <code>null</code> in order to perform default
037: * decoding, or equivalently may be omitted.
038: *
039: * <p><b> The classes in the <code>com.sun.media.jai.codec</code>
040: * package are not a committed part of the JAI API. Future releases
041: * of JAI will make use of new classes in their place. This
042: * class will change accordingly.</b>
043: *
044: * <p><table border=1>
045: * <caption>Resource List</caption>
046: * <tr><th>Name</th> <th>Value</th></tr>
047: * <tr><td>GlobalName</td> <td>fileload</td></tr>
048: * <tr><td>LocalName</td> <td>fileload</td></tr>
049: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
050: * <tr><td>Description</td> <td>Reads an image from a file.</td></tr>
051: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/URLDescriptor.html</td></tr>
052: * <tr><td>Version</td> <td>1.0</td></tr>
053: * <tr><td>arg0Desc</td> <td>The path of the file to read from.</td></tr>
054: * <tr><td>arg1Desc</td> <td>The ImageDecodeParam to use.</td></tr>
055: * </table></p>
056: *
057: * <p><table border=1>
058: * <caption>Parameter List</caption>
059: * <tr><th>Name</th> <th>Class Type</th>
060: * <th>Default Value</th></tr>
061: * <tr><td>URL</td> <td>java.net.URL</td>
062: * <td>NO_PARAMETER_DEFAULT</td>
063: * <tr><td>param</td> <td>com.sun.media.jai.codec.ImageDecodeParam</td>
064: * <td>null</td>
065: * </table></p>
066: *
067: * @see javax.media.jai.OperationDescriptor
068: */
069: public class URLDescriptor extends OperationDescriptorImpl {
070:
071: /**
072: * The resource strings that provide the general documentation and
073: * specify the parameter list for the "URL" operation.
074: */
075: private static final String[][] resources = {
076: { "GlobalName", "URL" },
077: { "LocalName", "URL" },
078: { "Vendor", "com.sun.media.jai" },
079: { "Description", JaiI18N.getString("URLDescriptor0") },
080: {
081: "DocURL",
082: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/URLDescriptor.html" },
083: { "Version", JaiI18N.getString("DescriptorVersion") },
084: { "arg0Desc", JaiI18N.getString("URLDescriptor1") },
085: { "arg1Desc", JaiI18N.getString("URLDescriptor2") } };
086:
087: /** The parameter names for the "URL" operation. */
088: private static final String[] paramNames = { "URL", "param" };
089:
090: /** The parameter class types for the "URL" operation. */
091: private static final Class[] paramClasses = { java.net.URL.class,
092: com.sun.media.jai.codec.ImageDecodeParam.class };
093:
094: /** The parameter default values for the "URL" operation. */
095: private static final Object[] paramDefaults = {
096: NO_PARAMETER_DEFAULT, null };
097:
098: /** Constructor. */
099: public URLDescriptor() {
100: super (resources, 0, paramClasses, paramNames, paramDefaults);
101: }
102:
103: /**
104: * Reads an image from a URL.
105: *
106: * <p>Creates a <code>ParameterBlockJAI</code> from all
107: * supplied arguments except <code>hints</code> and invokes
108: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
109: *
110: * @see JAI
111: * @see ParameterBlockJAI
112: * @see RenderedOp
113: *
114: * @param URL The URL to read from.
115: * @param param The ImageDecodeParam to use.
116: * May be <code>null</code>.
117: * @param hints The <code>RenderingHints</code> to use.
118: * May be <code>null</code>.
119: * @return The <code>RenderedOp</code> destination.
120: * @throws IllegalArgumentException if <code>URL</code> is <code>null</code>.
121: */
122: public static RenderedOp create(URL URL, ImageDecodeParam param,
123: RenderingHints hints) {
124: ParameterBlockJAI pb = new ParameterBlockJAI("URL",
125: RenderedRegistryMode.MODE_NAME);
126:
127: pb.setParameter("URL", URL);
128: pb.setParameter("param", param);
129:
130: return JAI.create("URL", pb, hints);
131: }
132: }
|