View | Details | Raw Unified | Return to bug 224468
Collapse All | Expand All

(-)src/org/eclipse/draw2d/graph/PopulateRanks.java (-5 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 61-70 Link Here
61
		Node prev = null, cur;
61
		Node prev = null, cur;
62
		for (int n = 0; n < rank.size(); n++) {
62
		for (int n = 0; n < rank.size(); n++) {
63
			cur = rank.getNode(n);
63
			cur = rank.getNode(n);
64
			if (cur instanceof VirtualNode)
64
			cur.left = prev;
65
				((VirtualNode)cur).left = prev;
65
			if (prev != null) {
66
			if (prev instanceof VirtualNode)
66
				prev.right = cur;
67
				((VirtualNode)prev).right = cur;
67
			}
68
			prev = cur;
68
			prev = cur;
69
		}
69
		}
70
	}
70
	}
(-)src/org/eclipse/draw2d/graph/VirtualNode.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-26 Link Here
19
 */
19
 */
20
public class VirtualNode extends Node {
20
public class VirtualNode extends Node {
21
21
22
Node left, right;
23
24
/**
22
/**
25
 * The next node.
23
 * The next node.
26
 */
24
 */
(-)src/org/eclipse/draw2d/graph/TransposeMetrics.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 65-70 Link Here
65
			temp = vnode.y;
65
			temp = vnode.y;
66
			vnode.y = vnode.x;
66
			vnode.y = vnode.x;
67
			vnode.x = temp;
67
			vnode.x = temp;
68
			temp = vnode.width;
69
			vnode.width = vnode.height;
70
			vnode.height = temp;
68
		}
71
		}
69
	}
72
	}
70
	g.size.transpose();
73
	g.size.transpose();
(-)src/org/eclipse/draw2d/graph/Node.java (-1 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 46-51 Link Here
46
 * @since 2.1.2
46
 * @since 2.1.2
47
 */
47
 */
48
public class Node {
48
public class Node {
49
	
50
Node left, right;
49
51
50
Object workingData[] = new Object[3];
52
Object workingData[] = new Object[3];
51
int workingInts[] = new int[4];
53
int workingInts[] = new int[4];
Lines 295-298 Link Here
295
	};
297
	};
296
}
298
}
297
299
300
/**
301
 * Returns a reference to a node located left from this one
302
 * @return <code>Node</code> on the left from this one
303
 * @since 3.4
304
 */
305
public Node getLeft() {
306
	return left;
307
}
308
309
/**
310
 * Returns a reference to a node located right from this one
311
 * @return <code>Node</code> on the right from this one
312
 * @since 3.4
313
 */
314
public Node getRight() {
315
	return right;
316
}
317
298
}
318
}
(-)src/org/eclipse/draw2d/geometry/PrecisionRectangle.java (+9 lines)
Lines 376-379 Link Here
376
	return preciseHeight;
376
	return preciseHeight;
377
}
377
}
378
378
379
/**
380
 * @see org.eclipse.draw2d.geometry.Rectangle#setSize(org.eclipse.draw2d.geometry.Dimension)
381
 */
382
public Rectangle setSize(Dimension d) {
383
	preciseWidth = d.preciseWidth();
384
	preciseHeight = d.preciseHeight();
385
	return super.setSize(d);
386
}
387
379
}
388
}
(-)src/org/eclipse/draw2d/geometry/Geometry.java (-17 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 41-66 Link Here
41
	 * Given the segments: u-------v. s-------t. If s->t is inside the triangle u-v-s, 
41
	 * Given the segments: u-------v. s-------t. If s->t is inside the triangle u-v-s, 
42
	 * then check whether the line u->u splits the line s->t.
42
	 * then check whether the line u->u splits the line s->t.
43
	 */
43
	 */
44
	int usX = ux - sx;
44
	/* Values are casted to long to avoid integer overflows */
45
	int usY = uy - sy;
45
	long usX = (long) ux - sx;
46
	int vsX = vx - sx;
46
	long usY = (long) uy - sy;
47
	int vsY = vy - sy;
47
	long vsX = (long) vx - sx;
48
	int stX = sx - tx;
48
	long vsY = (long) vy - sy;
49
	int stY = sy - ty;
49
	long stX = (long) sx - tx;
50
	long product = cross(vsX, vsY, stX, stY) * cross(stX, stY, usX, usY);
50
	long stY = (long) sy - ty;
51
	if (product >= 0) {
51
	if (productSign(cross(vsX, vsY, stX, stY), cross(stX, stY, usX, usY)) >= 0) {
52
		int vuX = vx - ux;
52
		long vuX = (long) vx - ux;
53
		int vuY = vy - uy;
53
		long vuY = (long) vy - uy;
54
		int utX = ux - tx;
54
		long utX = (long) ux - tx;
55
		int utY = uy - ty;
55
		long utY = (long) uy - ty;
56
		product = cross(-usX, -usY, vuX, vuY) * cross(vuX, vuY, utX, utY);
56
		return productSign(cross(-usX, -usY, vuX, vuY), cross(vuX, vuY, utX, utY)) <= 0;
57
		boolean intersects = product <= 0;
58
		return intersects;
59
	}
57
	}
60
	return false;
58
	return false;
61
}
59
}
62
60
63
private static long cross(int x1, int y1, int x2, int y2) {
61
private static int productSign(long x, long y) {
62
	if (x == 0 || y == 0) {
63
		return 0;
64
	} else if (x < 0 ^ y < 0) {
65
		return -1;
66
	}
67
	return 1;
68
}
69
70
private static long cross(long x1, long y1, long x2, long y2) {
64
	return x1 * y2 - x2 * y1;
71
	return x1 * y2 - x2 * y1;
65
}
72
}
66
73
(-)src/org/eclipse/draw2d/geometry/Point.java (-1 / +7 lines)
Lines 118-124 Link Here
118
 * @since 2.0
118
 * @since 2.0
119
 */
119
 */
120
public double getDistance(Point pt) {
120
public double getDistance(Point pt) {
121
	return Math.sqrt(getDistance2(pt));
121
	return Math.sqrt(getPreciseDistance2(pt));
122
}
122
}
123
123
124
/**
124
/**
Lines 138-143 Link Here
138
	return (int)result;
138
	return (int)result;
139
}
139
}
140
140
141
private double getPreciseDistance2(Point pt) {
142
	double i = pt.preciseX() - preciseX();
143
	double j = pt.preciseY() - preciseY();
144
	return i * i + j * j;
145
}
146
141
/**
147
/**
142
 * Calculates the orthogonal distance to the specified point.  The orthogonal distance is
148
 * Calculates the orthogonal distance to the specified point.  The orthogonal distance is
143
 * the sum of the horizontal and vertical differences.
149
 * the sum of the horizontal and vertical differences.
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 7-10 Link Here
7
Require-Bundle: org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)"
7
Require-Bundle: org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)"
8
Bundle-Vendor: %Plugin.providerName
8
Bundle-Vendor: %Plugin.providerName
9
Bundle-RequiredExecutionEnvironment: J2SE-1.4
9
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Export-Package: org.eclipse.draw2d.examples.graph
10
11

Return to bug 224468