01: package org.enhydra.jawe.components.graph;
02:
03: import java.awt.geom.Point2D;
04: import java.awt.geom.Rectangle2D;
05: import java.util.HashMap;
06: import java.util.Map;
07:
08: import org.enhydra.shark.xpdl.elements.Activity;
09: import org.jgraph.graph.CellViewRenderer;
10: import org.jgraph.graph.EdgeView;
11: import org.jgraph.graph.VertexView;
12:
13: /**
14: * Represents a view for a model's Activity object.
15: *
16: * @author Sasa Bojanic
17: */
18: public class DefaultGraphActivityView extends VertexView implements
19: GraphActivityViewInterface {
20:
21: protected static Map renderers = new HashMap();
22:
23: /**
24: * Constructs a activity view for the specified model object.
25: *
26: * @param cell reference to the model object
27: */
28: public DefaultGraphActivityView(Object cell) {
29: super (cell);
30: }
31:
32: /**
33: * Returns a renderer for the class.
34: */
35: public CellViewRenderer getRenderer() {
36: String type = ((GraphActivityInterface) super .getCell())
37: .getType();
38: GraphActivityRendererInterface garenderer = (GraphActivityRendererInterface) renderers
39: .get(type);
40: if (garenderer == null) {
41: garenderer = createRenderer((Activity) ((GraphActivityInterface) super
42: .getCell()).getUserObject());
43: renderers.put(type, garenderer);
44: }
45: return garenderer;
46: }
47:
48: /**
49: * Returns the bounding rectangle for this view.
50: */
51: public Rectangle2D getBounds() {//HM, JGraph3.4.1
52: return bounds;
53: }
54:
55: protected GraphActivityRendererInterface createRenderer(Activity act) {
56: return GraphUtilities.getGraphController()
57: .getGraphObjectRendererFactory()
58: .createActivityRenderer(act);
59: }
60:
61: public Point2D getPerimeterPoint(EdgeView edge, Point2D source,
62: Point2D p) {
63: return ((MultiLinedRenderer) getRenderer()).getPerimeterPoint(
64: this, p);
65: }
66: }
|