1 8 package com.nightlabs.editor2d.j2d; 9 10 import java.awt.Rectangle ; 11 import java.awt.geom.Arc2D ; 12 import java.awt.geom.Rectangle2D ; 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 arc = new Arc2D.Double (x, y, width, height, 0, 360, Arc2D.OPEN); 24 return new GeneralShape(arc); 25 } 26 27 public static GeneralShape createEllipse(Rectangle rect) 28 { 29 Arc2D arc = new Arc2D.Double (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 rect = new Rectangle2D.Double (x, y, width, height); 36 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 rect) 47 { 48 return new GeneralShape(rect); 49 } 50 51 } 52 | Popular Tags |