1 19 package jcckit.graphic; 20 21 26 public class ClippingRectangle implements ClippingShape { 27 private final double _minX, _minY, _maxX, _maxY; 28 29 33 public ClippingRectangle(double x1, double y1, double x2, double y2) { 34 _minX = Math.min(x1, x2); 35 _minY = Math.min(y1, y2); 36 _maxX = Math.max(x1, x2); 37 _maxY = Math.max(y1, y2); 38 } 39 40 44 public boolean isInside(GraphPoint point) { 45 double x = point.getX(); 46 double y = point.getY(); 47 return _minX <= x && x <= _maxX && _minY <= y && y <= _maxY; 48 } 49 50 51 public double getMinX() { 52 return _minX; 53 } 54 55 56 public double getMaxX() { 57 return _maxX; 58 } 59 60 61 public double getMinY() { 62 return _minY; 63 } 64 65 66 public double getMaxY() { 67 return _maxY; 68 } 69 70 71 public ClippingRectangle getBoundingBox() { 72 return this; 73 } 74 75 76 public BasicGraphicalElement getGraphicalElement() { 77 return new Rectangle(new GraphPoint(0.5 * (_minX + _maxX), 78 0.5 * (_minY + _maxY)), 79 _maxX - _minX, _maxY - _minY, null); 80 } 81 } 82 | Popular Tags |