comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:9418ab7b7f3f
1 /*
2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
3
4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package uk.ac.qmul.eecs.ccmi.diagrammodel;
20
21 /**
22 *
23 * The diagramModeltreeNode placed in an edge subtree representing a node connected
24 * by the edge itself.
25 *
26 */
27
28 @SuppressWarnings("serial")
29 public class NodeReferenceMutableTreeNode extends DiagramModelTreeNode {
30 public NodeReferenceMutableTreeNode(DiagramNode node, DiagramEdge edge){
31 super();
32 this.node = node;
33 this.edge = edge;
34 }
35
36
37 @Override
38 public String toString(){
39 StringBuilder b = new StringBuilder();
40 if(edge.getEndDescription(node) != null){
41 b.append(' ');
42 b.append(edge.getEndDescription(node));
43 b.append(' ');
44 }
45 b.append(node.getName());
46 b.append(' ');
47 if(edge.getEndLabel(node) != null){
48 b.append(edge.getEndLabel(node));
49 }
50 /* set the user object so that superclass toString can be called, which
51 * decorates the string with notes and bookmarks
52 */
53 setUserObject(b.toString());
54 return super.toString();
55 }
56
57 /**
58 * returns the tree node name "as it is", without any decoration such as notes, bookmarks or cardinality.
59 * Unlike the String returned by toString
60 * @return the tree node name
61 */
62 @Override
63 public String getName(){
64 return node.getName();
65 }
66
67 /**
68 * Returns a String representing this object for this tree node in a way more suitable
69 * for a text to speech synthesizer to read, than toString().
70 * @return a String suitable for text to speech synthesis
71 */
72 @Override
73 public String spokenText(){
74 toString();
75 return super.spokenText();
76 }
77
78 /**
79 * Returns the diagram edge that has this node in its subtree. Note that diagram edges
80 * are DiagramModelTreeNodes as well.
81 * @return a reference to the diagram edge
82 */
83 public DiagramEdge getEdge(){
84 return edge;
85 }
86
87 /**
88 * Returns the diagram node that this tree node represents inside the edge subtree
89 * @return a reference to the actual diagram node
90 */
91 public DiagramNode getNode(){
92 return node;
93 }
94
95 private DiagramNode node;
96 private DiagramEdge edge;
97 }