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
|
|
25 void edgeAdded(GraphEdge node,
|
|
26 GraphConnector anchor1, GraphConnector anchor2);
|
|
27 void edgeChanged(GraphEdge edge);
|
|
28 void edgeRerouted();
|
|
29 void edgeRemoved();
|
|
30 }
|
|
31
|
|
32 interface INetwork {
|
|
33 void addObserver(INetworkObserver observer);
|
|
34 void removeObserver(INetworkObserver observer);
|
|
35
|
|
36 //
|
|
37 // Interrogation:
|
|
38 //
|
|
39
|
|
40 GraphNode[] getRootNodes();
|
|
41
|
|
42 // Inquire whether in principle a node of node_type
|
|
43 // can be added at the given point, possibly nested
|
|
44 // within the nest node. The nest can be null.
|
|
45 bool canAdd(string node_type,
|
|
46 Point point, // necessary?
|
|
47 GraphNode nest);
|
|
48
|
|
49 bool canRelocate(GraphNode node);
|
|
50
|
|
51 bool canRemove(GraphNode node);
|
|
52
|
|
53 // Inquire whether in principle the source element can
|
|
54 // be connected to the target element using
|
|
55 // an edge of edge_type. This might return true even
|
|
56 // though the real operation would fail due to deeper checking.
|
|
57 bool canConnect(char[] edge_type,
|
|
58 GraphElement sourceElement, Point sourcePoint,
|
|
59 GraphElement targetElement, Point targetPoint);
|
|
60
|
|
61 // Inquire whether in principle a given end of an existing edge
|
|
62 // can be rerouted from old_element to new_element at new_point.
|
|
63 // old_element and new_element may be the same element.
|
|
64 bool canReroute(GraphEdge edge, EdgeEnd end,
|
|
65 GraphElement oldElement,
|
|
66 GraphElement newElement, Point newPoint);
|
|
67
|
|
68 bool canDisconnect(GraphEdge edge);
|
|
69
|
|
70 //
|
|
71 // Manipulation:
|
|
72 //
|
|
73
|
|
74 // Attempt to really add a node...
|
|
75 GraphNode add(char[] node_type, /* initial properties, */
|
|
76 Point point,
|
|
77 GraphNode nest);
|
|
78
|
|
79 void relocate(GraphNode node,
|
|
80 GraphElement oldContainer,
|
|
81 GraphElement newContainer, Point newPoint);
|
|
82
|
|
83 // Attempt to really remove a node
|
|
84 void remove(GraphNode node);
|
|
85
|
|
86 // Attempt to really connect the source element to the target element
|
|
87 // using an edge of the given type with the given initial properties.
|
|
88 GraphEdge connect(string edge_type, /* initial properties, */
|
|
89 GraphElement sourceElement, Point sourcePoint,
|
|
90 GraphElement targetElement, Point targetPoint);
|
|
91
|
|
92 // Attempt to really reroute..
|
|
93 void reroute(GraphEdge edge, EdgeEnd end,
|
|
94 GraphElement oldElement,
|
|
95 GraphElement newElement, Point newPoint);
|
|
96
|
|
97 // Attempt to really remove an edge...
|
|
98 void disconnect(GraphEdge edge);
|
|
99 }
|