96
|
1 module doodle.fig.network;
|
|
2
|
|
3 public {
|
|
4 import doodle.fig.diagram_elements;
|
|
5 }
|
|
6
|
|
7 enum EdgeEnd {
|
|
8 Source,
|
|
9 Target
|
|
10 };
|
|
11
|
|
12 interface INetworkObserver {
|
|
13 // Node changes
|
|
14
|
|
15 void nodeAdded(GraphNode node,
|
|
16 GraphElement container);
|
|
17 void nodeChanged(GraphNode node);
|
|
18 void nodeRelocated(GraphNode node,
|
|
19 GraphElement container);
|
|
20 void nodeRemoved(GraphNode node,
|
|
21 GraphElement container);
|
|
22
|
|
23 // Edge changes
|
|
24
|
97
|
25 void edgeAdded(GraphEdge edge);
|
96
|
26 void edgeChanged(GraphEdge edge);
|
|
27 void edgeRerouted();
|
|
28 void edgeRemoved();
|
|
29 }
|
|
30
|
|
31 interface INetwork {
|
|
32 void addObserver(INetworkObserver observer);
|
|
33 void removeObserver(INetworkObserver observer);
|
|
34
|
|
35 //
|
|
36 // Interrogation:
|
|
37 //
|
|
38
|
|
39 GraphNode[] getRootNodes();
|
|
40
|
|
41 // Inquire whether in principle a node of node_type
|
|
42 // can be added at the given point, possibly nested
|
|
43 // within the nest node. The nest can be null.
|
|
44 bool canAdd(string node_type,
|
|
45 Point point, // necessary?
|
|
46 GraphNode nest);
|
|
47
|
|
48 bool canRelocate(GraphNode node);
|
|
49
|
|
50 bool canRemove(GraphNode node);
|
|
51
|
|
52 // Inquire whether in principle the source element can
|
|
53 // be connected to the target element using
|
|
54 // an edge of edge_type. This might return true even
|
|
55 // though the real operation would fail due to deeper checking.
|
|
56 bool canConnect(char[] edge_type,
|
|
57 GraphElement sourceElement, Point sourcePoint,
|
|
58 GraphElement targetElement, Point targetPoint);
|
|
59
|
|
60 // Inquire whether in principle a given end of an existing edge
|
|
61 // can be rerouted from old_element to new_element at new_point.
|
|
62 // old_element and new_element may be the same element.
|
|
63 bool canReroute(GraphEdge edge, EdgeEnd end,
|
|
64 GraphElement oldElement,
|
|
65 GraphElement newElement, Point newPoint);
|
|
66
|
|
67 bool canDisconnect(GraphEdge edge);
|
|
68
|
|
69 //
|
|
70 // Manipulation:
|
|
71 //
|
|
72
|
|
73 // Attempt to really add a node...
|
|
74 GraphNode add(char[] node_type, /* initial properties, */
|
|
75 Point point,
|
|
76 GraphNode nest);
|
|
77
|
|
78 void relocate(GraphNode node,
|
|
79 GraphElement oldContainer,
|
|
80 GraphElement newContainer, Point newPoint);
|
|
81
|
|
82 // Attempt to really remove a node
|
|
83 void remove(GraphNode node);
|
|
84
|
|
85 // Attempt to really connect the source element to the target element
|
|
86 // using an edge of the given type with the given initial properties.
|
|
87 GraphEdge connect(string edge_type, /* initial properties, */
|
|
88 GraphElement sourceElement, Point sourcePoint,
|
|
89 GraphElement targetElement, Point targetPoint);
|
|
90
|
|
91 // Attempt to really reroute..
|
|
92 void reroute(GraphEdge edge, EdgeEnd end,
|
|
93 GraphElement oldElement,
|
|
94 GraphElement newElement, Point newPoint);
|
|
95
|
|
96 // Attempt to really remove an edge...
|
|
97 void disconnect(GraphEdge edge);
|
|
98 }
|