Mercurial > hg > ccmieditor
view java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/NodeReferenceMutableTreeNode.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 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; /** * * The diagramModeltreeNode placed in an edge subtree representing a node connected * by the edge itself. * */ @SuppressWarnings("serial") public class NodeReferenceMutableTreeNode extends DiagramModelTreeNode { public NodeReferenceMutableTreeNode(DiagramNode node, DiagramEdge edge){ super(); this.node = node; this.edge = edge; } @Override public String toString(){ StringBuilder b = new StringBuilder(); if(edge.getEndDescription(node) != null){ b.append(' '); b.append(edge.getEndDescription(node)); b.append(' '); } b.append(node.getName()); b.append(' '); if(edge.getEndLabel(node) != null){ b.append(edge.getEndLabel(node)); } /* set the user object so that superclass toString can be called, which * decorates the string with notes and bookmarks */ setUserObject(b.toString()); return super.toString(); } /** * returns the tree node name "as it is", without any decoration such as notes, bookmarks or cardinality. * Unlike the String returned by toString * @return the tree node name */ @Override public String getName(){ return node.getName(); } /** * Returns 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 has this node in its subtree. Note that diagram edges * are DiagramModelTreeNodes as well. * @return a reference to the diagram edge */ public DiagramEdge getEdge(){ return edge; } /** * Returns the diagram node that this tree node represents inside the edge subtree * @return a reference to the actual diagram node */ public DiagramNode getNode(){ return node; } private DiagramNode node; private DiagramEdge edge; }