Mercurial > hg > ccmieditor
diff java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/EdgeReferenceMutableTreeNode.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/EdgeReferenceMutableTreeNode.java Fri Dec 16 17:35:51 2011 +0000 @@ -0,0 +1,88 @@ +/* + 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; + +/** + * + * The diagramModeltreeNode placed in a node subtree representing an edge connecting + * that node with another node. + * + */ +@SuppressWarnings("serial") +public class EdgeReferenceMutableTreeNode extends DiagramModelTreeNode { + public EdgeReferenceMutableTreeNode(DiagramEdge edge, DiagramNode node){ + super(); + this.edge = edge; + this.node = node; + } + + @Override + public String toString(){ + final String and = " and "; + StringBuilder b = new StringBuilder(); + b.append("to "); + for(int i=0;i<edge.getNodesNum();i++){ + DiagramNode n = edge.getNodeAt(i); + if(!n.equals(node)) + b.append(n.getName()).append(and); + } + // remove the last " and " + b.delete(b.length()-and.length(), b.length()); + b.append(", via "); + b.append(edge.getName()); + super.setUserObject(b.toString()); + return super.toString(); + } + + @Override + public String getName(){ + return toString(); + } + + /** + * Return a String representing this object for this tree node in a way more suitable + * for a text to speech synthesizer to read, than toString(). + * @return a String suitable for text to speech synthesis + */ + @Override + public String spokenText(){ + toString(); + return super.spokenText(); + } + + /** + * Returns the diagram edge that this tree node represents inside the node subtree + * @return a reference to the actual edge + */ + public DiagramEdge getEdge(){ + return edge; + } + + /** + * Returns the node containing this tree node in its subtree. Notice that + * diagram nodes are DiagrammodelTreeNode as well. + * @return a reference to the diagram node + */ + public DiagramNode getNode(){ + return node; + } + + private DiagramEdge edge; + private DiagramNode node; +}