01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
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: public void paint(Graphics g, Point start, Point end) {
35: g.drawLine(start.x, start.y, end.x, end.y);
36: }
37:
38: public void addToGraph(MyGraph graph, Point start, Point end) {
39: DefaultEdge edge = new DefaultEdge();
40: Map attrs = new AttributeMap();
41: attrs.put("timestamp", new Date());
42:
43: int arrow = GraphConstants.ARROW_CLASSIC;
44: ArrayList points = new ArrayList();
45: points.add(start);
46: points.add(end);
47: GraphConstants.setPoints(attrs, points);
48: GraphConstants.setLineWidth(attrs, graph.getLineWidth());
49: GraphConstants.setLineColor(attrs, graph.getCellBorder());
50: GraphConstants.setDashPattern(attrs, graph.getDashPattern());
51:
52: GraphConstants.setLineEnd(attrs, arrow);
53: GraphConstants.setEndFill(attrs, true);
54:
55: Object[] cells = new Object[] { edge };
56: Map attributes = new Hashtable();
57: attributes.put(edge, attrs);
58:
59: graph.getModel().insert(cells, attributes, null, null, null);
60: }
61: }
|