KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > math > Circle


1 /* ************************************************************************** *
2  * Copyright (C) 2004 NightLabs GmbH, Marco Schulze *
3  * All rights reserved. *
4  * http://www.NightLabs.de *
5  * *
6  * This program and the accompanying materials are free software; you can re- *
7  * distribute it and/or modify it under the terms of the GNU General Public *
8  * License as published by the Free Software Foundation; either ver 2 of the *
9  * License, or any later version. *
10  * *
11  * This module is distributed in the hope that it will be useful, but WITHOUT *
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- *
13  * NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more *
14  * details. *
15  * *
16  * You should have received a copy of the GNU General Public License along *
17  * with this module; if not, write to the Free Software Foundation, Inc.: *
18  * 59 Temple Place, Suite 330 *
19  * Boston MA 02111-1307 *
20  * USA *
21  * *
22  * Or get it online: *
23  * http://www.opensource.org/licenses/gpl-license.php *
24  * *
25  * In case, you want to use this module or parts of it in a proprietary pro- *
26  * ject, you can purchase it under the NightLabs Commercial License. Please *
27  * contact NightLabs GmbH under info AT nightlabs DOT com for more infos or *
28  * visit http://www.NightLabs.com *
29  * ************************************************************************** */

30
31 /**
32  * <p> Project: NightLabsBase </p>
33  * <p> Copyright: Copyright (c) 2004 </p>
34  * <p> Company: NightLabs GmbH (Germany) </p>
35  * <p> Creation Date: 20.05.2005 </p>
36  * <p> Author: Daniel Mazurek </p>
37 **/

38 package com.nightlabs.math;
39
40 import java.awt.geom.Point2D JavaDoc;
41
42
43 public class Circle
44 {
45   protected double middleX;
46   public double getMiddleX() {
47     return middleX;
48   }
49   public void setMiddleX(double middleX) {
50     this.middleX = middleX;
51   }
52   
53   protected double middleY;
54   public double getMiddleY() {
55     return middleY;
56   }
57   public void setMiddleY(double middleY) {
58     this.middleY = middleY;
59   }
60   
61   protected double radius;
62   public double getRadius() {
63     return radius;
64   }
65   public void setRadius(double radius) {
66     this.radius = radius;
67   }
68
69   public Point2D JavaDoc getCenter() {
70     return new Point2D.Double JavaDoc(middleX, middleY);
71   }
72   public void setCenter(Point2D JavaDoc center) {
73     middleX = center.getX();
74     middleY = center.getY();
75   }
76     
77   public Circle(double middleX, double middleY, double radius)
78   {
79     super();
80     this.middleX = middleX;
81     this.middleY = middleY;
82     this.radius = radius;
83   }
84
85   public Circle(Point2D JavaDoc center, double radius) {
86     super();
87     middleX = center.getX();
88     middleY = center.getY();
89     this.radius = radius;
90   }
91  
92   public double getDiamter() {
93     return 2 * radius;
94   }
95 }
96
Popular Tags