comparison dwtx/draw2d/graph/VirtualNode.d @ 98:95307ad235d9

Added Draw2d code, still work in progress
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 00:52:14 +0200
parents
children
comparison
equal deleted inserted replaced
96:b492ba44e44d 98:95307ad235d9
1 /*******************************************************************************
2 * Copyright (c) 2003, 2008 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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module dwtx.draw2d.graph.VirtualNode;
14
15 import dwt.dwthelper.utils;
16 import tango.text.convert.Format;
17
18 import dwtx.draw2d.geometry.Insets;
19 import dwtx.draw2d.graph.Node;
20 import dwtx.draw2d.graph.Edge;
21 import dwtx.draw2d.graph.Subgraph;
22
23 /**
24 * @deprecated virtual nodes of an edge should be cast to Node.
25 * @author Randy Hudson
26 * @since 2.1.2
27 */
28 public class VirtualNode : Node {
29
30 /**
31 * The next node.
32 */
33 public Node next;
34
35 /**
36 * The previous node.
37 */
38 public Node prev;
39
40 /**
41 * Constructs a virtual node.
42 * @deprecated This class is for internal use only.
43 * @param e the edge
44 * @param i the row
45 */
46 public this(Edge e, int i) {
47 super(e);
48 incoming.add(e);
49 outgoing.add(e);
50 width = e.width;
51 height = 0;
52 rank = i;
53 setPadding(new Insets(0, e.padding, 0, e.padding));
54 }
55
56 /**
57 * Constructor.
58 * @param o object
59 * @param parent subgraph
60 */
61 public this(Object o, Subgraph parent) {
62 super(o, parent);
63 }
64
65 /**
66 * Returns the index of {@link #prev}.
67 * @return median
68 */
69 public double medianIncoming() {
70 return prev.index;
71 }
72
73 /**
74 * Returns the index of {@link #next}.
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 omega value
83 * for the this node and the node on the previous rank.
84 * @return the weighted weight, or omega
85 */
86 public int omega() {
87 Edge e = cast(Edge)data;
88 if (e.source.rank + 1 < rank && rank < e.target.rank)
89 return 8 * e.weight;
90 return 2 * e.weight;
91 }
92
93 /**
94 * @see java.lang.Object#toString()
95 */
96 public String toString() {
97 if (auto edge = cast(Edge)data )
98 return Format("VN[{}]({})", (edge.vNodes.indexOf(this) + 1) //$NON-NLS-1$
99 , data ); //$NON-NLS-1$ //$NON-NLS-2$
100 return super.toString();
101 }
102
103 }