KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > j2d > GeneralShapeFactory


1 /**
2  * <p> Project: com.nightlabs.gui </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 26.01.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.j2d;
9
10 import java.awt.Rectangle JavaDoc;
11 import java.awt.geom.Arc2D JavaDoc;
12 import java.awt.geom.Rectangle2D JavaDoc;
13
14
15 public class GeneralShapeFactory
16 {
17   public GeneralShapeFactory() {
18     super();
19   }
20
21   public static GeneralShape createEllipse(int x, int y, int width, int height)
22   {
23     Arc2D JavaDoc arc = new Arc2D.Double JavaDoc(x, y, width, height, 0, 360, Arc2D.OPEN);
24     return new GeneralShape(arc);
25   }
26
27   public static GeneralShape createEllipse(Rectangle JavaDoc rect)
28   {
29     Arc2D JavaDoc arc = new Arc2D.Double JavaDoc(rect.x, rect.y, rect.width, rect.height, 0, 360, Arc2D.OPEN);
30     return new GeneralShape(arc);
31   }
32     
33   public static GeneralShape createRectangle(int x, int y, int width, int height)
34   {
35     Rectangle2D JavaDoc rect = new Rectangle2D.Double JavaDoc(x, y, width, height);
36 // return new GeneralShape(rect);
37
GeneralShape gs = new GeneralShape();
38     gs.moveTo(x, y);
39     gs.lineTo(x, y+height);
40     gs.lineTo(x+width, y+height);
41     gs.lineTo(x+width, y);
42     gs.closePath();
43     return gs;
44   }
45   
46   public static GeneralShape createRectangle(Rectangle JavaDoc rect)
47   {
48     return new GeneralShape(rect);
49   }
50    
51 }
52
Popular Tags