comparison java/src/uk/ac/qmul/eecs/ccmi/gui/DiagramModelUpdater.java @ 3:9e67171477bc

PHANTOM Omni Heptic device release
author Fiore Martin <fiore@eecs.qmul.ac.uk>
date Wed, 25 Apr 2012 17:09:09 +0100
parents 9418ab7b7f3f
children d66dd5880081
comparison
equal deleted inserted replaced
2:4b2f975e35fa 3:9e67171477bc
20 20
21 import java.awt.geom.Point2D; 21 import java.awt.geom.Point2D;
22 import java.util.Set; 22 import java.util.Set;
23 23
24 import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramElement; 24 import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramElement;
25 import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramModelTreeNode; 25 import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramTreeNode;
26 import uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties; 26 import uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties;
27 import uk.ac.qmul.eecs.ccmi.network.AwarenessMessage;
28 import uk.ac.qmul.eecs.ccmi.network.DiagramEventActionSource;
29 import uk.ac.qmul.eecs.ccmi.network.NetDiagram;
27 30
28 /** 31 /**
29 * 32 *
30 * The DiagramModelUpdater class is used to make changes to the diagram model. The reason why 33 * The DiagramModelUpdater class is used to make changes to the diagram model. The reason why
31 * changes are not made directly to the model is allowing the network-local diagram interchangeability. 34 * changes are not made directly to the model is allowing the network-local diagram interchangeability.
36 * 39 *
37 * @see NetDiagram 40 * @see NetDiagram
38 */ 41 */
39 public interface DiagramModelUpdater { 42 public interface DiagramModelUpdater {
40 43
41 public boolean getLock(DiagramModelTreeNode treeNode, Lock lock); 44 /**
42 45 * Issues a lock request to the server for the specified tree node.
43 public void yieldLock(DiagramModelTreeNode treeNode, Lock lock); 46 *
44 47 * @param treeNode the tree node the lock is being requested for
45 public void insertInCollection(DiagramElement element); 48 * @param lock the type of lock being requested
46 49 * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked
50 * on the lock message, for awareness purposes
51 * @return {@code true} if the lock is successfully granted by the server
52 */
53 public boolean getLock(DiagramTreeNode treeNode, Lock lock, DiagramEventActionSource actionSource);
54
55 /**
56 * Releases a lock previously acquired by this client.
57 *
58 * @param treeNode the tree node the lock is being released for
59 * @param lock the type of lock being released
60 * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked
61 * on the lock message, for awareness purposes.
62 *
63 * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage
64 */
65 public void yieldLock(DiagramTreeNode treeNode, Lock lock ,DiagramEventActionSource actionSource);
66
67 /**
68 * Sends an awareness message to the server.
69 *
70 * @param awMsgName the type of awareness message being sent
71 * @param source the source of the action. Represents informations to be carried on this message.
72 *
73 * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage
74 */
75 public void sendAwarenessMessage(AwarenessMessage.Name awMsgName, Object source);
76
77 /**
78 * Inserts a {@code DiagramElement} in the {@code CollectionModel} of the {@code Diagram} holding this
79 * model updater.
80 *
81 * @param element the element to insert
82 * @param source the source of the insertion action. it can be used by collection listeners.
83 */
84 public void insertInCollection(DiagramElement element,DiagramEventSource source);
85
86 /**
87 * Inserts a {@code DiagramElement} in the {@code TreeModel} of the {@code Diagram} holding this
88 * model updater.
89 *
90 * @param element the element to insert
91 */
47 public void insertInTree(DiagramElement element); 92 public void insertInTree(DiagramElement element);
48 93
49 public void takeOutFromCollection(DiagramElement element); 94 /**
50 95 * Removes an element from the {@code CollectionModel} of the {@code Diagram} holding this
96 * model updater.
97 *
98 * @param element the element to remove
99 * @param source the source of the insertion action. it can be used by collection listeners.
100 */
101 public void takeOutFromCollection(DiagramElement element,DiagramEventSource source);
102
103 /**
104 * Removes an element from the {@code TreeModel} of the {@code Diagram} holding this
105 * model updater.
106 *
107 * @param element the element to remove
108 */
51 public void takeOutFromTree(DiagramElement element); 109 public void takeOutFromTree(DiagramElement element);
52 110
53 public void setName(DiagramElement element, String name); 111 /**
54 112 * Sets a new name for the element of the {@code Diagram} holding this
55 public void setProperty(Node node, String type, int index, String value); 113 * model updater.
56 114 *
57 public void setProperties(Node node, NodeProperties properties); 115 * @param element the element being renamed
58 116 * @param name the new name
59 public void clearProperties(Node node); 117 * @param source the source of the removal action. it can be used by collection listeners.
60 118 */
61 public void setNotes(DiagramModelTreeNode treeNode, String notes); 119 public void setName(DiagramElement element, String name,DiagramEventSource source);
62 120
63 public void addProperty(Node node, String type, String value); 121 /**
64 122 * Sets to a new value a property of a node of the {@code Diagram} holding this
65 public void removeProperty(Node node, String type, int index); 123 * model updater.
66 124 *
67 public void setModifiers(Node node, String type, int index, Set<Integer> modifiers); 125 * @param node the node being set a new property
68 126 * @param type the type of the new property
69 public void setEndLabel(Edge edge, Node node, String label); 127 * @param index the index of the property being set a new value
70 128 * @param value the new value for the property
71 public void setEndDescription(Edge edge, Node node, int i);// String description); 129 * @param source source the source of the {@code setName} action. it can be used by collection listeners.
72 130 */
73 public void translate(GraphElement ge, Point2D p, double x, double y); 131 public void setProperty(Node node, String type, int index, String value,DiagramEventSource source);
74 132
75 public void startMove(GraphElement ge, Point2D p); 133 /**
76 134 * Replace the whole {@code NodeProperties} object of a node of the {@code Diagram} holding this
77 public void bend(Edge edge, Point2D p); 135 * model updater with a new one.
78 136 *
79 public void stopMove(GraphElement ge); 137 * @param node the node being set a new {@code NodeProperties} instance
138 * @param properties the new {@code NodeProperties} instance
139 * @param source source the source of the {@code setProperty} action. it can be used by collection listeners.
140 */
141 public void setProperties(Node node, NodeProperties properties,DiagramEventSource source);
142
143 /**
144 * Clears the properties of a node of the {@code Diagram} holding this
145 * model updater.
146 *
147 * @param node the node whose properties are being cleared
148 * @param source the source of the {@code setProperties} action. it can be used by collection listeners.
149 *
150 * @see uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties#clear()
151 */
152 public void clearProperties(Node node,DiagramEventSource source);
153
154 /**
155 * Set the notes for a tree node of the {@code Diagram} holding this
156 * model updater.
157 *
158 * @param treeNode the tree node whose notes are being set
159 * @param notes the new notes
160 * @param source the source of the {@code setNotes} action. it can be used by collection listeners.
161 */
162 public void setNotes(DiagramTreeNode treeNode, String notes,DiagramEventSource source);
163
164 /**
165 * Add a new property to a node's properties of the {@code Diagram} holding this
166 * model updater.
167 *
168 * @param node the node whose properties are being added to
169 * @param type the type of the new property being added
170 * @param value the value of the new property being added
171 * @param source the source of the {@code setProperty} action. it can be used by collection listeners.
172 */
173 public void addProperty(Node node, String type, String value,DiagramEventSource source);
174
175 /**
176 * Removes a property from a node's properties of the {@code Diagram} holding this
177 * model updater.
178 *
179 * @param node the node whose properties are being removed from
180 * @param type the type of the new property being removed
181 * @param index the index of the property being removed
182 * @param source the source of the {@code removeProperty} action. it can be used by collection listeners.
183 */
184 public void removeProperty(Node node, String type, int index,DiagramEventSource source);
185
186 /**
187 * Set the modifiers for a property of a node in of the {@code Diagram} holding this
188 * model updater.
189 *
190 * @param node the node whose properties whose modifiers are being
191 * @param type the type of the property whose modifiers are being set
192 * @param index the index of the property whose modifiers are being set
193 * @param modifiers the new modifiers indexes. the indexes refer to the modifiers type array.
194 * @param source the source of the {@code setModifiers} action. it can be used by collection listeners.
195 */
196 public void setModifiers(Node node, String type, int index, Set<Integer> modifiers,DiagramEventSource source);
197
198 /**
199 * Set the end label for an edge of the {@code Diagram} holding this
200 * model updater.
201 *
202 * @param edge the edge whose label is being set
203 * @param node the node at the edge end where the label is being set
204 * @param label the new label
205 * @param source the source of the {@code setLabel} action. it can be used by collection listeners.
206 */
207 public void setEndLabel(Edge edge, Node node, String label,DiagramEventSource source);
208
209 /**
210 * Set the end description for an edge of the {@code Diagram} holding this
211 * model updater.
212 *
213 * @param edge the edge whose end description is being set
214 * @param node the node at the edge end where the end description is being set
215 * @param index the index of the new end description in the end description array of {@code edge}
216 * @param source the source of the {@code setEndDescription} action. it can be used by collection listeners.
217 */
218 public void setEndDescription(Edge edge, Node node, int index, DiagramEventSource source);
219
220 /**
221 * Translates a graph element of the {@code Diagram} holding this
222 * model updater.
223 *
224 * @param ge the graph element being translated
225 * @param p the starting point of the translation
226 * @param x the distance to translate along the x-axis
227 * @param y the distance to translate along the y-axis
228 * @param source the source of the {@code translate} action. it can be used by collection listeners.
229 */
230 public void translate(GraphElement ge, Point2D p, double x, double y,DiagramEventSource source);
231
232 /**
233 * Starts the move for a graph element of the {@code Diagram} holding this
234 * model updater. The move can be either a translation or a bend (if {@code ge} is an Edge).
235 * This method must be called before such motion methods are called in turn.
236 *
237 * @param ge the graph element being translated
238 * @param p the starting point of the motion
239 * @param source the source of the {@code startMove} action. it can be used by collection listeners.
240 */
241 public void startMove(GraphElement ge, Point2D p, DiagramEventSource source);
242
243 /**
244 * Bends an edge of the {@code Diagram} holding this model updater.
245 *
246 * @param edge the edge being bended
247 * @param p the starting point of the motion
248 * @param source the source of the {@code bend} action. it can be used by collection listeners.
249 */
250 public void bend(Edge edge, Point2D p,DiagramEventSource source);
251
252 /**
253 * Finishes off the motion of a graph element of the {@code Diagram} holding this
254 * model updater.
255 *
256 * @param ge the graph element being moved
257 * @param sourcethe source of the {@code stopMove} action. it can be used by collection listeners.
258 */
259 public void stopMove(GraphElement ge,DiagramEventSource source);
80 } 260 }