Mercurial > projects > dwt-addons
comparison dwtx/draw2d/graph/TransposeMetrics.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) 2005, 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 | |
14 module dwtx.draw2d.graph.TransposeMetrics; | |
15 | |
16 import dwt.dwthelper.utils; | |
17 import dwtx.dwtxhelper.Collection; | |
18 | |
19 import dwtx.draw2d.PositionConstants; | |
20 import dwtx.draw2d.geometry.Transposer; | |
21 import dwtx.draw2d.graph.GraphVisitor; | |
22 import dwtx.draw2d.graph.DirectedGraph; | |
23 import dwtx.draw2d.graph.Node; | |
24 import dwtx.draw2d.graph.Edge; | |
25 import dwtx.draw2d.graph.VirtualNode; | |
26 | |
27 class TransposeMetrics : GraphVisitor { | |
28 | |
29 Transposer t; | |
30 | |
31 public this(){ | |
32 t = new Transposer(); | |
33 } | |
34 | |
35 public void visit(DirectedGraph g) { | |
36 if (g.getDirection() is PositionConstants.SOUTH) | |
37 return; | |
38 t.setEnabled(true); | |
39 int temp; | |
40 g.setDefaultPadding(t.t(g.getDefaultPadding())); | |
41 for (int i = 0; i < g.nodes.size(); i++) { | |
42 Node node = g.nodes.getNode(i); | |
43 temp = node.width; | |
44 node.width = node.height; | |
45 node.height = temp; | |
46 if (node.getPadding() !is null) | |
47 node.setPadding(t.t(node.getPadding())); | |
48 } | |
49 } | |
50 | |
51 public void revisit(DirectedGraph g) { | |
52 if (g.getDirection() is PositionConstants.SOUTH) | |
53 return; | |
54 int temp; | |
55 g.setDefaultPadding(t.t(g.getDefaultPadding())); | |
56 for (int i = 0; i < g.nodes.size(); i++) { | |
57 Node node = cast(Node)g.nodes.get(i); | |
58 temp = node.width; | |
59 node.width = node.height; | |
60 node.height = temp; | |
61 temp = node.y; | |
62 node.y = node.x; | |
63 node.x = temp; | |
64 if (node.getPadding() !is null) | |
65 node.setPadding(t.t(node.getPadding())); | |
66 } | |
67 for (int i = 0; i < g.edges.size(); i++) { | |
68 Edge edge = g.edges.getEdge(i); | |
69 edge.start.transpose(); | |
70 edge.end.transpose(); | |
71 edge.getPoints().transpose(); | |
72 List bends = edge.vNodes; | |
73 if (bends is null) | |
74 continue; | |
75 for (int b = 0; b < bends.size(); b++) { | |
76 VirtualNode vnode = cast(VirtualNode) bends.get(b); | |
77 temp = vnode.y; | |
78 vnode.y = vnode.x; | |
79 vnode.x = temp; | |
80 temp = vnode.width; | |
81 vnode.width = vnode.height; | |
82 vnode.height = temp; | |
83 } | |
84 } | |
85 g.size.transpose(); | |
86 } | |
87 | |
88 } |