01: /*
02: * $RCSfile: HistogramRIF.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:28 $
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.awt.image.renderable.RenderedImageFactory;
18: import javax.media.jai.JAI;
19: import javax.media.jai.ROI;
20: import javax.media.jai.util.ImagingListener;
21: import com.sun.media.jai.util.ImageUtil;
22:
23: /**
24: * A <code>RIF</code> supporting the "Histogram" operation in the
25: * rendered image layer.
26: *
27: * @since EA2
28: * @see javax.media.jai.operator.HistogramDescriptor
29: * @see HistogramOpImage
30: *
31: */
32: public class HistogramRIF implements RenderedImageFactory {
33:
34: /** Constructor. */
35: public HistogramRIF() {
36: }
37:
38: /**
39: * Creates a new instance of <code>HistogramOpImage</code>
40: * in the rendered layer. Any image layout information in
41: * <code>RenderingHints</code> is ignored.
42: * This method satisfies the implementation of RIF.
43: */
44: public RenderedImage create(ParameterBlock args,
45: RenderingHints hints) {
46: RenderedImage src = args.getRenderedSource(0);
47:
48: int xStart = src.getMinX(); // default values
49: int yStart = src.getMinY();
50:
51: int maxWidth = src.getWidth();
52: int maxHeight = src.getHeight();
53:
54: ROI roi = (ROI) args.getObjectParameter(0);
55: int xPeriod = args.getIntParameter(1);
56: int yPeriod = args.getIntParameter(2);
57: int[] numBins = (int[]) args.getObjectParameter(3);
58: double[] lowValue = (double[]) args.getObjectParameter(4);
59: double[] highValue = (double[]) args.getObjectParameter(5);
60:
61: HistogramOpImage op = null;
62: try {
63: op = new HistogramOpImage(src, roi, xStart, yStart,
64: xPeriod, yPeriod, numBins, lowValue, highValue);
65: } catch (Exception e) {
66: ImagingListener listener = ImageUtil
67: .getImagingListener(hints);
68: String message = JaiI18N.getString("HistogramRIF0");
69: listener.errorOccurred(message, e, this , false);
70: }
71:
72: return op;
73: }
74: }
|