2362N/A * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A <code>ParameterBlock</code> encapsulates all the information about sources and 0N/A * parameters (Objects) required by a RenderableImageOp, or other 0N/A * classes that process images. 0N/A * <p> Although it is possible to place arbitrary objects in the 0N/A * source Vector, users of this class may impose semantic constraints 0N/A * such as requiring all sources to be RenderedImages or 0N/A * RenderableImage. <code>ParameterBlock</code> itself is merely a container and 0N/A * performs no checking on source or parameter types. 0N/A * <p> All parameters in a <code>ParameterBlock</code> are objects; convenience 0N/A * add and set methods are available that take arguments of base type and 0N/A * construct the appropriate subclass of Number (such as 0N/A * Integer or Float). Corresponding get methods perform a 0N/A * downward cast and have return values of base type; an exception 0N/A * will be thrown if the stored values do not have the correct type. 0N/A * There is no way to distinguish between the results of 0N/A * "short s; add(s)" and "add(new Short(s))". 0N/A * <p> Note that the get and set methods operate on references. 0N/A * Therefore, one must be careful not to share references between 0N/A * <code>ParameterBlock</code>s when this is inappropriate. For example, to create 0N/A * a new <code>ParameterBlock</code> that is equal to an old one except for an 0N/A * added source, one might be tempted to write: 0N/A * ParameterBlock addSource(ParameterBlock pb, RenderableImage im) { 0N/A * ParameterBlock pb1 = new ParameterBlock(pb.getSources()); 0N/A * pb1.addSource(im); 0N/A * <p> This code will have the side effect of altering the original 0N/A * <code>ParameterBlock</code>, since the getSources operation returned a reference 0N/A * to its source Vector. Both pb and pb1 share their source Vector, 0N/A * and a change in either is visible to both. 0N/A * <p> A correct way to write the addSource function is to clone 0N/A * the source Vector: 0N/A * ParameterBlock addSource (ParameterBlock pb, RenderableImage im) { 0N/A * ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone()); 0N/A * pb1.addSource(im); 0N/A * <p> The clone method of <code>ParameterBlock</code> has been defined to 0N/A * perform a clone of both the source and parameter Vectors for 0N/A * this reason. A standard, shallow clone is available as 0N/A * <p> The addSource, setSource, add, and set methods are 0N/A * defined to return 'this' after adding their argument. This allows 0N/A * use of syntax like: 0N/A * ParameterBlock pb = new ParameterBlock(); 0N/A * op = new RenderableImageOp("operation", pb.add(arg1).add(arg2)); 0N/A /** A Vector of sources, stored as arbitrary Objects. */ 0N/A /** A Vector of non-source parameters, stored as arbitrary Objects. */ 0N/A /** A dummy constructor. */ 0N/A * Constructs a <code>ParameterBlock</code> with a given Vector 0N/A * @param sources a <code>Vector</code> of source images 0N/A * Constructs a <code>ParameterBlock</code> with a given Vector of sources and 0N/A * Vector of parameters. 0N/A * @param sources a <code>Vector</code> of source images 0N/A * @param parameters a <code>Vector</code> of parameters to be used in the 0N/A * rendering operation 0N/A * Creates a shallow copy of a <code>ParameterBlock</code>. The source and 0N/A * parameter Vectors are copied by reference -- additions or 0N/A * changes will be visible to both versions. 0N/A * @return an Object clone of the <code>ParameterBlock</code>. 0N/A // We can't be here since we implement Cloneable. 0N/A * Creates a copy of a <code>ParameterBlock</code>. The source and parameter 0N/A * Vectors are cloned, but the actual sources and parameters are 0N/A * copied by reference. This allows modifications to the order 0N/A * and number of sources and parameters in the clone to be invisible 0N/A * to the original <code>ParameterBlock</code>. Changes to the shared sources or 0N/A * parameters themselves will still be visible. 0N/A * @return an Object clone of the <code>ParameterBlock</code>. 0N/A // We can't be here since we implement Cloneable. 0N/A * Adds an image to end of the list of sources. The image is 0N/A * stored as an object in order to allow new node types in the 0N/A * @param source an image object to be stored in the source list. 0N/A * @return a new <code>ParameterBlock</code> containing the specified 0N/A * <code>source</code>. 0N/A * Returns a source as a general Object. The caller must cast it into 0N/A * an appropriate type. 0N/A * @param index the index of the source to be returned. 0N/A * @return an <code>Object</code> that represents the source located 0N/A * at the specified index in the <code>sources</code> 0N/A * <code>Vector</code>. 0N/A * @see #setSource(Object, int) 0N/A * Replaces an entry in the list of source with a new source. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param source the specified source image 0N/A * @param index the index into the <code>sources</code> 0N/A * <code>Vector</code> at which to 0N/A * insert the specified <code>source</code> 0N/A * @return a new <code>ParameterBlock</code> that contains the 0N/A * specified <code>source</code> at the specified 0N/A * <code>index</code>. 0N/A * @see #getSource(int) 0N/A * Returns a source as a <code>RenderedImage</code>. This method is 0N/A * a convenience method. 0N/A * An exception will be thrown if the source is not a RenderedImage. 0N/A * @param index the index of the source to be returned 0N/A * @return a <code>RenderedImage</code> that represents the source 0N/A * image that is at the specified index in the 0N/A * <code>sources</code> <code>Vector</code>. 0N/A * Returns a source as a RenderableImage. This method is a 0N/A * convenience method. 0N/A * An exception will be thrown if the sources is not a RenderableImage. 0N/A * @param index the index of the source to be returned 0N/A * @return a <code>RenderableImage</code> that represents the source 0N/A * image that is at the specified index in the 0N/A * <code>sources</code> <code>Vector</code>. 0N/A * Returns the number of source images. 0N/A * @return the number of source images in the <code>sources</code> 0N/A * <code>Vector</code>. 0N/A * Returns the entire Vector of sources. 0N/A * @return the <code>sources</code> <code>Vector</code>. 0N/A * @see #setSources(Vector) 0N/A * Sets the entire Vector of sources to a given Vector. 0N/A * @param sources the <code>Vector</code> of source images 0N/A /** Clears the list of source images. */ 0N/A * Returns the number of parameters (not including source images). 0N/A * @return the number of parameters in the <code>parameters</code> 0N/A * <code>Vector</code>. 0N/A * Returns the entire Vector of parameters. 0N/A * @return the <code>parameters</code> <code>Vector</code>. 0N/A * @see #setParameters(Vector) 0N/A * Sets the entire Vector of parameters to a given Vector. 0N/A * @param parameters the specified <code>Vector</code> of 0N/A * @see #getParameters 0N/A /** Clears the list of parameters. */ 0N/A * Adds an object to the list of parameters. 0N/A * @param obj the <code>Object</code> to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Byte to the list of parameters. 0N/A * @param b the byte to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Character to the list of parameters. 0N/A * @param c the char to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Short to the list of parameters. 0N/A * @param s the short to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Integer to the list of parameters. 0N/A * @param i the int to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Long to the list of parameters. 0N/A * @param l the long to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Float to the list of parameters. 0N/A * @param f the float to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Adds a Double to the list of parameters. 0N/A * @param d the double to add to the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param obj the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Byte. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param b the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Character. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param c the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Short. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param s the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with an Integer. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param i the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Long. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param l the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Float. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param f the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Replaces an Object in the list of parameters with a Double. 0N/A * If the index lies beyond the current source list, 0N/A * the list is extended with nulls as needed. 0N/A * @param d the parameter that replaces the 0N/A * parameter at the specified index in the 0N/A * <code>parameters</code> <code>Vector</code> 0N/A * @param index the index of the parameter to be 0N/A * replaced with the specified parameter 0N/A * @return a new <code>ParameterBlock</code> containing 0N/A * the specified parameter. 0N/A * Gets a parameter as an object. 0N/A * @param index the index of the parameter to get 0N/A * @return an <code>Object</code> representing the 0N/A * the parameter at the specified index 0N/A * into the <code>parameters</code> 0N/A * <code>Vector</code>. 0N/A * A convenience method to return a parameter as a byte. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Byte</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>byte</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Byte</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as a char. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Character</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>char</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Character</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as a short. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Short</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>short</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Short</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as an int. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not an <code>Integer</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>int</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Integer</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as a long. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Long</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>long</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Long</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as a float. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Float</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>float</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Float</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * A convenience method to return a parameter as a double. An 0N/A * exception is thrown if the parameter is 0N/A * <code>null</code> or not a <code>Double</code>. 0N/A * @param index the index of the parameter to be returned. 0N/A * @return the parameter at the specified index 0N/A * as a <code>double</code> value. 0N/A * @throws ClassCastException if the parameter at the 0N/A * specified index is not a <code>Double</code> 0N/A * @throws NullPointerException if the parameter at the specified 0N/A * index is <code>null</code> 0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code> 0N/A * is negative or not less than the current size of this 0N/A * <code>ParameterBlock</code> object 0N/A * Returns an array of Class objects describing the types 0N/A * of the parameters. 0N/A * @return an array of <code>Class</code> objects.