1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2007</p>
22 * <p>Company: Ontotext Lab. / SIRMA </p>
23 */
24
25 package org.wsmostudio.bpmo.figures;
26
27 import org.eclipse.draw2d.*;
28 import org.eclipse.draw2d.geometry.Rectangle;
29
30 public class DeferredChoiceFigure extends Shape {
31
32 boolean selected;
33 private static double cosPi6 = Math.cos(Math.PI / 6.0);
34 private static double sinPi6 = Math.sin(Math.PI / 6.0);
35
36 public DeferredChoiceFigure() {
37 super();
38 setBorder(new MarginBorder(3,3,3,3));
39 setOpaque(false);
40 }
41
42 protected void outlineShape(Graphics graphics) {
43
44 Rectangle rect = getBounds();
45 int centerX = rect.x + rect.width / 2;
46 int centerY = rect.y + rect.height / 2;
47 graphics.drawPolygon(new int[] {centerX - rect.width / 2, centerY,
48 centerX, centerY - rect.height / 2,
49 centerX + rect.width / 2, centerY,
50 centerX, centerY + rect.height / 2});
51 graphics.setLineWidth(1);
52
53 int step = Math.min(Math.round(((float)rect.width) / 4),
54 Math.round(((float)rect.height) / 4));
55
56 graphics.drawOval(centerX - step + 1, centerY - step + 1, 2 * step - 2, step * 2 - 2);
57 graphics.drawOval(centerX - step - 1, centerY - step - 1, 2 * step + 2, step * 2 + 2);
58
59 double r = step - 2;
60
61 graphics.setBackgroundColor(getForegroundColor());
62 graphics.fillPolygon(new int[] {
63 centerX - (int)Math.round(r * cosPi6), centerY - (int)Math.round(r * sinPi6),
64 centerX + (int)Math.round(r * cosPi6), centerY - (int)Math.round(r * sinPi6),
65 centerX, centerY + (int)Math.round(r)});
66
67 graphics.fillPolygon(new int[] {
68 centerX - (int)Math.round(r * cosPi6), centerY + (int)Math.round(r * sinPi6),
69 centerX + (int)Math.round(r * cosPi6), centerY + (int)Math.round(r * sinPi6),
70 centerX, centerY - (int)Math.round(r)});
71 }
72
73 protected void fillShape(Graphics g) {
74 Rectangle r = getBounds();
75 g.fillPolygon(new int[] {r.x, r.y + r.height / 2,
76 r.x + r.width / 2, r.y,
77 r.x + r.width, r.y + r.height / 2,
78 r.x + r.width / 2, r.y + r.height});
79 }
80
81 public void setSelected(boolean selected) {
82 if (this.selected == selected)
83 return;
84 this.selected = selected;
85 repaint();
86 }
87
88 }
89
90
91
92
93
94
95
96
97
98
99
100
101