1 package fr.ifremer.quadrige3.ui.swing.plaf;
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 import org.jdesktop.jxlayer.JXLayer;
28
29 import javax.swing.JComponent;
30 import java.awt.*;
31 import java.awt.event.ActionEvent;
32
33
34
35
36
37
38
39 public class WaitBlockingLayerUI extends ComponentBlockingLayerUI {
40
41 private int angle;
42
43 private static final int MAX_DIMENSION = 150;
44
45
46
47
48 public WaitBlockingLayerUI() {
49 }
50
51
52 @Override
53 protected void paintLayer(Graphics2D g2, JXLayer<? extends JComponent> l) {
54 super.paintLayer(g2, l);
55 if (!running || !started) {
56 return;
57 }
58
59
60 int s = Math.min(Math.min(l.getWidth(), MAX_DIMENSION), Math.min(l.getHeight(), MAX_DIMENSION)) / 5;
61 int cx = l.getWidth() / 2;
62 int cy = l.getHeight() / 2;
63 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
64 g2.setStroke(new BasicStroke(s / 4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
65 g2.setPaint(Color.white);
66 g2.rotate(Math.PI * angle / 180, cx, cy);
67 for (int i = 0; i < 12; i++) {
68 float scale = (11.0f - (float) i) / 11.0f;
69 g2.drawLine(cx + s, cy, cx + s * 2, cy);
70 g2.rotate(-Math.PI / 6, cx, cy);
71 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, scale * getFade()));
72 }
73 }
74
75
76 @Override
77 public void actionPerformed(ActionEvent e) {
78 super.actionPerformed(e);
79 if (running) {
80 angle += 3;
81 if (angle >= 360) angle = 0;
82 }
83 }
84
85 }
86