Mercurial > hg > truffle
comparison visualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.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 |
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.hierarchicallayout; | |
25 | |
26 /** | |
27 * | |
28 * @author Thomas Wuerthinger | |
29 */ | |
30 public class Edge<N, E> { | |
31 | |
32 private E data; | |
33 private Node<N, E> source; | |
34 private Node<N, E> dest; | |
35 | |
36 protected Edge(Graph<N, E> graph, Node<N, E> source, Node<N, E> dest, E data) { | |
37 setData(data); | |
38 this.source = source; | |
39 this.dest = dest; | |
40 assert source != null; | |
41 assert dest != null; | |
42 assert source.getGraph() == dest.getGraph(); | |
43 assert source.getGraph() != null; | |
44 assert dest.getGraph() != null; | |
45 } | |
46 | |
47 public Node<N, E> getSource() { | |
48 return source; | |
49 } | |
50 | |
51 public Node<N, E> getDest() { | |
52 return dest; | |
53 } | |
54 | |
55 public E getData() { | |
56 return data; | |
57 } | |
58 | |
59 public void setData(E e) { | |
60 data = e; | |
61 } | |
62 | |
63 public void remove() { | |
64 source.getGraph().removeEdge(this, null); | |
65 } | |
66 | |
67 public boolean isSelfLoop() { | |
68 return source == dest; | |
69 } | |
70 | |
71 public void reverse() { | |
72 | |
73 // Remove from current source / dest | |
74 source.removeOutEdge(this); | |
75 dest.removeInEdge(this); | |
76 | |
77 Node<N, E> tmp = source; | |
78 source = dest; | |
79 dest = tmp; | |
80 | |
81 // Add to new source / dest | |
82 source.addOutEdge(this); | |
83 dest.addInEdge(this); | |
84 } | |
85 | |
86 @Override | |
87 public String toString() { | |
88 return "Edge (" + source + " -- " + dest + "): " + data; | |
89 } | |
90 } |