]> de.git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/ui/swinggui/StatusBar.java
fix lots of CRLFs
[xonotic/xonotic.git] / misc / tools / NexuizDemoRecorder / main / src / main / java / com / nexuiz / demorecorder / ui / swinggui / StatusBar.java
1 package com.nexuiz.demorecorder.ui.swinggui;
2
3 import java.awt.BorderLayout;
4 import java.awt.Color;
5 import java.awt.Component;
6 import java.awt.Graphics;
7 import java.awt.SystemColor;
8
9 import javax.swing.BorderFactory;
10 import javax.swing.Icon;
11 import javax.swing.JLabel;
12 import javax.swing.JPanel;
13
14 public class StatusBar extends JPanel {
15
16         private static final long serialVersionUID = -1471757496863555741L;
17         private JLabel currentActivity = null;
18         
19         private static final String STATE_IDLE = "Idle";
20         private static final String STATE_WORKING = "Working";
21
22         public StatusBar() {
23                 BorderLayout borderLayout = new BorderLayout(0, 0);
24                 setLayout(borderLayout);
25                 JPanel rightPanel = new JPanel(new BorderLayout());
26                 rightPanel.add(new JLabel(new AngledLinesWindowsCornerIcon()), BorderLayout.SOUTH);
27                 rightPanel.setOpaque(false);
28
29                 add(rightPanel, BorderLayout.EAST);
30
31                 this.currentActivity = new JLabel("Idle");
32                 add(this.currentActivity, BorderLayout.WEST);
33                 setBackground(SystemColor.control);
34                 setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.black));
35         }
36         
37         /**
38          * Sets the state/display of the status bar to "idle" (false) or "working" (true).
39          * @param state
40          */
41         public void showState(boolean state) {
42                 if (state) {
43                         currentActivity.setText(STATE_WORKING);
44                 } else {
45                         currentActivity.setText(STATE_IDLE);
46                 }
47         }
48
49         private static class AngledLinesWindowsCornerIcon implements Icon {
50                 private static final Color WHITE_LINE_COLOR = new Color(255, 255, 255);
51
52                 private static final Color GRAY_LINE_COLOR = new Color(172, 168, 153);
53                 private static final int WIDTH = 13;
54
55                 private static final int HEIGHT = 13;
56
57                 public int getIconHeight() {
58                         return HEIGHT;
59                 }
60
61                 public int getIconWidth() {
62                         return WIDTH;
63                 }
64
65                 public void paintIcon(Component c, Graphics g, int x, int y) {
66
67                         g.setColor(WHITE_LINE_COLOR);
68                         g.drawLine(0, 12, 12, 0);
69                         g.drawLine(5, 12, 12, 5);
70                         g.drawLine(10, 12, 12, 10);
71
72                         g.setColor(GRAY_LINE_COLOR);
73                         g.drawLine(1, 12, 12, 1);
74                         g.drawLine(2, 12, 12, 2);
75                         g.drawLine(3, 12, 12, 3);
76
77                         g.drawLine(6, 12, 12, 6);
78                         g.drawLine(7, 12, 12, 7);
79                         g.drawLine(8, 12, 12, 8);
80
81                         g.drawLine(11, 12, 12, 11);
82                         g.drawLine(12, 12, 12, 12);
83
84                 }
85         }
86 }