/
AdvancedPath.java
74 lines (69 loc) · 2.4 KB
/
AdvancedPath.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*********************************************************************************************
*
* 'AdvancedPath.java, in plugin ummisco.gama.ui.shared, is part of the source code of the GAMA modeling and simulation
* platform. (v. 1.8.1)
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
*
*
**********************************************************************************************/
package ummisco.gama.ui.controls;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Path;
/**
* AdvancedPath, a Path object that contains extra paths
*
* @see Path
*/
public class AdvancedPath extends Path {
/**
* Contructor
*
* @param device
*/
public AdvancedPath(final Device device) {
super(device);
}
/**
* Adds to the receiver the round-cornered rectangle specified by x, y, width and height.
*
* @param x
* the x coordinate of the rectangle to add
* @param y
* the y coordinate of the rectangle to add
* @param width
* the width of the rectangle to add
* @param height
* the height of the rectangle to add
* @param arcWidth
* the width of the arc
* @param arcHeight
* the height of the arc
* @exception SWTException
* <ul>
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
public void addRoundRectangle(final float x, final float y, final float width, final float height,
final float arcWidth, final float arcHeight) {
if (this.isDisposed()) {
SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
}
// Top left corner
this.cubicTo(x, y, x, y, x, y + arcHeight);
this.cubicTo(x, y, x, y, x + arcWidth, y);
// Top right corner
this.cubicTo(x + width, y, x + width, y, x + width - arcWidth, y);
this.cubicTo(x + width, y, x + width, y, x + width, y + arcHeight);
// Bottom right corner
this.cubicTo(x + width, y + height, x + width, y + height, x + width, y + height - arcHeight);
this.cubicTo(x + width, y + height, x + width, y + height, x + width - arcWidth, y + height);
// Bottom left corner
this.cubicTo(x, y + height, x, y + height, x + arcWidth, y + height);
this.cubicTo(x, y + height, x, y + height, x, y + height - arcHeight);
}
}