fiore@0: /* fiore@0: CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool fiore@0: fiore@0: Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/) fiore@0: fiore@0: This program is free software: you can redistribute it and/or modify fiore@0: it under the terms of the GNU General Public License as published by fiore@0: the Free Software Foundation, either version 3 of the License, or fiore@0: (at your option) any later version. fiore@0: fiore@0: This program is distributed in the hope that it will be useful, fiore@0: but WITHOUT ANY WARRANTY; without even the implied warranty of fiore@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fiore@0: GNU General Public License for more details. fiore@0: fiore@0: You should have received a copy of the GNU General Public License fiore@0: along with this program. If not, see . fiore@0: */ fiore@0: package uk.ac.qmul.eecs.ccmi.gui; fiore@0: fiore@0: import java.awt.geom.Point2D; fiore@0: import java.util.Set; fiore@0: fiore@0: import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramElement; fiore@3: import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramTreeNode; fiore@0: import uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties; fiore@3: import uk.ac.qmul.eecs.ccmi.network.AwarenessMessage; fiore@3: import uk.ac.qmul.eecs.ccmi.network.DiagramEventActionSource; fiore@3: import uk.ac.qmul.eecs.ccmi.network.NetDiagram; fiore@0: fiore@0: /** fiore@0: * fiore@0: * The DiagramModelUpdater class is used to make changes to the diagram model. The reason why fiore@0: * changes are not made directly to the model is allowing the network-local diagram interchangeability. fiore@0: * A NetDiagram differs from a local fiore@0: * diagram only by its DiagramModelUpdater implementation. The rest of the operations are fiore@0: * performed through the delegate local diagram which is passed as argument to the constructor. fiore@0: * In this way a local diagram can be easily turned into a network diagram and vice versa. fiore@0: * fiore@0: * @see NetDiagram fiore@0: */ fiore@0: public interface DiagramModelUpdater { fiore@0: fiore@3: /** fiore@3: * Issues a lock request to the server for the specified tree node. fiore@3: * fiore@3: * @param treeNode the tree node the lock is being requested for fiore@3: * @param lock the type of lock being requested fiore@3: * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked fiore@3: * on the lock message, for awareness purposes fiore@3: * @return {@code true} if the lock is successfully granted by the server fiore@3: */ fiore@3: public boolean getLock(DiagramTreeNode treeNode, Lock lock, DiagramEventActionSource actionSource); fiore@0: fiore@3: /** fiore@3: * Releases a lock previously acquired by this client. fiore@3: * fiore@3: * @param treeNode the tree node the lock is being released for fiore@3: * @param lock the type of lock being released fiore@3: * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked fiore@3: * on the lock message, for awareness purposes. fiore@3: * fiore@3: * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage fiore@3: */ fiore@3: public void yieldLock(DiagramTreeNode treeNode, Lock lock ,DiagramEventActionSource actionSource); fiore@0: fiore@3: /** fiore@3: * Sends an awareness message to the server. fiore@3: * fiore@3: * @param awMsgName the type of awareness message being sent fiore@3: * @param source the source of the action. Represents informations to be carried on this message. fiore@3: * fiore@3: * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage fiore@3: */ fiore@3: public void sendAwarenessMessage(AwarenessMessage.Name awMsgName, Object source); fiore@0: fiore@3: /** fiore@3: * Inserts a {@code DiagramElement} in the {@code CollectionModel} of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param element the element to insert fiore@3: * @param source the source of the insertion action. it can be used by collection listeners. fiore@3: */ fiore@3: public void insertInCollection(DiagramElement element,DiagramEventSource source); fiore@3: fiore@3: /** fiore@3: * Inserts a {@code DiagramElement} in the {@code TreeModel} of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param element the element to insert fiore@3: */ fiore@0: public void insertInTree(DiagramElement element); fiore@0: fiore@3: /** fiore@3: * Removes an element from the {@code CollectionModel} of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param element the element to remove fiore@3: * @param source the source of the insertion action. it can be used by collection listeners. fiore@3: */ fiore@3: public void takeOutFromCollection(DiagramElement element,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Removes an element from the {@code TreeModel} of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param element the element to remove fiore@3: */ fiore@0: public void takeOutFromTree(DiagramElement element); fiore@0: fiore@3: /** fiore@3: * Sets a new name for the element of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param element the element being renamed fiore@3: * @param name the new name fiore@3: * @param source the source of the removal action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setName(DiagramElement element, String name,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Sets to a new value a property of a node of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param node the node being set a new property fiore@3: * @param type the type of the new property fiore@3: * @param index the index of the property being set a new value fiore@3: * @param value the new value for the property fiore@3: * @param source source the source of the {@code setName} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setProperty(Node node, String type, int index, String value,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Replace the whole {@code NodeProperties} object of a node of the {@code Diagram} holding this fiore@3: * model updater with a new one. fiore@3: * fiore@3: * @param node the node being set a new {@code NodeProperties} instance fiore@3: * @param properties the new {@code NodeProperties} instance fiore@3: * @param source source the source of the {@code setProperty} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setProperties(Node node, NodeProperties properties,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Clears the properties of a node of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param node the node whose properties are being cleared fiore@3: * @param source the source of the {@code setProperties} action. it can be used by collection listeners. fiore@3: * fiore@3: * @see uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties#clear() fiore@3: */ fiore@3: public void clearProperties(Node node,DiagramEventSource source); fiore@3: fiore@3: /** fiore@3: * Set the notes for a tree node of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param treeNode the tree node whose notes are being set fiore@3: * @param notes the new notes fiore@3: * @param source the source of the {@code setNotes} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setNotes(DiagramTreeNode treeNode, String notes,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Add a new property to a node's properties of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param node the node whose properties are being added to fiore@3: * @param type the type of the new property being added fiore@3: * @param value the value of the new property being added fiore@3: * @param source the source of the {@code setProperty} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void addProperty(Node node, String type, String value,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Removes a property from a node's properties of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param node the node whose properties are being removed from fiore@3: * @param type the type of the new property being removed fiore@3: * @param index the index of the property being removed fiore@3: * @param source the source of the {@code removeProperty} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void removeProperty(Node node, String type, int index,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Set the modifiers for a property of a node in of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param node the node whose properties whose modifiers are being fiore@3: * @param type the type of the property whose modifiers are being set fiore@3: * @param index the index of the property whose modifiers are being set fiore@3: * @param modifiers the new modifiers indexes. the indexes refer to the modifiers type array. fiore@3: * @param source the source of the {@code setModifiers} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setModifiers(Node node, String type, int index, Set modifiers,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Set the end label for an edge of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param edge the edge whose label is being set fiore@3: * @param node the node at the edge end where the label is being set fiore@3: * @param label the new label fiore@3: * @param source the source of the {@code setLabel} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setEndLabel(Edge edge, Node node, String label,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Set the end description for an edge of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param edge the edge whose end description is being set fiore@3: * @param node the node at the edge end where the end description is being set fiore@3: * @param index the index of the new end description in the end description array of {@code edge} fiore@3: * @param source the source of the {@code setEndDescription} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void setEndDescription(Edge edge, Node node, int index, DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Translates a graph element of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param ge the graph element being translated fiore@3: * @param p the starting point of the translation fiore@3: * @param x the distance to translate along the x-axis fiore@3: * @param y the distance to translate along the y-axis fiore@3: * @param source the source of the {@code translate} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void translate(GraphElement ge, Point2D p, double x, double y,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Starts the move for a graph element of the {@code Diagram} holding this fiore@3: * model updater. The move can be either a translation or a bend (if {@code ge} is an Edge). fiore@3: * This method must be called before such motion methods are called in turn. fiore@3: * fiore@3: * @param ge the graph element being translated fiore@3: * @param p the starting point of the motion fiore@3: * @param source the source of the {@code startMove} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void startMove(GraphElement ge, Point2D p, DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Bends an edge of the {@code Diagram} holding this model updater. fiore@3: * fiore@3: * @param edge the edge being bended fiore@3: * @param p the starting point of the motion fiore@3: * @param source the source of the {@code bend} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void bend(Edge edge, Point2D p,DiagramEventSource source); fiore@0: fiore@3: /** fiore@3: * Finishes off the motion of a graph element of the {@code Diagram} holding this fiore@3: * model updater. fiore@3: * fiore@3: * @param ge the graph element being moved fiore@5: * @param source the source of the {@code stopMove} action. it can be used by collection listeners. fiore@3: */ fiore@3: public void stopMove(GraphElement ge,DiagramEventSource source); fiore@0: }