Mercurial > projects > dwt2
comparison org.eclipse.draw2d/src/org/eclipse/draw2d/graph/TransposeMetrics.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | dbfb303e8fb0 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 org.eclipse.draw2d.graph.TransposeMetrics; | |
15 | |
16 import java.lang.all; | |
17 | |
18 import org.eclipse.draw2d.PositionConstants; | |
19 import org.eclipse.draw2d.geometry.Transposer; | |
20 import org.eclipse.draw2d.graph.GraphVisitor; | |
21 import org.eclipse.draw2d.graph.DirectedGraph; | |
22 import org.eclipse.draw2d.graph.Node; | |
23 import org.eclipse.draw2d.graph.Edge; | |
24 import org.eclipse.draw2d.graph.VirtualNode; | |
25 | |
26 class TransposeMetrics : GraphVisitor { | |
27 | |
28 Transposer t; | |
29 | |
30 public this(){ | |
31 t = new Transposer(); | |
32 } | |
33 | |
34 public void visit(DirectedGraph g) { | |
35 if (g.getDirection() is PositionConstants.SOUTH) | |
36 return; | |
37 t.setEnabled(true); | |
38 int temp; | |
39 g.setDefaultPadding(t.t(g.getDefaultPadding())); | |
40 for (int i = 0; i < g.nodes.size(); i++) { | |
41 Node node = g.nodes.getNode(i); | |
42 temp = node.width; | |
43 node.width = node.height; | |
44 node.height = temp; | |
45 if (node.getPadding() !is null) | |
46 node.setPadding(t.t(node.getPadding())); | |
47 } | |
48 } | |
49 | |
50 public void revisit(DirectedGraph g) { | |
51 if (g.getDirection() is PositionConstants.SOUTH) | |
52 return; | |
53 int temp; | |
54 g.setDefaultPadding(t.t(g.getDefaultPadding())); | |
55 for (int i = 0; i < g.nodes.size(); i++) { | |
56 Node node = cast(Node)g.nodes.get(i); | |
57 temp = node.width; | |
58 node.width = node.height; | |
59 node.height = temp; | |
60 temp = node.y; | |
61 node.y = node.x; | |
62 node.x = temp; | |
63 if (node.getPadding() !is null) | |
64 node.setPadding(t.t(node.getPadding())); | |
65 } | |
66 for (int i = 0; i < g.edges.size(); i++) { | |
67 Edge edge = g.edges.getEdge(i); | |
68 edge.start.transpose(); | |
69 edge.end.transpose(); | |
70 edge.getPoints().transpose(); | |
71 List bends = edge.vNodes; | |
72 if (bends is null) | |
73 continue; | |
74 for (int b = 0; b < bends.size(); b++) { | |
75 VirtualNode vnode = cast(VirtualNode) bends.get(b); | |
76 temp = vnode.y; | |
77 vnode.y = vnode.x; | |
78 vnode.x = temp; | |
79 temp = vnode.width; | |
80 vnode.width = vnode.height; | |
81 vnode.height = temp; | |
82 } | |
83 } | |
84 g.size.transpose(); | |
85 } | |
86 | |
87 } |