1 19 package jcckit.graphic; 20 21 26 public class Rectangle extends BasicGraphicalElement { 27 private final GraphPoint _center; 28 private final double _width; 29 private final double _height; 30 31 38 public Rectangle(GraphPoint center, double width, double height, 39 GraphicAttributes attributes) { 40 super(attributes); 41 _center = center; 42 _width = width; 43 _height = height; 44 } 45 46 47 public GraphPoint getCenter() { 48 return _center; 49 } 50 51 52 public double getWidth() { 53 return _width; 54 } 55 56 57 public double getHeight() { 58 return _height; 59 } 60 61 67 public void renderWith(Renderer renderer) { 68 if (renderer instanceof RectangleRenderer) { 69 ((RectangleRenderer) renderer).render(this); 70 } else { 71 throw new IllegalArgumentException (renderer 72 + " does not implements RectangleRenderer."); 73 } 74 } 75 } 76 77 | Popular Tags |