Mercurial > hg > truffle
comparison visualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.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 | 24d9f3310ed6 |
comparison
equal
deleted
inserted
replaced
4511:6cb549627941 | 4512:015fb895586b |
---|---|
1 /* | |
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 package com.sun.hotspot.igv.graph; | |
25 | |
26 import com.sun.hotspot.igv.data.Source; | |
27 import com.sun.hotspot.igv.layout.Link; | |
28 import com.sun.hotspot.igv.layout.Port; | |
29 import java.awt.Color; | |
30 import java.awt.Point; | |
31 import java.util.ArrayList; | |
32 import java.util.List; | |
33 | |
34 /** | |
35 * | |
36 * @author Thomas Wuerthinger | |
37 */ | |
38 public class Connection implements Source.Provider, Link { | |
39 | |
40 @Override | |
41 public boolean isVIP() { | |
42 return style == ConnectionStyle.BOLD; | |
43 } | |
44 | |
45 public enum ConnectionStyle { | |
46 | |
47 NORMAL, | |
48 DASHED, | |
49 BOLD | |
50 } | |
51 private InputSlot inputSlot; | |
52 private OutputSlot outputSlot; | |
53 private Source source; | |
54 private Color color; | |
55 private ConnectionStyle style; | |
56 private List<Point> controlPoints; | |
57 private String label; | |
58 | |
59 protected Connection(InputSlot inputSlot, OutputSlot outputSlot, String label) { | |
60 this.inputSlot = inputSlot; | |
61 this.outputSlot = outputSlot; | |
62 this.label = label; | |
63 this.inputSlot.connections.add(this); | |
64 this.outputSlot.connections.add(this); | |
65 controlPoints = new ArrayList<>(); | |
66 Figure sourceFigure = this.outputSlot.getFigure(); | |
67 Figure destFigure = this.inputSlot.getFigure(); | |
68 sourceFigure.addSuccessor(destFigure); | |
69 destFigure.addPredecessor(sourceFigure); | |
70 source = new Source(); | |
71 | |
72 this.color = Color.BLACK; | |
73 this.style = ConnectionStyle.NORMAL; | |
74 } | |
75 | |
76 public InputSlot getInputSlot() { | |
77 return inputSlot; | |
78 } | |
79 | |
80 public OutputSlot getOutputSlot() { | |
81 return outputSlot; | |
82 } | |
83 | |
84 public Color getColor() { | |
85 return color; | |
86 } | |
87 | |
88 public ConnectionStyle getStyle() { | |
89 return style; | |
90 } | |
91 | |
92 public void setColor(Color c) { | |
93 color = c; | |
94 } | |
95 | |
96 public void setStyle(ConnectionStyle s) { | |
97 style = s; | |
98 } | |
99 | |
100 @Override | |
101 public Source getSource() { | |
102 return source; | |
103 } | |
104 | |
105 public String getLabel() { | |
106 return label; | |
107 } | |
108 | |
109 public void remove() { | |
110 inputSlot.getFigure().removePredecessor(outputSlot.getFigure()); | |
111 inputSlot.connections.remove(this); | |
112 outputSlot.getFigure().removeSuccessor(inputSlot.getFigure()); | |
113 outputSlot.connections.remove(this); | |
114 } | |
115 | |
116 public String getToolTipText() { | |
117 StringBuilder builder = new StringBuilder(); | |
118 if (label != null) { | |
119 builder.append(label).append(": from "); | |
120 } else { | |
121 builder.append("From "); | |
122 } | |
123 builder.append(getOutputSlot().getFigure()); | |
124 builder.append(" to "); | |
125 builder.append(getInputSlot().getFigure()); | |
126 return builder.toString(); | |
127 } | |
128 | |
129 @Override | |
130 public String toString() { | |
131 return "Connection('" + label + "', " + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; | |
132 } | |
133 | |
134 @Override | |
135 public Port getFrom() { | |
136 return outputSlot; | |
137 } | |
138 | |
139 @Override | |
140 public Port getTo() { | |
141 return inputSlot; | |
142 } | |
143 | |
144 @Override | |
145 public List<Point> getControlPoints() { | |
146 return controlPoints; | |
147 } | |
148 | |
149 @Override | |
150 public void setControlPoints(List<Point> list) { | |
151 controlPoints = list; | |
152 } | |
153 } | |
154 |