1 19 package org.lucane.applications.whiteboard.graph.shapes; 20 21 import java.awt.Graphics ; 22 import java.awt.Point ; 23 import java.util.ArrayList ; 24 import java.util.Date ; 25 import java.util.Hashtable ; 26 import java.util.Map ; 27 28 import org.jgraph.graph.AttributeMap; 29 import org.jgraph.graph.DefaultEdge; 30 import org.jgraph.graph.GraphConstants; 31 import org.lucane.applications.whiteboard.graph.MyGraph; 32 33 class SimpleArrow implements Shape 34 { 35 public void paint(Graphics g, Point start, Point end) 36 { 37 g.drawLine(start.x, start.y, end.x, end.y); 38 } 39 40 public void addToGraph(MyGraph graph, Point start, Point end) 41 { 42 DefaultEdge edge = new DefaultEdge(); 43 Map attrs = new AttributeMap(); 44 attrs.put("timestamp", new Date ()); 45 46 int arrow = GraphConstants.ARROW_CLASSIC; 47 ArrayList points = new ArrayList (); 48 points.add(start); 49 points.add(end); 50 GraphConstants.setPoints(attrs, points); 51 GraphConstants.setLineWidth(attrs, graph.getLineWidth()); 52 GraphConstants.setLineColor(attrs, graph.getCellBorder()); 53 GraphConstants.setDashPattern(attrs, graph.getDashPattern()); 54 55 GraphConstants.setLineEnd(attrs, arrow); 56 GraphConstants.setEndFill(attrs, true); 57 58 Object [] cells = new Object [] { edge }; 59 Map attributes = new Hashtable (); 60 attributes.put(edge, attrs); 61 62 graph.getModel().insert(cells, attributes, null, null, null); 63 } 64 } | Popular Tags |