01: /**
02: * JaWE CellViewFactory implementation
03: *
04: * Miroslav Popov, Jul 7, 2005
05: */package org.enhydra.jawe.components.graph;
06:
07: import org.jgraph.graph.CellView;
08: import org.jgraph.graph.CellViewFactory;
09: import org.jgraph.graph.EdgeView;
10: import org.jgraph.graph.GraphModel;
11: import org.jgraph.graph.PortView;
12:
13: /**
14: * @author Miroslav Popov
15: */
16: public class GraphObjectViewFactory implements CellViewFactory {
17: /* (non-Javadoc)
18: * @see org.jgraph.graph.CellViewFactory#createView(org.jgraph.graph.GraphModel, java.lang.Object)
19: */
20: public CellView createView(GraphModel model, Object cell) {
21: CellView view = null;
22: if (model.isPort(cell))
23: view = createPortView(cell);
24: else if (model.isEdge(cell))
25: view = createEdgeView(cell);
26: else
27: view = createVertexView(cell);
28:
29: return view;
30: }
31:
32: /**
33: * Create different vertex view depending of cell type
34: *
35: * @param cell
36: * @return CellView which represent view of cell
37: */
38: protected CellView createVertexView(Object cell) {
39: if (cell instanceof GraphParticipantInterface) {
40: return new DefaultGraphParticipantView(cell);
41: } else if (cell instanceof GraphBubbleActivityInterface) {
42: return new DefaultGraphBubbleActivityView(cell);
43: } else if (cell instanceof GraphActivityInterface) {
44: return new DefaultGraphActivityView(cell);
45: } else {
46: return null;
47: }
48: }
49:
50: /**
51: * Return edge view. For now we have only transition as edges
52: *
53: * @param cell
54: * @return EdgeView
55: */
56: protected EdgeView createEdgeView(Object cell) {
57: if (cell instanceof GraphTransitionInterface)
58: return new DefaultGraphTransitionView(cell);
59:
60: return null;
61: }
62:
63: /**
64: * We don't want many ports to be shown. Instead we want only one as big as vertex view is
65: *
66: * @param cell
67: * @return JaWEPortView - redefined port view
68: */
69: protected PortView createPortView(Object cell) {
70: if (cell instanceof GraphPortInterface)
71: return new DefaultGraphPortView(cell);
72:
73: return null;
74: }
75: }
|