1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2003, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.draw2d.graph;
|
12
|
|
13
|
import org.eclipse.draw2d.geometry.Insets;
|
14
|
|
15
|
/**
|
16
|
* @deprecated virtual nodes of an edge should be cast to Node.
|
17
|
* @author Randy Hudson
|
18
|
* @since 2.1.2
|
19
|
*/
|
20
|
public class VirtualNode extends Node {
|
21
|
|
22
|
/**
|
23
|
* The next node.
|
24
|
*/
|
25
|
public Node next;
|
26
|
|
27
|
/**
|
28
|
* The previous node.
|
29
|
*/
|
30
|
public Node prev;
|
31
|
|
32
|
/**
|
33
|
* Constructs a virtual node.
|
34
|
*
|
35
|
* @deprecated This class is for internal use only.
|
36
|
* @param e
|
37
|
* the edge
|
38
|
* @param i
|
39
|
* the row
|
40
|
*/
|
41
|
public VirtualNode(Edge e, int i) {
|
42
|
super(e);
|
43
|
incoming.add(e);
|
44
|
outgoing.add(e);
|
45
|
width = e.width;
|
46
|
height = 0;
|
47
|
rank = i;
|
48
|
setPadding(new Insets(0, e.padding, 0, e.padding));
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Constructor.
|
53
|
*
|
54
|
* @param o
|
55
|
* object
|
56
|
* @param parent
|
57
|
* subgraph
|
58
|
*/
|
59
|
public VirtualNode(Object o, Subgraph parent) {
|
60
|
super(o, parent);
|
61
|
}
|
62
|
|
63
|
/**
|
64
|
* Returns the index of {@link #prev}.
|
65
|
*
|
66
|
* @return median
|
67
|
*/
|
68
|
public double medianIncoming() {
|
69
|
return prev.index;
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Returns the index of {@link #next}.
|
74
|
*
|
75
|
* @return outgoing
|
76
|
*/
|
77
|
public double medianOutgoing() {
|
78
|
return next.index;
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* For internal use only. Returns the original edge weight multiplied by the
|
83
|
* omega value for the this node and the node on the previous rank.
|
84
|
*
|
85
|
* @return the weighted weight, or omega
|
86
|
*/
|
87
|
public int omega() {
|
88
|
Edge e = (Edge) data;
|
89
|
if (e.source.rank + 1 < rank && rank < e.target.rank)
|
90
|
return 8 * e.weight;
|
91
|
return 2 * e.weight;
|
92
|
}
|
93
|
|
94
|
/**
|
95
|
* @see java.lang.Object#toString()
|
96
|
*/
|
97
|
public String toString() {
|
98
|
if (data instanceof Edge)
|
99
|
return "VN[" + (((Edge) data).vNodes.indexOf(this) + 1) //$NON-NLS-1$
|
100
|
+ "](" + data + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
101
|
return super.toString();
|
102
|
}
|
103
|
|
104
|
}
|