1 19 package org.lucane.applications.whiteboard.graph.shapes; 20 21 import java.awt.Graphics ; 22 import java.awt.Point ; 23 import java.util.HashMap ; 24 25 import org.lucane.applications.whiteboard.WhiteBoard; 26 import org.lucane.applications.whiteboard.graph.MyGraph; 27 28 public class ShapeManager 29 { 30 private HashMap shapes; 31 private String selectedShape; 32 33 public ShapeManager(WhiteBoard plugin) 34 { 35 this.shapes = new HashMap (); 36 this.shapes.put("rectangle", new Rectangle()); 37 this.shapes.put("roundRectangle", new RoundRectangle()); 38 this.shapes.put("diamond", new Diamond()); 39 this.shapes.put("ellipse", new Ellipse()); 40 41 this.shapes.put("line", new Line()); 42 this.shapes.put("simpleArrow", new SimpleArrow()); 43 this.shapes.put("doubleArrow", new DoubleArrow()); 44 45 this.shapes.put("text", new Text(plugin)); 46 this.shapes.put("image", new Image(plugin)); 47 48 this.selectedShape = null; 49 } 50 51 public void setSelectedShape(String name) 52 { 53 this.selectedShape = name; 54 } 55 56 public String getSelectedShape() 57 { 58 return selectedShape; 59 } 60 61 public void paintSelectedShape(Graphics g, Point start, Point end) 62 { 63 if(this.selectedShape != null) 64 getShape(selectedShape).paint(g, start, end); 65 } 66 67 public void addSelectedShape(MyGraph graph, Point start, Point end) 68 { 69 if(this.selectedShape != null) 70 getShape(selectedShape).addToGraph(graph, start, end); 71 } 72 73 private Shape getShape(String name) 74 { 75 return (Shape)shapes.get(name); 76 } 77 78 } | Popular Tags |