annotate visualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java @ 4512:015fb895586b

Moved visualizer to new directory.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 07 Feb 2012 22:41:09 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4512
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 */
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 package com.sun.hotspot.igv.graph;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import com.sun.hotspot.igv.data.InputNode;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import com.sun.hotspot.igv.data.Properties;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import com.sun.hotspot.igv.data.Source;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import com.sun.hotspot.igv.layout.Port;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import com.sun.hotspot.igv.layout.Vertex;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.awt.Color;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import java.awt.Font;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 import java.awt.FontMetrics;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 import java.awt.Graphics;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 import java.awt.image.BufferedImage;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 import java.util.ArrayList;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 import java.util.Collections;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 import java.util.Comparator;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 import java.util.List;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 /**
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 *
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 * @author Thomas Wuerthinger
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 */
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 public abstract class Slot implements Port, Source.Provider, Properties.Provider {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 private int wantedIndex;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 private Source source;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 protected List<Connection> connections;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 private InputNode associatedNode;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 private Color color;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 private String text;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 private String shortName;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 private Figure figure;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 protected Slot(Figure figure, int wantedIndex) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 this.figure = figure;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 connections = new ArrayList<>(2);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 source = new Source();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 this.wantedIndex = wantedIndex;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 text = "";
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 shortName = "";
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 assert figure != null;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 @Override
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 public Properties getProperties() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 Properties p = new Properties();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 if (source.getSourceNodes().size() > 0) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 for (InputNode n : source.getSourceNodes()) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 p.add(n.getProperties());
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 } else {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 p.setProperty("name", "Slot");
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 p.setProperty("figure", figure.getProperties().get("name"));
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 p.setProperty("connectionCount", Integer.toString(connections.size()));
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 return p;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 public static final Comparator<Slot> slotIndexComparator = new Comparator<Slot>() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 @Override
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 public int compare(Slot o1, Slot o2) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 return o1.wantedIndex - o2.wantedIndex;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 };
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 public static final Comparator<Slot> slotFigureComparator = new Comparator<Slot>() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 @Override
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 public int compare(Slot o1, Slot o2) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 return o1.figure.getId() - o2.figure.getId();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 };
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 public InputNode getAssociatedNode() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 return associatedNode;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 public void setAssociatedNode(InputNode node) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 associatedNode = node;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 public int getWidth() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 if (shortName == null || shortName.length() <= 1) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 return Figure.SLOT_WIDTH;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 } else {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 Graphics g = image.getGraphics();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 g.setFont(figure.getDiagram().getSlotFont().deriveFont(Font.BOLD));
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 FontMetrics metrics = g.getFontMetrics();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 return Math.max(Figure.SLOT_WIDTH, metrics.stringWidth(shortName) + 6);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 public int getWantedIndex() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 return wantedIndex;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 @Override
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 public Source getSource() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 return source;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 public String getText() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 return text;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 public void setShortName(String s) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 assert s != null;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 // assert s.length() <= 2;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 this.shortName = s;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 public String getShortName() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 return shortName;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 public String getToolTipText() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 StringBuilder sb = new StringBuilder();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 sb.append(text);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 for (InputNode n : getSource().getSourceNodes()) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 sb.append("Node (ID=" + n.getId() + "): " + n.getProperties().get("name"));
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 sb.append("<br>");
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 return sb.toString();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 public boolean shouldShowName() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 return getShortName() != null && getShortName().length() > 0;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 public void setText(String s) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 if (s == null) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 s = "";
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 this.text = s;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 public Figure getFigure() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 assert figure != null;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 return figure;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 public Color getColor() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 return this.color;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 public void setColor(Color c) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 color = c;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 public List<Connection> getConnections() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 return Collections.unmodifiableList(connections);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 public void removeAllConnections() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 List<Connection> connectionsCopy = new ArrayList<>(this.connections);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 for (Connection c : connectionsCopy) {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 c.remove();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 @Override
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 public Vertex getVertex() {
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 return figure;
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 public abstract int getPosition();
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 public abstract void setPosition(int position);
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 }
015fb895586b Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195