1 18 19 package org.apache.batik.ext.awt.geom; 20 21 import java.awt.Rectangle ; 22 import java.awt.Shape ; 23 import java.awt.geom.AffineTransform ; 24 import java.awt.geom.PathIterator ; 25 import java.awt.geom.Point2D ; 26 import java.awt.geom.Rectangle2D ; 27 28 33 public class ShapeExtender implements ExtendedShape { 34 Shape shape; 35 36 public ShapeExtender(Shape 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 p) { 48 return shape.contains(p); 49 } 50 51 public boolean contains(Rectangle2D r) { 52 return shape.contains(r); 53 } 54 55 public Rectangle getBounds() { 56 return shape.getBounds(); 57 } 58 59 public Rectangle2D getBounds2D() { 60 return shape.getBounds2D(); 61 } 62 63 public PathIterator getPathIterator(AffineTransform at) { 64 return shape.getPathIterator(at); 65 } 66 67 public PathIterator getPathIterator(AffineTransform 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 r) { 80 return shape.intersects(r); 81 } 82 83 84 public static class EPIWrap implements ExtendedPathIterator { 85 PathIterator pi = null; 86 public EPIWrap(PathIterator 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 |