KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcckit > graphic > Oval


1 /*
2  * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved
3  *
4  * This library is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details
13  * (http://www.gnu.org/copyleft/lesser.html).
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package jcckit.graphic;
20
21 /**
22  * An oval (i.e. an ellipse).
23  *
24  * @author Franz-Josef Elmer
25  */

26 public class Oval extends Rectangle {
27   /**
28    * Creates a new instance.
29    * @param center The position of the center of this element.
30    * @param width The width.
31    * @param height The height.
32    * @param attributes Drawing attributes. Can be <tt>null</tt>.
33    */

34   public Oval(GraphPoint center, double width, double height,
35                    GraphicAttributes attributes) {
36     super(center, width, height, attributes);
37   }
38
39   /**
40    * Renders this oval with the specified {@link Renderer}.
41    * @param renderer An instance of {@link OvalRenderer}.
42    * @throws IllegalArgumentException if <tt>renderer</tt> is not
43    * an instance of <tt>OvalRenderer</tt>.
44    */

45   public void renderWith(Renderer renderer) {
46     if (renderer instanceof OvalRenderer) {
47       ((OvalRenderer) renderer).render(this);
48     } else {
49       throw new IllegalArgumentException JavaDoc(renderer
50                             + " does not implements OvalRenderer.");
51     }
52   }
53 }
54
55
Popular Tags