KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > geom > ShapeExtender


1 /*
2
3    Copyright 1999-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17 */

18
19 package org.apache.batik.ext.awt.geom;
20
21 import java.awt.Rectangle JavaDoc;
22 import java.awt.Shape JavaDoc;
23 import java.awt.geom.AffineTransform JavaDoc;
24 import java.awt.geom.PathIterator JavaDoc;
25 import java.awt.geom.Point2D JavaDoc;
26 import java.awt.geom.Rectangle2D JavaDoc;
27
28 /**
29  * This class wraps a normal path into an extended path.
30  * @author <a HREF="mailto:deweese@apache.org">Thomas DeWeese</a>
31  * @version $Id: ShapeExtender.java,v 1.5 2004/10/30 18:38:05 deweese Exp $
32  */

33 public class ShapeExtender implements ExtendedShape {
34     Shape JavaDoc shape;
35
36     public ShapeExtender(Shape JavaDoc shape) {
37         this.shape = shape;
38     }
39
40     public boolean contains(double x, double y) {
41         return shape.contains(x, y);
42     }
43     public boolean contains(double x, double y, double w, double h) {
44         return shape.contains(x, y, w, h);
45     }
46
47     public boolean contains(Point2D JavaDoc p) {
48         return shape.contains(p);
49     }
50
51     public boolean contains(Rectangle2D JavaDoc r) {
52         return shape.contains(r);
53     }
54
55     public Rectangle JavaDoc getBounds() {
56         return shape.getBounds();
57     }
58
59     public Rectangle2D JavaDoc getBounds2D() {
60         return shape.getBounds2D();
61     }
62
63     public PathIterator JavaDoc getPathIterator(AffineTransform JavaDoc at) {
64         return shape.getPathIterator(at);
65     }
66
67     public PathIterator JavaDoc getPathIterator(AffineTransform JavaDoc at, double flatness) {
68         return shape.getPathIterator(at, flatness);
69     }
70
71     public ExtendedPathIterator getExtendedPathIterator() {
72         return new EPIWrap(shape.getPathIterator(null));
73     }
74
75     public boolean intersects(double x, double y, double w, double h) {
76         return shape.intersects(x, y, w, h);
77     }
78
79     public boolean intersects(Rectangle2D JavaDoc r) {
80         return shape.intersects(r);
81     }
82
83
84     public static class EPIWrap implements ExtendedPathIterator {
85         PathIterator JavaDoc pi = null;
86         public EPIWrap(PathIterator JavaDoc pi) {
87             this.pi = pi;
88         }
89
90         public int currentSegment(double[] coords) {
91             return pi.currentSegment(coords); }
92
93         public int currentSegment(float[] coords) {
94             return pi.currentSegment(coords); }
95
96         public int getWindingRule() {
97             return pi.getWindingRule();
98         }
99
100         public boolean isDone() {
101             return pi.isDone(); }
102
103         public void next() {
104             pi.next();
105         }
106     }
107 }
108
Popular Tags