01: package tools.tracesviewer;
02:
03: import java.awt.*;
04:
05: /**
06: *@version 1.2
07: *
08: *@author Olivier Deruelle <br/>
09: *
10: *
11: */
12:
13: public class CircleArrow extends Arrow {
14:
15: public int x = 0;
16: public int y = 0;
17: public int diameter = 0;
18:
19: public CircleArrow(boolean selected, String arrowName, int x,
20: int ymin, int ymax, int diameter, boolean flag, boolean info) {
21: super (selected, arrowName, flag, x, x + diameter, ymin, ymax,
22: info);
23: this .x = xmin;
24: this .y = (ymin + ymax) / 2;
25: this .diameter = diameter;
26: }
27:
28: public int xmin() {
29: return x;
30: }
31:
32: public int xmax() {
33: return x + diameter;
34: }
35:
36: public int ymin() {
37: return ymin;
38: }
39:
40: public int ymax() {
41: return ymax;
42: }
43:
44: public void draw(Graphics g) {
45: // Set the color of this arrow:
46: if (selected)
47: g.setColor(Color.red);
48: else
49: g.setColor(color);
50: /* Draw the circle */
51:
52: g.drawOval(x, y - (diameter / 2), diameter, diameter);
53: g.drawOval(x - 1, y - (diameter / 2) - 1, diameter + 2,
54: diameter + 2);
55:
56: /* Display the first line of the message */
57: String timeString = "Time : " + tracesMessage.getTime() + " ms";
58:
59: int timeStringWidth = g.getFontMetrics(g.getFont())
60: .stringWidth(timeString);
61: int fistLineStringWidth = g.getFontMetrics(g.getFont())
62: .stringWidth(tracesMessage.getFirstLine());
63:
64: g.drawString(tracesMessage.getFirstLine(), x + diameter + 5
65: + tracesCanvas.HORIZONTAL_GAP / 2 - fistLineStringWidth
66: / 2, y - 5);
67:
68: g.drawString(timeString,
69: x + diameter + 5 + tracesCanvas.HORIZONTAL_GAP / 2
70: - timeStringWidth / 2, y
71: + g.getFontMetrics(g.getFont()).getHeight());
72:
73: /* Draw the head of the arrow */
74:
75: g.drawLine(x, y, x - 3, y + 10);
76: g.drawLine(x, y, x + 7, y + 7);
77:
78: g.drawLine(x - 1, y, x - 4, y + 10);
79: g.drawLine(x + 1, y, x + 8, y + 7);
80:
81: g.drawLine(x - 2, y, x - 5, y + 10);
82: g.drawLine(x + 2, y, x + 9, y + 7);
83: }
84: }
|