001: /*
002: * $RCSfile: AWTImageDescriptor.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:28 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import java.awt.Image;
015: import java.awt.RenderingHints;
016: import java.awt.image.RenderedImage;
017: import javax.media.jai.JAI;
018: import javax.media.jai.OperationDescriptorImpl;
019: import javax.media.jai.ParameterBlockJAI;
020: import javax.media.jai.RenderedOp;
021: import javax.media.jai.registry.RenderedRegistryMode;
022:
023: /**
024: * An <code>OperationDescriptor</code> describing the "AWTImage" operation.
025: *
026: * <p> The AWTImage operation converts a standard
027: * <code>java.awt.Image</code> into a rendered image. By default, the
028: * width and height of the image are the same as the original AWT
029: * image. The sample model and color model are set according to the
030: * AWT image data.
031: *
032: * <p><table border=1>
033: * <caption>Resource List</caption>
034: * <tr><th>Name</th> <th>Value</th></tr>
035: * <tr><td>GlobalName</td> <td>AWTImage</td></tr>
036: * <tr><td>LocalName</td> <td>AWTImage</td></tr>
037: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
038: * <tr><td>Description</td> <td>Converts a <code>java.awt.Image</code>
039: * into a rendered image.</td></tr>
040: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AWTImageDescriptor.html</td></tr>
041: * <tr><td>Version</td> <td>1.0</td></tr>
042: * <tr><td>arg0Desc</td> <td>The AWT image to be converted.</td></tr>
043: * </table></p>
044: *
045: * <p><table border=1>
046: * <caption>Parameter List</caption>
047: * <tr><th>Name</th> <th>Class Type</th>
048: * <th>Default Value</th></tr>
049: * <tr><td>awtImage</td> <td>java.awt.Image</td>
050: * <td>NO_PARAMETER_DEFAULT</td>
051: * </table></p>
052: *
053: * @see java.awt.Image
054: * @see javax.media.jai.OperationDescriptor
055: */
056: public class AWTImageDescriptor extends OperationDescriptorImpl {
057:
058: /**
059: * The resource strings that provide the general documentation
060: * and specify the parameter list for this operation.
061: */
062: private static final String[][] resources = {
063: { "GlobalName", "AWTImage" },
064: { "LocalName", "AWTImage" },
065: { "Vendor", "com.sun.media.jai" },
066: { "Description", JaiI18N.getString("AWTImageDescriptor0") },
067: {
068: "DocURL",
069: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AWTImageDescriptor.html" },
070: { "Version", JaiI18N.getString("DescriptorVersion") },
071: { "arg0Desc", JaiI18N.getString("AWTImageDescriptor1") } };
072:
073: /** The parameter class list for this operation. */
074: private static final Class[] paramClasses = { java.awt.Image.class };
075:
076: /** The parameter name list for this operation. */
077: private static final String[] paramNames = { "awtImage" };
078:
079: /** The parameter default value list for this operation. */
080: private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
081:
082: /** Constructor. */
083: public AWTImageDescriptor() {
084: super (resources, 0, paramClasses, paramNames, paramDefaults);
085: }
086:
087: /**
088: * Converts a java.awt.Image into a rendered image.
089: *
090: * <p>Creates a <code>ParameterBlockJAI</code> from all
091: * supplied arguments except <code>hints</code> and invokes
092: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
093: *
094: * @see JAI
095: * @see ParameterBlockJAI
096: * @see RenderedOp
097: *
098: * @param awtImage The AWT image to be converted.
099: * @param hints The <code>RenderingHints</code> to use.
100: * May be <code>null</code>.
101: * @return The <code>RenderedOp</code> destination.
102: * @throws IllegalArgumentException if <code>awtImage</code> is <code>null</code>.
103: */
104: public static RenderedOp create(Image awtImage, RenderingHints hints) {
105: ParameterBlockJAI pb = new ParameterBlockJAI("AWTImage",
106: RenderedRegistryMode.MODE_NAME);
107:
108: pb.setParameter("awtImage", awtImage);
109:
110: return JAI.create("AWTImage", pb, hints);
111: }
112: }
|