annotate java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/CollectionModel.java @ 0:9418ab7b7f3f

Initial import
author Fiore Martin <fiore@eecs.qmul.ac.uk>
date Fri, 16 Dec 2011 17:35:51 +0000
parents
children 9e67171477bc
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@0 22
fiore@0 23 import javax.swing.event.ChangeListener;
fiore@0 24
fiore@0 25 /**
fiore@0 26 *
fiore@0 27 * Represents the collection side of a DiagramModel instance.
fiore@0 28 *
fiore@0 29 * @param <N> a type extending DiagramNode
fiore@0 30 * @param <E> a type extending DiagramEdge
fiore@0 31 */
fiore@0 32 public interface CollectionModel<N extends DiagramNode, E extends DiagramEdge> {
fiore@0 33 /**
fiore@0 34 * Adds a collection listener to the model.
fiore@0 35 * @param listener the listener to be added
fiore@0 36 */
fiore@0 37 void addCollectionListener(CollectionListener listener);
fiore@0 38 /**
fiore@0 39 * Removed a collection listener to the model.
fiore@0 40 * @param listener the listener to be removed
fiore@0 41 */
fiore@0 42 void removeCollectionListener (CollectionListener listener);
fiore@0 43
fiore@0 44 /**
fiore@0 45 * insert a DiagramNode into the diagram model
fiore@0 46 * @param n the DiagramNode to be inserted in the collection
fiore@0 47 * @return true if this collection changed as a result of the call
fiore@0 48 */
fiore@0 49 boolean insert(N n) ;
fiore@0 50
fiore@0 51 /**
fiore@0 52 * insert a DiagramEdge into the diagram model
fiore@0 53 * @param e the DiagramNode to be inserted in the collection
fiore@0 54 * @return true if this collection changed as a result of the call
fiore@0 55 */
fiore@0 56 boolean insert(E e);
fiore@0 57
fiore@0 58 /**
fiore@0 59 * Removes a DiagramElement from the model
fiore@0 60 * @param e the diagramElement to be removed
fiore@0 61 * @return true if this collection changed as a result of the call
fiore@0 62 */
fiore@0 63 boolean takeOut(DiagramElement e);
fiore@0 64
fiore@0 65 /**
fiore@0 66 * Returns the diagram nodes contained by the model as a Collection
fiore@0 67 * @return the collection of diagram nodes
fiore@0 68 */
fiore@0 69 Collection<N> getNodes();
fiore@0 70
fiore@0 71 /**
fiore@0 72 * Returns the diagram edges contained by the model as a Collection
fiore@0 73 * @return the collection of diagram edges
fiore@0 74 */
fiore@0 75 Collection<E> getEdges();
fiore@0 76
fiore@0 77 /**
fiore@0 78 * return a list of nodes and edges in the model as a unique collection
fiore@0 79 * of Diagram elements.
fiore@0 80 * @return
fiore@0 81 */
fiore@0 82 Collection<DiagramElement> getElements();
fiore@0 83
fiore@0 84 /**
fiore@0 85 * Add a change listener to the model. the listeners will be fired each time the model
fiore@0 86 * goes from the unmodified to modified state. The model is modified when a either a
fiore@0 87 * node or an edge are inserted or removed or changed when they are within the model.
fiore@0 88 * @param l a ChangeListener to add to the model
fiore@0 89 */
fiore@0 90 void addChangeListener(ChangeListener l);
fiore@0 91
fiore@0 92 /**
fiore@0 93 * Removes a change listener from the model.
fiore@0 94 * @param l a ChangeListener to remove from the model
fiore@0 95 */
fiore@0 96 void removeChangeListener(ChangeListener l);
fiore@0 97
fiore@0 98 /**
fiore@0 99 * Returns true if the model has been modified
fiore@0 100 * @return true if the model has been modified
fiore@0 101 */
fiore@0 102 boolean isModified();
fiore@0 103
fiore@0 104 /**
fiore@0 105 * Sets the model as unmodified. This entails that {@link #isModified()} will return
fiore@0 106 * false unless the model doesn't get modified again. After this call a new modification
fiore@0 107 * of the model would trigger the associated change listeners again.
fiore@0 108 */
fiore@0 109 void setUnmodified();
fiore@0 110
fiore@0 111 /**
fiore@0 112 * Sorts the nodes and edges is the model. The ordering method is given by a diagram
fiore@0 113 * element comparator.
fiore@0 114 * @see DiagramElementComparator
fiore@0 115 */
fiore@0 116 void sort();
fiore@0 117
fiore@0 118 /**
fiore@0 119 * Returns an object that can be used to access the nodes and edges (via {@link #getNodes()}
fiore@0 120 * and {@link #getEdges()} in a synchronized block. The monitor is guaranteed to give
fiore@0 121 * exclusive access even in regards to the access via the tree side of the model.
fiore@0 122 * @return
fiore@0 123 */
fiore@0 124 Object getMonitor();
fiore@0 125
fiore@0 126 }