1 26 27 package org.nightlabs.editor2d.j2d; 28 29 import java.awt.Rectangle ; 30 import java.awt.geom.Arc2D ; 31 import java.awt.geom.Rectangle2D ; 32 33 34 public class GeneralShapeFactory 35 { 36 public GeneralShapeFactory() { 37 super(); 38 } 39 40 public static GeneralShape createEllipse(int x, int y, int width, int height) 41 { 42 Arc2D arc = new Arc2D.Double (x, y, width, height, 0, 360, Arc2D.OPEN); 43 return new GeneralShape(arc); 44 } 45 46 public static GeneralShape createEllipse(Rectangle rect) 47 { 48 Arc2D arc = new Arc2D.Double (rect.x, rect.y, rect.width, rect.height, 0, 360, Arc2D.OPEN); 49 return new GeneralShape(arc); 50 } 51 52 public static GeneralShape createRectangle(int x, int y, int width, int height) 53 { 54 Rectangle2D rect = new Rectangle2D.Double (x, y, width, height); 55 GeneralShape gs = new GeneralShape(); 57 gs.moveTo(x, y); 58 gs.lineTo(x, y+height); 59 gs.lineTo(x+width, y+height); 60 gs.lineTo(x+width, y); 61 gs.closePath(); 62 return gs; 63 } 64 65 public static GeneralShape createRectangle(Rectangle rect) 66 { 67 return new GeneralShape(rect); 68 } 69 70 } 71 | Popular Tags |