Mercurial > hg > ccmieditor
comparison 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 |
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 a node subtree representing an edge connecting | |
24 * that node with another node. | |
25 * | |
26 */ | |
27 @SuppressWarnings("serial") | |
28 public class EdgeReferenceMutableTreeNode extends DiagramModelTreeNode { | |
29 public EdgeReferenceMutableTreeNode(DiagramEdge edge, DiagramNode node){ | |
30 super(); | |
31 this.edge = edge; | |
32 this.node = node; | |
33 } | |
34 | |
35 @Override | |
36 public String toString(){ | |
37 final String and = " and "; | |
38 StringBuilder b = new StringBuilder(); | |
39 b.append("to "); | |
40 for(int i=0;i<edge.getNodesNum();i++){ | |
41 DiagramNode n = edge.getNodeAt(i); | |
42 if(!n.equals(node)) | |
43 b.append(n.getName()).append(and); | |
44 } | |
45 // remove the last " and " | |
46 b.delete(b.length()-and.length(), b.length()); | |
47 b.append(", via "); | |
48 b.append(edge.getName()); | |
49 super.setUserObject(b.toString()); | |
50 return super.toString(); | |
51 } | |
52 | |
53 @Override | |
54 public String getName(){ | |
55 return toString(); | |
56 } | |
57 | |
58 /** | |
59 * Return a String representing this object for this tree node in a way more suitable | |
60 * for a text to speech synthesizer to read, than toString(). | |
61 * @return a String suitable for text to speech synthesis | |
62 */ | |
63 @Override | |
64 public String spokenText(){ | |
65 toString(); | |
66 return super.spokenText(); | |
67 } | |
68 | |
69 /** | |
70 * Returns the diagram edge that this tree node represents inside the node subtree | |
71 * @return a reference to the actual edge | |
72 */ | |
73 public DiagramEdge getEdge(){ | |
74 return edge; | |
75 } | |
76 | |
77 /** | |
78 * Returns the node containing this tree node in its subtree. Notice that | |
79 * diagram nodes are DiagrammodelTreeNode as well. | |
80 * @return a reference to the diagram node | |
81 */ | |
82 public DiagramNode getNode(){ | |
83 return node; | |
84 } | |
85 | |
86 private DiagramEdge edge; | |
87 private DiagramNode node; | |
88 } |