01: /*
02: * $RCSfile: AddConstToCollectionOpImage.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:12 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
13:
14: import java.awt.RenderingHints;
15: import java.awt.image.RenderedImage;
16: import java.awt.image.renderable.ParameterBlock;
17: import java.util.Collection;
18: import java.util.Iterator;
19: import java.util.Vector;
20: import javax.media.jai.ImageLayout;
21: import javax.media.jai.JAI;
22: import javax.media.jai.CollectionImage;
23:
24: /**
25: * An <code>OpImage</code> implementing the "AddConstToCollection" operation.
26: *
27: * @see javax.media.jai.operator.AddConstToCollectionDescriptor
28: * @see AddConstToCollectionCIF
29: *
30: *
31: * @since EA4
32: */
33: final class AddConstToCollectionOpImage extends CollectionImage {
34:
35: /**
36: * Constructor.
37: *
38: * @param sourceCollection A collection of rendered images.
39: * @param hints Optionally contains destination image layout.
40: * @param constants The constants to be added, stored as reference.
41: */
42: public AddConstToCollectionOpImage(Collection sourceCollection,
43: RenderingHints hints, double[] constants) {
44: /**
45: * Try to create a new instance of the sourceCollection to be
46: * used to store output images. If failed, use a Vector.
47: */
48: try {
49: imageCollection = (Collection) sourceCollection.getClass()
50: .newInstance();
51: } catch (Exception e) {
52: imageCollection = new Vector();
53: }
54:
55: Iterator iter = sourceCollection.iterator();
56: while (iter.hasNext()) {
57: ParameterBlock pb = new ParameterBlock();
58: pb.addSource(iter.next());
59: pb.add(constants);
60:
61: imageCollection.add(JAI.create("AddConst", pb, hints));
62: }
63: }
64: }
|