annotate java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/CollectionModel.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 9e67171477bc
children
rev   line source
fiore@0 1 /*
fiore@0 2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
fiore@0 3
fiore@0 4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
fiore@0 5
fiore@0 6 This program is free software: you can redistribute it and/or modify
fiore@0 7 it under the terms of the GNU General Public License as published by
fiore@0 8 the Free Software Foundation, either version 3 of the License, or
fiore@0 9 (at your option) any later version.
fiore@0 10
fiore@0 11 This program is distributed in the hope that it will be useful,
fiore@0 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
fiore@0 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fiore@0 14 GNU General Public License for more details.
fiore@0 15
fiore@0 16 You should have received a copy of the GNU General Public License
fiore@0 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
fiore@0 18 */
fiore@0 19 package uk.ac.qmul.eecs.ccmi.diagrammodel;
fiore@0 20
fiore@0 21 import java.util.Collection;
fiore@3 22 import java.util.concurrent.locks.ReentrantLock;
fiore@0 23
fiore@0 24 import javax.swing.event.ChangeListener;
fiore@0 25
fiore@0 26 /**
fiore@0 27 *
fiore@0 28 * Represents the collection side of a DiagramModel instance.
fiore@0 29 *
fiore@0 30 * @param <N> a type extending DiagramNode
fiore@0 31 * @param <E> a type extending DiagramEdge
fiore@0 32 */
fiore@0 33 public interface CollectionModel<N extends DiagramNode, E extends DiagramEdge> {
fiore@0 34 /**
fiore@0 35 * Adds a collection listener to the model.
fiore@0 36 * @param listener the listener to be added
fiore@0 37 */
fiore@0 38 void addCollectionListener(CollectionListener listener);
fiore@0 39 /**
fiore@0 40 * Removed a collection listener to the model.
fiore@0 41 * @param listener the listener to be removed
fiore@0 42 */
fiore@0 43 void removeCollectionListener (CollectionListener listener);
fiore@0 44
fiore@0 45 /**
fiore@0 46 * insert a DiagramNode into the diagram model
fiore@0 47 * @param n the DiagramNode to be inserted in the collection
fiore@3 48 * @param source the source of the action. This will be reported as the source of the event
fiore@3 49 * generated by this action to the registered listeners. If null the CollectionModel instance
fiore@3 50 * itself will be used as source
fiore@0 51 * @return true if this collection changed as a result of the call
fiore@0 52 */
fiore@3 53 boolean insert(N n, Object source) ;
fiore@0 54
fiore@0 55 /**
fiore@0 56 * insert a DiagramEdge into the diagram model
fiore@0 57 * @param e the DiagramNode to be inserted in the collection
fiore@3 58 * @param source the source of the action. This will be reported as the source of the event
fiore@3 59 * generated by this action to the registered listeners. If null the CollectionModel instance
fiore@3 60 * itself will be used as source
fiore@0 61 * @return true if this collection changed as a result of the call
fiore@0 62 */
fiore@3 63 boolean insert(E e, Object source);
fiore@0 64
fiore@0 65 /**
fiore@0 66 * Removes a DiagramElement from the model
fiore@0 67 * @param e the diagramElement to be removed
fiore@3 68 * @param source the source of the action. This will be reported as the source of the event
fiore@3 69 * generated by this action to the registered listeners. If null the CollectionModel instance
fiore@3 70 * itself will be used as source
fiore@0 71 * @return true if this collection changed as a result of the call
fiore@0 72 */
fiore@3 73 boolean takeOut(DiagramElement e, Object source);
fiore@0 74
fiore@0 75 /**
fiore@3 76 * Returns the diagram nodes contained by the model as a collection
fiore@0 77 * @return the collection of diagram nodes
fiore@0 78 */
fiore@0 79 Collection<N> getNodes();
fiore@0 80
fiore@0 81 /**
fiore@3 82 * Returns the diagram edges contained by the model as a collection
fiore@0 83 * @return the collection of diagram edges
fiore@0 84 */
fiore@0 85 Collection<E> getEdges();
fiore@0 86
fiore@0 87 /**
fiore@0 88 * return a list of nodes and edges in the model as a unique collection
fiore@3 89 * of diagram elements.
fiore@3 90 * @return the collection of diagram elements
fiore@0 91 */
fiore@0 92 Collection<DiagramElement> getElements();
fiore@0 93
fiore@0 94 /**
fiore@0 95 * Add a change listener to the model. the listeners will be fired each time the model
fiore@0 96 * goes from the unmodified to modified state. The model is modified when a either a
fiore@0 97 * node or an edge are inserted or removed or changed when they are within the model.
fiore@0 98 * @param l a ChangeListener to add to the model
fiore@0 99 */
fiore@0 100 void addChangeListener(ChangeListener l);
fiore@0 101
fiore@0 102 /**
fiore@0 103 * Removes a change listener from the model.
fiore@0 104 * @param l a ChangeListener to remove from the model
fiore@0 105 */
fiore@0 106 void removeChangeListener(ChangeListener l);
fiore@0 107
fiore@0 108 /**
fiore@0 109 * Returns true if the model has been modified
fiore@0 110 * @return true if the model has been modified
fiore@0 111 */
fiore@0 112 boolean isModified();
fiore@0 113
fiore@0 114 /**
fiore@0 115 * Sets the model as unmodified. This entails that {@link #isModified()} will return
fiore@0 116 * false unless the model doesn't get modified again. After this call a new modification
fiore@0 117 * of the model would trigger the associated change listeners again.
fiore@0 118 */
fiore@0 119 void setUnmodified();
fiore@0 120
fiore@0 121 /**
fiore@0 122 * Sorts the nodes and edges is the model. The ordering method is given by a diagram
fiore@0 123 * element comparator.
fiore@0 124 * @see DiagramElementComparator
fiore@0 125 */
fiore@0 126 void sort();
fiore@0 127
fiore@0 128 /**
fiore@3 129 * Returns a reentrant lock that can be used to access the nodes and edges via {@code getNodes()}
fiore@3 130 * and {@code getEdges()} and the change methods in a synchronized fashion.
fiore@3 131 * @return a lock object
fiore@0 132 */
fiore@3 133 ReentrantLock getMonitor();
fiore@0 134
fiore@0 135 }