01: /*
02: * $RCSfile: PointMapperOpImage.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/11/21 22:49:40 $
10: * $State: Exp $
11: */
12:
13: package com.sun.media.jai.opimage;
14:
15: import java.awt.geom.AffineTransform;
16: import java.awt.geom.NoninvertibleTransformException;
17: import java.awt.geom.Point2D;
18: import java.util.Map;
19: import javax.media.jai.NullOpImage;
20: import javax.media.jai.OpImage;
21: import javax.media.jai.PlanarImage;
22:
23: /**
24: * A class which merely wraps another <code>PlanarImage</code> but
25: * uses a supplied <code>AffineTransform</code> object for point mapping.
26: */
27: public class PointMapperOpImage extends NullOpImage {
28: private AffineTransform transform;
29: private AffineTransform inverseTransform;
30:
31: public PointMapperOpImage(PlanarImage source, Map configuration,
32: AffineTransform transform)
33: throws NoninvertibleTransformException {
34: super (source, null, configuration, OP_COMPUTE_BOUND);
35:
36: if (transform == null) {
37: throw new IllegalArgumentException("transform == null!");
38: }
39:
40: this .transform = transform;
41: this .inverseTransform = transform.createInverse();
42: }
43:
44: public Point2D mapDestPoint(Point2D destPt, int sourceIndex) {
45: if (sourceIndex != 0) {
46: throw new IndexOutOfBoundsException("sourceIndex != 0!");
47: }
48:
49: return inverseTransform.transform(destPt, null);
50: }
51:
52: public Point2D mapSourcePoint(Point2D sourcePt, int sourceIndex) {
53: if (sourceIndex != 0) {
54: throw new IndexOutOfBoundsException("sourceIndex != 0!");
55: }
56:
57: return inverseTransform.transform(sourcePt, null);
58: }
59:
60: public synchronized void dispose() {
61: getSourceImage(0).dispose();
62: super.dispose();
63: }
64: }
|