view java/src/uk/ac/qmul/eecs/ccmi/gui/DiagramModelUpdater.java @ 8:ea7885bd9bff tip

fixed bug : render solid line as dotted/dashed when moving the stylus from dotted/dashed to solid
author ccmi-guest
date Thu, 03 Jul 2014 16:12:20 +0100
parents d66dd5880081
children
line wrap: on
line source
/*  
 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
  
 Copyright (C) 2011  Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.qmul.eecs.ccmi.gui;

import java.awt.geom.Point2D;
import java.util.Set;

import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramElement;
import uk.ac.qmul.eecs.ccmi.diagrammodel.DiagramTreeNode;
import uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties;
import uk.ac.qmul.eecs.ccmi.network.AwarenessMessage;
import uk.ac.qmul.eecs.ccmi.network.DiagramEventActionSource;
import uk.ac.qmul.eecs.ccmi.network.NetDiagram;

/**
 * 
 * The DiagramModelUpdater class is used to make changes to the diagram model. The reason why 
 * changes are not made directly to the model is allowing the network-local diagram interchangeability. 
 * A NetDiagram differs from a local 
 * diagram only by its DiagramModelUpdater implementation. The rest of the operations are 
 * performed through the delegate local diagram which is passed as argument to the constructor.    
 * In this way a local diagram can be easily turned into a network diagram and vice versa.
 *
 * @see NetDiagram
 */
public interface DiagramModelUpdater {
	
	/**
	 * Issues a lock request to the server for the specified tree node.
	 * 
	 * @param treeNode the tree node the lock is being requested for
	 * @param lock the type of lock being requested
	 * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked 
	 *  on the lock message, for awareness purposes 
	 * @return {@code true} if the lock is successfully granted by the server
	 */
	public boolean getLock(DiagramTreeNode treeNode, Lock lock, DiagramEventActionSource actionSource);
	
	/**
	 * Releases a lock previously acquired by this client. 
	 *  
	 * @param treeNode the tree node the lock is being released for
	 * @param lock the type of lock being released
	 * @param actionSource The {@code DiagramEventActionSource} that's going to be piggybacked 
	 *  on the lock message, for awareness purposes.
	 *  
	 * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage
	 */
	public void yieldLock(DiagramTreeNode treeNode, Lock lock ,DiagramEventActionSource actionSource);
	
	/**
	 * Sends an awareness message to the server. 
	 * 
	 * @param awMsgName the type of awareness message being sent 
	 * @param source the source of the action. Represents informations to be carried on this message.
	 * 
	 * @see uk.ac.qmul.eecs.ccmi.network.AwarenessMessage 
	 */
	public void sendAwarenessMessage(AwarenessMessage.Name awMsgName, Object source);
	
	/**
	 * Inserts a {@code DiagramElement} in the {@code CollectionModel} of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param element the element to insert 
	 * @param source the source of the insertion action. it can be used by collection listeners.   
	 */
	public void insertInCollection(DiagramElement element,DiagramEventSource source);
	
	/**
	 * Inserts a {@code DiagramElement} in the {@code TreeModel} of the {@code Diagram} holding this 
	 * model updater.
	 * 
	 * @param element the element to insert 
	 */
	public void insertInTree(DiagramElement element);
	
	/**
	 * Removes an element from the {@code CollectionModel} of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param element the element to remove 
	 * @param source the source of the insertion action. it can be used by collection listeners.   
	 */
	public void takeOutFromCollection(DiagramElement element,DiagramEventSource source);
	
	/**
	 * Removes an element from the {@code TreeModel} of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param element the element to remove 
	 */
	public void takeOutFromTree(DiagramElement element);
	
	/**
	 * Sets a new name for the element of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param element the element being renamed
	 * @param name the new name 
	 * @param source the source of the removal action. it can be used by collection listeners.
	 */
	public void setName(DiagramElement element, String name,DiagramEventSource source);
	
	/**
	 * Sets to a new value a property of a node of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param node the node being set a new property 
	 * @param type the type of the new property 
	 * @param index the index of the property being set a new value  
	 * @param value the new value for the property 
	 * @param source source the source of the {@code setName} action. it can be used by collection listeners.
	 */
	public void setProperty(Node node, String type, int index, String value,DiagramEventSource source);
	
	/**
	 * Replace the whole {@code NodeProperties} object of a node of the {@code Diagram} holding this 
	 * model updater with a new one. 
	 * 
	 * @param node the node being set a new {@code NodeProperties} instance
	 * @param properties the new {@code NodeProperties} instance 
	 * @param source source the source of the {@code setProperty} action. it can be used by collection listeners.
	 */
	public void setProperties(Node node, NodeProperties properties,DiagramEventSource source);
	
	/**
	 * Clears the properties of a node of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param node the node whose properties are being cleared 
	 * @param source the source of the {@code setProperties} action. it can be used by collection listeners.
	 * 
	 * @see uk.ac.qmul.eecs.ccmi.diagrammodel.NodeProperties#clear()
	 */
	public void clearProperties(Node node,DiagramEventSource source);

	/**
	 * Set the notes for a tree node of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param treeNode the tree node whose notes are being set 
	 * @param notes the new notes 
	 * @param source the source of the {@code setNotes} action. it can be used by collection listeners.
	 */
	public void setNotes(DiagramTreeNode treeNode, String notes,DiagramEventSource source);
	
	/**
	 * Add a new property to a node's properties of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param node the node whose properties are being added to 
	 * @param type the type of the new property being added 
	 * @param value the value of the new property being added 
	 * @param source the source of the {@code setProperty} action. it can be used by collection listeners.
	 */
	public void addProperty(Node node, String type, String value,DiagramEventSource source);
	
	/**
	 * Removes a property from a node's properties of the {@code Diagram} holding this 
	 * model updater.  
	 * 
	 * @param node the node whose properties are being removed from
	 * @param type the type of the new property being removed
	 * @param index the index of the property being removed 
	 * @param source the source of the {@code removeProperty} action. it can be used by collection listeners.
	 */
	public void removeProperty(Node node, String type, int index,DiagramEventSource source);
	
	/**
	 * Set the modifiers for a property of a node in of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param node the node whose properties whose modifiers are being 
	 * @param type the type of the property whose modifiers are being set
	 * @param index the index of the property whose modifiers are being set
	 * @param modifiers the new modifiers indexes. the indexes refer to the modifiers type array. 
	 * @param source the source of the {@code setModifiers} action. it can be used by collection listeners.
	 */ 
	public void setModifiers(Node node, String type, int index, Set<Integer> modifiers,DiagramEventSource source);
	
	/**
	 * Set the end label for an edge of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param edge the edge whose label is being set 
	 * @param node the node at the edge end where the label is being set 
	 * @param label the new label 
	 * @param source the source of the {@code setLabel} action. it can be used by collection listeners.
	 */
	public void setEndLabel(Edge edge, Node node, String label,DiagramEventSource source);
	
	/**
	 * Set the end description for an edge of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param edge the edge whose end description is being set 
	 * @param node the node at the edge end where the end description is being set 
	 * @param index the index of the new end description in the end description array of {@code edge}
	 * @param source the source of the {@code setEndDescription} action. it can be used by collection listeners.
	 */
	public void setEndDescription(Edge edge, Node node, int index, DiagramEventSource source);
	
	/**
	 * Translates a graph element of the {@code Diagram} holding this 
	 * model updater. 
	 * 
	 * @param ge the graph element being translated 
	 * @param p the starting point of the translation 
	 * @param x the distance to translate along the x-axis
	 * @param y the distance to translate along the y-axis
	 * @param source the source of the {@code translate} action. it can be used by collection listeners.
	 */
	public void translate(GraphElement ge, Point2D p, double x, double y,DiagramEventSource source);
	
	/**
	 * Starts the move for a graph element of the {@code Diagram} holding this 
	 * model updater. The move can be either a translation or a bend (if {@code ge} is an Edge). 
	 * This method must be called before such motion methods are called in turn.  
	 * 
	 * @param ge the graph element being translated 
	 * @param p the starting point of the motion 
	 * @param source the source of the {@code startMove} action. it can be used by collection listeners.
	 */
	public void startMove(GraphElement ge, Point2D p, DiagramEventSource source);
	
	/**
	 * Bends an edge of the {@code Diagram} holding this  model updater.
	 * 
	 * @param edge the edge being bended 
	 * @param p the starting point of the motion 
	 * @param source the source of the {@code bend} action. it can be used by collection listeners.
	 */
	public void bend(Edge edge, Point2D p,DiagramEventSource source);
	
	/**
	 * Finishes off the motion of a graph element of the {@code Diagram} holding this 
	 * model updater. 
	 *  
	 * @param ge the graph element being moved
	 * @param source the source of the {@code stopMove} action. it can be used by collection listeners.
	 */
	public void stopMove(GraphElement ge,DiagramEventSource source);
}