Mercurial > hg > ccmieditor
view 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 |
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.diagrammodel; import java.util.Collection; import java.util.concurrent.locks.ReentrantLock; import javax.swing.event.ChangeListener; /** * * Represents the collection side of a DiagramModel instance. * * @param <N> a type extending DiagramNode * @param <E> a type extending DiagramEdge */ public interface CollectionModel<N extends DiagramNode, E extends DiagramEdge> { /** * Adds a collection listener to the model. * @param listener the listener to be added */ void addCollectionListener(CollectionListener listener); /** * Removed a collection listener to the model. * @param listener the listener to be removed */ void removeCollectionListener (CollectionListener listener); /** * insert a DiagramNode into the diagram model * @param n the DiagramNode to be inserted in the collection * @param source the source of the action. This will be reported as the source of the event * generated by this action to the registered listeners. If null the CollectionModel instance * itself will be used as source * @return true if this collection changed as a result of the call */ boolean insert(N n, Object source) ; /** * insert a DiagramEdge into the diagram model * @param e the DiagramNode to be inserted in the collection * @param source the source of the action. This will be reported as the source of the event * generated by this action to the registered listeners. If null the CollectionModel instance * itself will be used as source * @return true if this collection changed as a result of the call */ boolean insert(E e, Object source); /** * Removes a DiagramElement from the model * @param e the diagramElement to be removed * @param source the source of the action. This will be reported as the source of the event * generated by this action to the registered listeners. If null the CollectionModel instance * itself will be used as source * @return true if this collection changed as a result of the call */ boolean takeOut(DiagramElement e, Object source); /** * Returns the diagram nodes contained by the model as a collection * @return the collection of diagram nodes */ Collection<N> getNodes(); /** * Returns the diagram edges contained by the model as a collection * @return the collection of diagram edges */ Collection<E> getEdges(); /** * return a list of nodes and edges in the model as a unique collection * of diagram elements. * @return the collection of diagram elements */ Collection<DiagramElement> getElements(); /** * Add a change listener to the model. the listeners will be fired each time the model * goes from the unmodified to modified state. The model is modified when a either a * node or an edge are inserted or removed or changed when they are within the model. * @param l a ChangeListener to add to the model */ void addChangeListener(ChangeListener l); /** * Removes a change listener from the model. * @param l a ChangeListener to remove from the model */ void removeChangeListener(ChangeListener l); /** * Returns true if the model has been modified * @return true if the model has been modified */ boolean isModified(); /** * Sets the model as unmodified. This entails that {@link #isModified()} will return * false unless the model doesn't get modified again. After this call a new modification * of the model would trigger the associated change listeners again. */ void setUnmodified(); /** * Sorts the nodes and edges is the model. The ordering method is given by a diagram * element comparator. * @see DiagramElementComparator */ void sort(); /** * Returns a reentrant lock that can be used to access the nodes and edges via {@code getNodes()} * and {@code getEdges()} and the change methods in a synchronized fashion. * @return a lock object */ ReentrantLock getMonitor(); }