4 | Garbage collector forced deoptimization of this code because it contained a weak reference to a map (hidden class) that died during this GC cycle. 5 |
6 | 7 |8 | Garbage collector forced deoptimization of this code because it contained a weak reference to a map (hidden class) that died during this GC cycle. 9 |
10 | 11 |12 | This optimized code depended on a transition between maps (hidden classes) that was replaced by a new version. 13 |
14 | 15 |16 | This optimized code was generated in the assumption that certain prototype never changes hidden class. 17 | It was deoptimized because that prototype transitioned to a new hidden class. 18 |
19 | 20 |
21 | This optimized code was generated in the assumption that certain object has no elements (indexed properties "0"
, "1"
, ...).
22 | It was deoptimized because elements were added to that object.
23 |
26 | This optimized code was generated in the assumption that certain global variable stays contant. It was deoptimized because value of that variable changed. 27 |
28 | 29 |30 | This optimized code was generated in the assumption that certain properties have specific type in all instances of the given hidden class. 31 | It was deoptimized because this assumption was violated. 32 |
33 | 34 |35 | This optimized code was generated in the assumption that initial map associated with the given constructor stays the same. 36 | This assumption was violated. 37 |
38 | 39 |40 | This optimized code embeds tenuring decisions that were invalidated by allocation site profiling. 41 |
42 | 43 |44 | This optimized code embeds elements transition decisions that were invalidated by allocation site profiling. 45 |
46 | 47 | -------------------------------------------------------------------------------- /irhydra/lib/src/modes/v8/ui/descriptions.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | library descriptions; 16 | 17 | import 'package:polymer/polymer.dart'; 18 | 19 | /** 20 | * A list of HIR/LIR insruction descriptions. 21 | * 22 | * Described as a polymer element for the sole purpose of storing it 23 | * modularly. 24 | */ 25 | @CustomTag('ir-descriptions-v8') 26 | class Descriptions extends PolymerElement { 27 | var _hir, _lir; 28 | 29 | Descriptions.created() : super.created() { 30 | _hir = new Map.fromIterable( 31 | shadowRoot.querySelectorAll("[data-hir]"), 32 | key: (n) => n.attributes["data-hir"], 33 | value: (n) => n.innerHtml 34 | ); 35 | 36 | _lir = new Map.fromIterable( 37 | shadowRoot.querySelectorAll("[data-lir]"), 38 | key: (n) => n.attributes["data-lir"], 39 | value: (n) => n.innerHtml 40 | ); 41 | } 42 | 43 | lookup(ns, opcode) { 44 | switch (ns) { 45 | case "lir": return _lir[opcode]; 46 | case "hir": return _hir[opcode]; 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /irhydra/lib/src/spinner.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** Simple wrapper around spin.js that creates spinner at navbar. */ 16 | library spinner; 17 | 18 | import "dart:html" as html; 19 | import "dart:js" as js; 20 | 21 | /** Current instance of spinner. */ 22 | js.JsObject _spinner; 23 | 24 | /** Start spinner. */ 25 | start() { 26 | stop(); // Ensure that spinner is stopped. 27 | 28 | final target = html.document.querySelector(".navbar-inner > .container"); 29 | final opts = new js.JsObject.jsify({ 30 | "lines": 13, // The number of lines to draw 31 | "length": 7, // The length of each line 32 | "width": 4, // The line thickness 33 | "radius": 8, // The radius of the inner circle 34 | "corners": 1, // Corner roundness (0..1) 35 | "rotate": 0, // The rotation offset 36 | "color": '#000', // #rgb or #rrggbb 37 | "speed": 1, // Rounds per second 38 | "trail": 60, // Afterglow percentage 39 | "shadow": false, // Whether to render a shadow 40 | "hwaccel": false, // Whether to use hardware acceleration 41 | "className": 'spinner', // The CSS class to assign to the spinner 42 | "zIndex": 2e9, // The z-index (defaults to 2000000000) 43 | "top": 'auto', // Top position relative to parent in px 44 | "left": 'auto' // Left position relative to parent in px 45 | }); 46 | _spinner = new js.JsObject(js.context['Spinner'], [opts]).callMethod('spin', [target]); 47 | } 48 | 49 | /** Stop spinner. */ 50 | stop() { 51 | if (_spinner != null) { 52 | _spinner.callMethod('stop'); 53 | _spinner = null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /irhydra/lib/src/ui/_ui.scss: -------------------------------------------------------------------------------- 1 | $toolbar-background: white; 2 | $toolbar-color: black; 3 | $toolbar-background-hover: rgba(#999, 0.2); 4 | 5 | $toolbar-border: 1px solid #e0e0e0; 6 | $toolbar-box-shadow: 0 2px 5px rgba(0, 0, 0, .26); 7 | 8 | $button-background: $toolbar-background; 9 | $button-color: $toolbar-color; 10 | $button-background-hover: $toolbar-background-hover; 11 | 12 | $tabs-header-color: black; 13 | $tabs-header-color-active: black; 14 | $tabs-header-color-hover: black; 15 | -------------------------------------------------------------------------------- /irhydra/lib/src/ui/compilation-timeline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |DirectedGraph
whose Nodes may be compound {@link Subgraph}s,
15 | * which may contain other nodes. Any node in the graph may be parented by one
16 | * subgraph. Since subgraphs are nodes, the source or target end of an
17 | * {@link Edge} may be a subgraph. For additional restrictions, refer to the
18 | * JavaDoc for the layout algorithm being used.
19 | *
20 | * A CompoundDirectedGraph is passed to a graph layout, which will position all
21 | * of the nodes, subgraphs, and edges in that graph. This class serves as the
22 | * data structure for a layout algorithm.
23 | *
24 | * @author Randy Hudson
25 | * @since 2.1.2
26 | */
27 | class CompoundDirectedGraph extends DirectedGraph {
28 | NodeList subgraphs = new NodeList();
29 | EdgeList containment = new EdgeList();
30 | }
31 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/CompoundDirectedGraphLayout.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Performs a graph layout on a CompoundDirectedGraph
. The input
15 | * format is the same as for {@link DirectedGraphLayout}. All nodes, including
16 | * subgraphs and their children, should be added to the
17 | * {@link DirectedGraph#nodes} field.
18 | *
19 | * The requirements for this algorithm are the same as those of
20 | * DirectedGraphLayout
, with the following exceptions:
21 | *
true
if the Object is a Dimension and its width and height
27 | * are equal to this Dimension's width and height, false
28 | * otherwise.
29 | * @param othe Object being tested for equality
30 | * @return true
if the given object is equal to this dimension
31 | * @since 2.0
32 | */
33 |
34 | bool operator == (Object o) {
35 | if (o is Dimension) {
36 | return (o.width == width && o.height == height);
37 | }
38 |
39 | return false;
40 | }
41 |
42 | /**
43 | * @see java.lang.Object#hashCode()
44 | */
45 | int get hashCode {
46 | return (width * height) ^ (width + height);
47 | }
48 |
49 | /**
50 | * @see Object#toString()
51 | */
52 | String toString() {
53 | return "Dimension(${width}, ${height})";
54 | }
55 |
56 | /**
57 | * Swaps the width and height of this Dimension, and returns this for
58 | * convenience. Can be useful in orientation changes.
59 | * @return this
for convenience
60 | * @since 2.0
61 | */
62 | Dimension transpose() {
63 | int temp = width;
64 | width = height;
65 | height = temp;
66 | return this;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/EdgeList.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * A list of Edge
s.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class EdgeList extends ListBasetrue
if the two line segments formed by the given
38 | * coordinates share at least one common point.
39 | * @since 3.1
40 | */
41 | static bool linesIntersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
42 | int bb1_x = Math.min(x1, x2);
43 | int bb1_y = Math.min(y1, y2);
44 | int bb2_x = Math.max(x1, x2);
45 | int bb2_y = Math.max(y1, y2);
46 | int bb3_x = Math.min(x3, x4);
47 | int bb3_y = Math.min(y3, y4);
48 | int bb4_x = Math.max(x3, x4);
49 | int bb4_y = Math.max(y3, y4);
50 | if (!(bb2_x >= bb3_x && bb4_x >= bb1_x && bb2_y >= bb3_y && bb4_y >= bb1_y)) {
51 | return false;
52 | }
53 | int p1p3_x = x1 - x3;
54 | int p1p3_y = y1 - y3;
55 | int p2p3_x = x2 - x3;
56 | int p2p3_y = y2 - y3;
57 | int p3p4_x = x3 - x4;
58 | int p3p4_y = y3 - y4;
59 | if (productSign(crossProduct(p2p3_x, p2p3_y, p3p4_x, p3p4_y), crossProduct(p3p4_x, p3p4_y, p1p3_x, p1p3_y)) >= 0) {
60 | int p2p1_x = x2 - x1;
61 | int p2p1_y = y2 - y1;
62 | int p1p4_x = x1 - x4;
63 | int p1p4_y = y1 - y4;
64 | return productSign(crossProduct(-p1p3_x, -p1p3_y, p2p1_x, p2p1_y), crossProduct(p2p1_x, p2p1_y, p1p4_x, p1p4_y)) <= 0;
65 | }
66 | return false;
67 | }
68 | static int productSign(int x, int y) {
69 | if (x == 0 || y == 0) {
70 | return 0;
71 | } else if ((x < 0) != (y < 0)) {
72 | return -1;
73 | }
74 | return 1;
75 | }
76 | static int crossProduct(int x1, int y1, int x2, int y2) {
77 | return x1 * y2 - x2 * y1;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/GraphUtilities.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Some utility methods for graphs.
15 | * @author Eric Bordeau
16 | * @since 2.1.2
17 | */
18 | class GraphUtilities {
19 | static Subgraph getCommonAncestor(Node left, Node right) {
20 | Subgraph parent;
21 | if (right is Subgraph)
22 | parent = right;
23 | else
24 | parent = right.parent;
25 | while (parent != null) {
26 | if (parent.isNested(left))
27 | return parent;
28 | parent = parent.parent;
29 | }
30 | return null;
31 | }
32 |
33 | /**
34 | * Counts the number of edge crossings in a DirectedGraph
35 | * @param graphthe graph whose crossed edges are counted
36 | * @return the number of edge crossings in the graph
37 | */
38 | static int numberOfCrossingsInGraph(DirectedGraph graph) {
39 | int crossings = 0;
40 | for (var rank in graph.ranks) {
41 | crossings += numberOfCrossingsInRank(rank);
42 | }
43 | return crossings;
44 | }
45 | /**
46 | * Counts the number of edge crossings in a Rank
47 | * @param rankthe rank whose crossed edges are counted
48 | * @return the number of edge crossings in the rank
49 | */
50 | static int numberOfCrossingsInRank(Rank rank) {
51 | int crossings = 0;
52 | for (int i = 0; i < rank.length - 1; i++) {
53 | Node currentNode = rank[i];
54 | Node nextNode;
55 | for (int j = i + 1; j < rank.length; j++) {
56 | nextNode = rank[j];
57 | EdgeList currentOutgoing = currentNode.outgoing;
58 | EdgeList nextOutgoing = nextNode.outgoing;
59 | for (int k = 0; k < currentOutgoing.length; k++) {
60 | Edge currentEdge = currentOutgoing[k];
61 | for (int l = 0; l < nextOutgoing.length; l++) {
62 | if (nextOutgoing[l].getIndexForRank(currentNode.rank + 1) < currentEdge.getIndexForRank(currentNode.rank + 1)) crossings++;
63 | }
64 | }
65 | }
66 | }
67 | return crossings;
68 | }
69 | static NodeList search(Node node, NodeList list) {
70 | if (node.flag) return list;
71 | node.flag = true;
72 | list.add(node);
73 | for (int i = 0; i < node.outgoing.length; i++) search(node.outgoing[i].target, list);
74 | return list;
75 | }
76 | /**
77 | * Returns true
if adding an edge between the 2 given nodes
78 | * will introduce a cycle in the containing graph.
79 | * @param sourcethe potential source node
80 | * @param targetthe potential target node
81 | * @return whether an edge between the 2 given nodes will introduce a cycle
82 | */
83 | static bool willCauseCycle(Node source, Node target) {
84 | NodeList nodes = search(target, new NodeList());
85 | nodes.resetFlags();
86 | return nodes.contains(source);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/GraphVisitor.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Performs some action on a Graph.
15 | * @author Randy Hudson
16 | * @since 2.1.2
17 | */
18 | abstract class GraphVisitor {
19 | /**
20 | * Act on the given directed graph.
21 | * @param gthe graph
22 | */
23 | void visit(DirectedGraph g) {
24 | }
25 |
26 | /**
27 | * Called in reverse order of visit.
28 | * @since 3.1
29 | * @param gthe graph to act upon
30 | */
31 | void revisit(DirectedGraph g) {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/InitialRankSolver.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Assigns a valid rank assignment to all nodes based on their edges. The
15 | * assignment is not optimal in that it does not provide the minimum global
16 | * length of edge lengths.
17 | * @author Randy Hudson
18 | * @since 2.1.2
19 | */
20 | class InitialRankSolver extends GraphVisitor {
21 | DirectedGraph graph;
22 | EdgeList candidates = new EdgeList();
23 | NodeList members = new NodeList();
24 | void visit(DirectedGraph graph) {
25 | this.graph = graph;
26 | graph.edges.resetFlags(false);
27 | graph.nodes.resetFlags();
28 | solve();
29 | }
30 | void solve() {
31 | if (graph.nodes.length == 0) return;
32 | NodeList unranked = new NodeList(graph.nodes);
33 | NodeList rankMe = new NodeList();
34 | Node node;
35 | int i;
36 | while (!unranked.isEmpty) {
37 | rankMe.clear();
38 | for (i = 0; i < unranked.length;) {
39 | node = unranked[i];
40 | if (node.incoming.isCompletelyFlagged()) {
41 | rankMe.add(node);
42 | unranked.removeAt(i);
43 | } else i++;
44 | }
45 | if (rankMe.length == 0) throw ("Cycle detected in graph");
46 | for (i = 0; i < rankMe.length; i++) {
47 | node = rankMe[i];
48 | assignMinimumRank(node);
49 | node.outgoing.setFlags(true);
50 | }
51 | }
52 | connectForest();
53 | }
54 | void connectForest() {
55 | List forest = new List();
56 | List stack = new List();
57 | NodeList tree;
58 | graph.nodes.resetFlags();
59 | for (int i = 0; i < graph.nodes.length; i++) {
60 | Node neighbor, n = graph.nodes[i];
61 | if (n.flag) continue;
62 | tree = new NodeList();
63 | stack.add(n);
64 | while (!stack.isEmpty) {
65 | n = stack.removeLast();
66 | n.flag = true;
67 | tree.add(n);
68 | for (int s = 0; s < n.incoming.length; s++) {
69 | neighbor = n.incoming[s].source;
70 | if (!neighbor.flag) stack.add(neighbor);
71 | }
72 | for (int s = 0; s < n.outgoing.length; s++) {
73 | neighbor = n.outgoing[s].target;
74 | if (!neighbor.flag) stack.add(neighbor);
75 | }
76 | }
77 | forest.add(tree);
78 | }
79 | if (forest.length > 1) {
80 | graph.forestRoot = new Node(data: "the forest root");
81 | graph.nodes.add(graph.forestRoot);
82 | for (var tree in forest) {
83 | graph.edges.add(new Edge(graph.forestRoot, tree[0], delta: 0, weight: 0));
84 | }
85 | }
86 | }
87 | void assignMinimumRank(Node node) {
88 | int rank = 0;
89 | Edge e;
90 | for (int i1 = 0; i1 < node.incoming.length; i1++) {
91 | e = node.incoming[i1];
92 | rank = Math.max(rank, e.delta + e.source.rank);
93 | }
94 | node.rank = rank;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/InvertEdges.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Inverts any edges which are marked as backwards or "feedback" edges.
15 | * @author Daniel Lee
16 | * @since 2.1.2
17 | */
18 | class InvertEdges extends GraphVisitor {
19 | /**
20 | * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph)
21 | */
22 | void visit(DirectedGraph g) {
23 | for (int i = 0; i < g.edges.length; i++) {
24 | Edge e = g.edges[i];
25 | if (e.isFeedback) e.invert();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/LocalOptimizer.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * This graph visitor examines all adjacent pairs of nodes and determines if
15 | * swapping the two nodes provides improved graph aesthetics.
16 | * @author Daniel Lee
17 | * @since 2.1.2
18 | */
19 | class LocalOptimizer extends GraphVisitor {
20 | bool shouldSwap(Node current, Node next) {
21 | int crossCount = 0;
22 | int invertedCrossCount = 0;
23 | EdgeList currentEdges = current.incoming;
24 | EdgeList nextEdges = next.incoming;
25 | int rank = current.rank - 1;
26 | int iCurrent, iNext;
27 | for (int i = 0; i < currentEdges.length; i++) {
28 | Edge currentEdge = currentEdges[i];
29 | iCurrent = currentEdge.getIndexForRank(rank);
30 | for (int j = 0; j < nextEdges.length; j++) {
31 | iNext = nextEdges[j].getIndexForRank(rank);
32 | if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else {
33 | int offsetDiff = nextEdges[j].sourceOffset - currentEdge.sourceOffset;
34 | if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++;
35 | }
36 | }
37 | }
38 | currentEdges = current.outgoing;
39 | nextEdges = next.outgoing;
40 | rank = current.rank + 1;
41 | for (int i = 0; i < currentEdges.length; i++) {
42 | Edge currentEdge = currentEdges[i];
43 | iCurrent = currentEdge.getIndexForRank(rank);
44 | for (int j = 0; j < nextEdges.length; j++) {
45 | iNext = nextEdges[j].getIndexForRank(rank);
46 | if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else {
47 | int offsetDiff = nextEdges[j].targetOffset - currentEdge.targetOffset;
48 | if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++;
49 | }
50 | }
51 | }
52 | if (invertedCrossCount < crossCount) return true;
53 | return false;
54 | }
55 | void swapNodes(Node current, Node next, Rank rank) {
56 | int index = rank.indexOf(current);
57 | rank[index + 1] = current;
58 | rank[index] = next;
59 | index = current.index;
60 | current.index = next.index;
61 | next.index = index;
62 | }
63 | /**
64 | * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph)
65 | */
66 | void visit(DirectedGraph g) {
67 | bool flag;
68 | do {
69 | flag = false;
70 | for (int r = 0; r < g.ranks.length; r++) {
71 | Rank rank = g.ranks[r];
72 | for (int n = 0; n < rank.count() - 1; n++) {
73 | Node currentNode = rank[n];
74 | Node nextNode = rank[n + 1];
75 | if (shouldSwap(currentNode, nextNode)) {
76 | swapNodes(currentNode, nextNode, rank);
77 | flag = true;
78 | n = Math.max(0, n - 2);
79 | }
80 | }
81 | }
82 | } while (flag);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/MinCross.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * Sweeps up and down the ranks rearranging them so as to reduce edge crossings.
15 | * @author Randy Hudson
16 | * @since 2.1.2
17 | */
18 | class MinCross extends GraphVisitor {
19 | static final int MAX = 45;
20 | DirectedGraph g;
21 | RankSorter sorter;
22 |
23 | MinCross([this.sorter]) {
24 | if (sorter == null) sorter = new RankSorter();
25 | }
26 |
27 | void setRankSorter(RankSorter sorter) {
28 | this.sorter = sorter;
29 | }
30 | void solve() {
31 | Rank rank;
32 | for (int loop = 0; loop < MAX; loop++) {
33 | for (int row = 1; row < g.ranks.length; row++) {
34 | rank = g.ranks[row];
35 | sorter.sortRankIncoming(g, rank, row, loop / MAX);
36 | }
37 | if (loop == MAX - 1) continue;
38 | for (int row = g.ranks.length - 2; row >= 0; row--) {
39 | rank = g.ranks[row];
40 | sorter.sortRankOutgoing(g, rank, row, loop / MAX);
41 | }
42 | }
43 | }
44 | /**
45 | * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph)
46 | */
47 | void visit(DirectedGraph g) {
48 | sorter.init(g);
49 | this.g = g;
50 | solve();
51 | sorter.optimize(g);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/NodeList.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * A list containing nodes.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class NodeList extends ListBasetrue
if the given point is contained but not on the
31 | * boundary of this obstacle.
32 | * @param pa point
33 | * @return true
if properly contained
34 | */
35 | bool containsProper(Point p) {
36 | return p.x > this.x && p.x < this.x + this.width - 1 && p.y > this.y && p.y < this.y + this.height - 1;
37 | }
38 | int getSpacing() {
39 | return router.getSpacing();
40 | }
41 | void growVertex(Vertex vertex) {
42 | if (vertex.totalCount > 0) vertex.grow();
43 | }
44 | /**
45 | * Grows all vertices on this obstacle.
46 | */
47 | void growVertices() {
48 | growVertex(topLeft);
49 | growVertex(topRight);
50 | growVertex(bottomLeft);
51 | growVertex(bottomRight);
52 | }
53 | /**
54 | * Initializes this obstacle to the values of the given rectangle
55 | * @param rectbounds of this obstacle
56 | */
57 | void init(Rectangle rect) {
58 | this.x = rect.x;
59 | this.y = rect.y;
60 | this.width = rect.width;
61 | this.height = rect.height;
62 | exclude = false;
63 | topLeft = new Vertex(x, y, this);
64 | topLeft.positionOnObstacle = PositionConstants.NORTH_WEST;
65 | topRight = new Vertex(x + width - 1, y, this);
66 | topRight.positionOnObstacle = PositionConstants.NORTH_EAST;
67 | bottomLeft = new Vertex(x, y + height - 1, this);
68 | bottomLeft.positionOnObstacle = PositionConstants.SOUTH_WEST;
69 | bottomRight = new Vertex(x + width - 1, y + height - 1, this);
70 | bottomRight.positionOnObstacle = PositionConstants.SOUTH_EAST;
71 | center = new Vertex.fromPoint(getCenter(), this);
72 | }
73 | /**
74 | * Requests a full reset on all four vertices of this obstacle.
75 | */
76 | void reset() {
77 | topLeft.fullReset();
78 | bottomLeft.fullReset();
79 | bottomRight.fullReset();
80 | topRight.fullReset();
81 | }
82 | void shrinkVertex(Vertex vertex) {
83 | if (vertex.totalCount > 0) vertex.shrink();
84 | }
85 | /**
86 | * Shrinks all four vertices of this obstacle.
87 | */
88 | void shrinkVertices() {
89 | shrinkVertex(topLeft);
90 | shrinkVertex(topRight);
91 | shrinkVertex(bottomLeft);
92 | shrinkVertex(bottomRight);
93 | }
94 | /**
95 | * @see org.eclipse.draw2d.geometry.Rectangle#toString()
96 | */
97 | String toString() {
98 | return "Obstacle($x"; // TODO(vegorov)
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/Point.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000, 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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 |
12 | part of draw2d.graph;
13 |
14 | /**
15 | * Represents a point (x, y) in 2-dimensional space. This class provides various
16 | * methods for manipulating this Point or creating new derived geometrical
17 | * Objects.
18 | */
19 | class Point {
20 | int x;
21 | int y;
22 |
23 | Point(this.x, this.y);
24 |
25 | Point clone() => new Point(x, y);
26 |
27 | /**
28 | * Test for equality.
29 | * @param oObject being tested for equality
30 | * @return true if both x and y values are equal
31 | * @since 2.0
32 | */
33 | bool operator == (Object o) {
34 | if (o is Point) {
35 | return o.x == x && o.y == y;
36 | }
37 | return false;
38 | }
39 |
40 | /**
41 | * @see java.lang.Object#hashCode()
42 | */
43 | int get hashCode {
44 | return (x * y) ^ (x + y);
45 | }
46 |
47 | /**
48 | * @return String representation.
49 | * @since 2.0
50 | */
51 | String toString() {
52 | return "Point(${x}, ${y})";
53 | }
54 |
55 | /**
56 | * Calculates the distance from this Point to the one specified.
57 | * @param pThe Point being compared to this
58 | * @return The distance
59 | * @since 2.0
60 | */
61 | double getDistance(Point p) {
62 | final dx = p.x - x;
63 | final dy = p.y - y;
64 | return math.sqrt((dx * dx + dy * dy).toDouble()); // TODO(vegorov) working around the crash.
65 | }
66 |
67 |
68 | /**
69 | * Creates a new Point which is translated by the values of the provided
70 | * Point.
71 | * @param pPoint which provides the translation amounts.
72 | * @return A new Point
73 | * @since 2.0
74 | */
75 | Point translate(Point p) {
76 | x += p.x;
77 | y += p.y;
78 | return this;
79 | }
80 |
81 | /**
82 | * Scales this Point by the specified amount.
83 | * @return this
for convenience
84 | * @param factorscale factor
85 | * @since 2.0
86 | */
87 | Point scale(double factor) {
88 | x = Math.floor(x * factor);
89 | y = Math.floor(y * factor);
90 | return this;
91 | }
92 |
93 | /**
94 | * Transposes this object. X and Y values are exchanged.
95 | * @return this
for convenience
96 | * @since 2.0
97 | */
98 | Point transpose() {
99 | var t = x;
100 | x = y;
101 | y = t;
102 | return this;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/PointList.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000, 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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | * Alexander Shatalin (Borland) - Contribution for Bug 238874
10 | */
11 |
12 |
13 | part of draw2d.graph;
14 |
15 | /**
16 | * Represents a List of Points.
17 | */
18 | class PointList {
19 | final List
18 | * Ranks are populated using a pre-order depth-first traversal of the spanning
19 | * tree. For each node, all edges requiring virtual nodes are added to the
20 | * ranks.
21 | * @author Randy Hudson
22 | * @since 2.1.2
23 | */
24 | class PopulateRanks extends GraphVisitor {
25 | final List
21 | * A Subgraph may contain another Subgraph.
22 | *
23 | * A Subgraph has additional geometric properties which describe the containing
24 | * box. They are:
25 | *
18 | *
19 | *
36 | */
37 | class PositionConstants {
38 | /**
39 | * None
40 | */
41 | static const int NONE = 0;
42 | /**
43 | * Left
44 | */
45 | static const int LEFT = 1;
46 | /**
47 | * Center (Horizontal)
48 | */
49 | static const int CENTER = 2;
50 | /**
51 | * Right
52 | */
53 | static const int RIGHT = 4;
54 | /**
55 | * Bit-wise OR of LEFT, CENTER, and RIGHT
56 | */
57 | static const int LEFT_CENTER_RIGHT = LEFT | CENTER;
58 | /**
59 | * Used to signify left alignment regardless of orientation (i.e., LTR or
60 | * RTL)
61 | */
62 | static const int ALWAYS_LEFT = 64;
63 | /**
64 | * Used to signify right alignment regardless of orientation (i.e., LTR or
65 | * RTL)
66 | */
67 | static const int ALWAYS_RIGHT = 128;
68 | /**
69 | * Top
70 | */
71 | static const int TOP = 8;
72 | /**
73 | * Middle (Vertical)
74 | */
75 | static const int MIDDLE = 16;
76 | /**
77 | * Bottom
78 | */
79 | static const int BOTTOM = 32;
80 | /**
81 | * Bit-wise OR of TOP, MIDDLE, and BOTTOM
82 | */
83 | static const int TOP_MIDDLE_BOTTOM = TOP | MIDDLE;
84 | /**
85 | * North
86 | */
87 | static const int NORTH = 1;
88 | /**
89 | * South
90 | */
91 | static const int SOUTH = 4;
92 | /**
93 | * West
94 | */
95 | static const int WEST = 8;
96 | /**
97 | * East
98 | */
99 | static const int EAST = 16;
100 | /**
101 | * A constant indicating horizontal direction
102 | */
103 | static const int HORIZONTAL = 64;
104 | /**
105 | * A constant indicating vertical direction
106 | */
107 | static const int VERTICAL = 128;
108 | /**
109 | * North-East: a bit-wise OR of {@link #NORTH} and {@link #EAST}
110 | */
111 | static const int NORTH_EAST = NORTH | EAST;
112 | /**
113 | * North-West: a bit-wise OR of {@link #NORTH} and {@link #WEST}
114 | */
115 | static const int NORTH_WEST = NORTH | WEST;
116 | /**
117 | * South-East: a bit-wise OR of {@link #SOUTH} and {@link #EAST}
118 | */
119 | static const int SOUTH_EAST = SOUTH | EAST;
120 | /**
121 | * South-West: a bit-wise OR of {@link #SOUTH} and {@link #WEST}
122 | */
123 | static const int SOUTH_WEST = SOUTH | WEST;
124 | /**
125 | * North-South: a bit-wise OR of {@link #NORTH} and {@link #SOUTH}
126 | */
127 | static const int NORTH_SOUTH = NORTH | SOUTH;
128 | /**
129 | * East-West: a bit-wise OR of {@link #EAST} and {@link #WEST}
130 | */
131 | static const int EAST_WEST = EAST | WEST;
132 | /**
133 | * North-South-East-West: a bit-wise OR of all 4 directions.
134 | */
135 | static const int NSEW = NORTH_SOUTH | EAST_WEST;
136 | }
137 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/README:
--------------------------------------------------------------------------------
1 | This folder contains parts of Draw2d library translated from Java to Dart.
2 |
3 | The translation was mostly done by a java2dart tool and resulting source was
4 | cleaned up manually. Cleanup is incomplete and the libarary definetely contains
5 | untested and/or dead code that does not match Dart style guide.
6 |
7 | Translated files retain their original license and comments.
8 |
9 | Draw2d: http://www.eclipse.org/gef/draw2d/index.php
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/Rank.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * For Internal Use only.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class Rank extends NodeList {
19 | int bottomPadding = 0;
20 | int height = 0;
21 | int location = 0;
22 | final int hash = new Object().hashCode;
23 | int topPadding = 0;
24 | int total = 0;
25 |
26 | Rank() : super();
27 |
28 | void assignIndices() {
29 | total = 0;
30 | int mag;
31 | for (var node in this) {
32 | if (node is SubgraphBoundary) {
33 | mag = 4;
34 | } else {
35 | mag = Math.max(1, node.incoming.length + node.outgoing.length);
36 | mag = Math.min(mag, 5);
37 | }
38 | total += mag;
39 | node.index = total;
40 | total += mag;
41 | }
42 | }
43 | /**
44 | * Returns the number of nodes in this rank.
45 | * @return the number of nodes
46 | */
47 | int count() {
48 | return this.length;
49 | }
50 |
51 | /**
52 | * @see Object#hashCode() Overridden for speed based on equality.
53 | */
54 | int get hashCode {
55 | return hash;
56 | }
57 |
58 | void setDimensions(int location, int rowHeight) {
59 | this.height = rowHeight;
60 | this.location = location;
61 | for (var n in this) {
62 | n.y = location;
63 | n.height = rowHeight;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/RankList.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * For internal use only. A list of lists.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class RankList extends ListBase
20 | *
23 | * LEFT, CENTER, RIGHT
21 | * Used to describe horizontal position.
22 | *
24 | *
27 | * TOP, MIDDLE, BOTTOM
25 | * Used to describe vertical position.
26 | *
28 | *
34 | *
35 | * NORTH, SOUTH, EAST, WEST
29 | * Used to describe the four positions relative to an object's center point.
30 | * May also be used when describing which direction an object is facing.
33 | *
31 | * NOTE: If you have a use for all four of these possibilities, do not use TOP,
32 | * BOTTOM, RIGHT, LEFT in place of NORTH, SOUTH, EAST, WEST.
26 | *
33 | *
34 | * @author hudsonr
35 | * @since 2.1.2
36 | */
37 | class Subgraph extends Node {
38 |
39 | /**
40 | * The children of this subgraph. Nodes may not belong to more than one
41 | * subgraph.
42 | */
43 | NodeList members = new NodeList();
44 |
45 | Node head;
46 | Node tail;
47 | Node left;
48 | Node right;
49 | int nestingTreeMin;
50 |
51 | /**
52 | * The space required for this subgraph's border. The default value is
53 | * undefined.
54 | */
55 | Insets insets = new Insets.round(1);
56 |
57 | /**
58 | * The minimum space between this subgraph's border and it's children.
59 | */
60 | Insets innerPadding = NO_INSETS;
61 |
62 | static final Insets NO_INSETS = new Insets.round(0);
63 |
64 | /**
65 | * Constructs a new subgraph with the given data object and parent subgraph.
66 | *
67 | * @see Node#Node(Object, Subgraph)
68 | * @param data
69 | * an arbitrary data object
70 | * @param parent
71 | * the parent
72 | */
73 | Subgraph(Object data, [Subgraph parent]) : super(data: data, parent: parent);
74 |
75 | /**
76 | * Adds the given node to this subgraph.
77 | *
78 | * @param n
79 | * the node to add
80 | */
81 | void addMember(Node n) {
82 | members.add(n);
83 | }
84 |
85 | /**
86 | * Returns true
if the given node is contained inside the
87 | * branch represented by this subgraph.
88 | *
89 | * @param n
90 | * the node in question
91 | * @return true
if nested
92 | */
93 | bool isNested(Node n) {
94 | return n.nestingIndex >= nestingTreeMin
95 | && n.nestingIndex <= nestingIndex;
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/SubgraphBoundary.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * For INTERNAL use only.
15 | *
16 | * @author hudsonr
17 | * @since 2.1.2
18 | */
19 | class SubgraphBoundary extends Node {
20 |
21 | /**
22 | * constant indicating TOP.
23 | */
24 | static const int TOP = 0;
25 |
26 | /**
27 | * constant indicating LEFT.
28 | */
29 | static const int LEFT = 1;
30 |
31 | /**
32 | * constant indicating BOTTOM.
33 | */
34 | static const int BOTTOM = 2;
35 |
36 | /**
37 | * constant indicating RIGHT.
38 | */
39 | static const int RIGHT = 3;
40 |
41 | /**
42 | * Constructs a new boundary.
43 | *
44 | * @param s
45 | * the subgraph
46 | * @param p
47 | * the padding
48 | * @param side
49 | * which side
50 | */
51 | SubgraphBoundary(Subgraph s, Insets p, int side) : super(parent: s) {
52 | this.width = s.width;
53 | this.height = s.height;
54 | this.padding = new Insets.round(0);
55 | switch (side) {
56 | case LEFT:
57 | width = s.insets.left;
58 | y = s.y;
59 | padding.left = p.left;
60 | padding.right = s.innerPadding.left;
61 | padding.top = padding.bottom = 0;
62 | parent = s.parent;
63 | data = "left(${s})"; //$NON-NLS-1$ //$NON-NLS-2$
64 | break;
65 | case RIGHT:
66 | width = s.insets.right;
67 | y = s.y;
68 | padding.right = p.right;
69 | padding.left = s.innerPadding.right;
70 | padding.top = padding.bottom = 0;
71 | parent = s.parent;
72 | data = "right(${s})"; //$NON-NLS-1$ //$NON-NLS-2$
73 | break;
74 | case TOP:
75 | height = s.insets.top;
76 | // $TODO width of head/tail should be 0
77 | width = 5;
78 | padding.top = p.top;
79 | padding.bottom = s.innerPadding.top;
80 | padding.left = padding.right = 0;
81 | data = "top(${s})"; //$NON-NLS-1$ //$NON-NLS-2$
82 | break;
83 | case BOTTOM:
84 | height = s.insets.bottom;
85 | // $TODO width of head/tail should be 0
86 | width = 5;
87 | padding.top = s.innerPadding.bottom;
88 | padding.bottom = p.bottom;
89 | padding.left = padding.right = 0;
90 | data = "bottom(${s})"; //$NON-NLS-1$ //$NON-NLS-2$
91 | break;
92 | }
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/TightSpanningTreeSolver.dart:
--------------------------------------------------------------------------------
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 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 |
14 | /**
15 | * Finds a tight spanning tree from the graphs edges which induce a valid rank
16 | * assignment. This process requires that the nodes be initially given a
17 | * feasible ranking.
18 | * @author Randy Hudson
19 | * @since 2.1.2
20 | */
21 | class TightSpanningTreeSolver extends SpanningTreeVisitor {
22 | DirectedGraph graph;
23 | final candidates = new List