|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| package org.ericmignot.modeler.util.graphic; |
|
20 |
| |
|
21 |
| import java.awt.*; |
|
22 |
| |
|
23 |
| import javax.swing.JPanel; |
|
24 |
| |
|
25 |
| public class UMLStateDiagramEndStatePanel extends JPanel |
|
26 |
| { |
|
27 |
| private int fixedSize; |
|
28 |
| private Color fillColor; |
|
29 |
| private Color drawColor; |
|
30 |
| private Color ringBackgroundColor; |
|
31 |
| private int internalGap; |
|
32 |
| |
|
33 |
0
| public UMLStateDiagramEndStatePanel(
|
|
34 |
| Color ringBackgroundColor, |
|
35 |
| Color fillColor, |
|
36 |
| Color drawColor, |
|
37 |
| int size, |
|
38 |
| int internalGap) |
|
39 |
| { |
|
40 |
0
| this.ringBackgroundColor = ringBackgroundColor;
|
|
41 |
0
| this.fillColor = fillColor;
|
|
42 |
0
| this.drawColor = drawColor;
|
|
43 |
0
| this.fixedSize = size;
|
|
44 |
0
| this.internalGap = internalGap;
|
|
45 |
| } |
|
46 |
| |
|
47 |
0
| public Color getBackground()
|
|
48 |
| { |
|
49 |
0
| return this.fillColor;
|
|
50 |
| } |
|
51 |
| |
|
52 |
0
| public Color getForeground()
|
|
53 |
| { |
|
54 |
0
| return this.drawColor;
|
|
55 |
| } |
|
56 |
| |
|
57 |
0
| public Dimension getPreferredSize()
|
|
58 |
| { |
|
59 |
0
| return new Dimension(fixedSize, fixedSize);
|
|
60 |
| } |
|
61 |
| |
|
62 |
0
| public void paintComponent(Graphics g)
|
|
63 |
| { |
|
64 |
0
| int width = this.getSize().width;
|
|
65 |
0
| int x = (width - this.fixedSize ) / 2;
|
|
66 |
0
| int height = this.getSize().height;
|
|
67 |
0
| int y = (height - this.fixedSize) / 2;
|
|
68 |
| |
|
69 |
0
| Color oldColor = g.getColor();
|
|
70 |
| |
|
71 |
0
| Graphics2D g2d = (Graphics2D) g;
|
|
72 |
0
| g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
73 |
| |
|
74 |
0
| g.setColor(this.ringBackgroundColor);
|
|
75 |
0
| g.fillOval(x, y, this.fixedSize-1, this.fixedSize-1);
|
|
76 |
0
| g.setColor(this.drawColor);
|
|
77 |
0
| g.drawOval(x, y, this.fixedSize-1, this.fixedSize-1);
|
|
78 |
0
| g.setColor(this.fillColor);
|
|
79 |
0
| g.fillOval(x + this.internalGap, y + this.internalGap, this.fixedSize-1 - 2*this.internalGap , this.fixedSize-1 - 2*this.internalGap);
|
|
80 |
0
| g.setColor(this.drawColor);
|
|
81 |
0
| g.drawOval(x + this.internalGap, y + this.internalGap, this.fixedSize-1 - 2*this.internalGap, this.fixedSize-1 - 2*this.internalGap);
|
|
82 |
| |
|
83 |
0
| g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
|
|
84 |
0
| g.setColor(oldColor);
|
|
85 |
| |
|
86 |
| } |
|
87 |
| |
|
88 |
| } |