comparison dwtx/draw2d/graph/Rank.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, 2005 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.Rank;
14
15 import dwt.dwthelper.utils;
16 import dwtx.draw2d.graph.Node;
17 import dwtx.draw2d.graph.SubgraphBoundary;
18 import dwtx.draw2d.graph.NodeList;
19
20 /**
21 * For Internal Use only.
22 * @author hudsonr
23 * @since 2.1.2
24 */
25 public class Rank : NodeList {
26
27 alias NodeList.add add;
28
29 int bottomPadding;
30 int height;
31 int location;
32
33 const int hash;
34 int topPadding;
35 int total;
36
37 public this(){
38 hash = (new Object()).toHash();
39 }
40
41 void add(Node n) {
42 super.add(n);
43 }
44
45 void assignIndices() {
46 total = 0;
47 Node node;
48
49 int mag;
50 for (int i = 0; i < size(); i++) {
51 node = getNode(i);
52 mag = Math.max(1, node.incoming.size() + node.outgoing.size());
53 mag = Math.min(mag, 5);
54 if (null !is cast(SubgraphBoundary)node )
55 mag = 4;
56 total += mag;
57 node.index = total;
58 total += mag;
59 }
60 }
61
62 /**
63 * Returns the number of nodes in this rank.
64 * @return the number of nodes
65 */
66 public int count() {
67 return super.size();
68 }
69
70 /**
71 * @see Object#equals(Object)
72 */
73 public override int opEquals(Object o) {
74 return o is this;
75 }
76
77 /**
78 * @see Object#toHash()
79 * Overridden for speed based on equality.
80 */
81 public override hash_t toHash() {
82 return hash;
83 }
84
85 void setDimensions(int location, int rowHeight) {
86 this.height = rowHeight;
87 this.location = location;
88 for (int i = 0; i < size(); i++) {
89 Node n = getNode(i);
90 n.y = location;
91 n.height = rowHeight;
92 }
93 }
94
95 /**
96 * @deprecated Do not call
97 */
98 public void sort() { }
99
100 }