1
2 package hoplugins.trainingExperience.ui.bar;
3
4 import java.awt.BorderLayout;
5 import java.awt.Color;
6
7 import javax.swing.JPanel;
8
9
10 /***
11 * VerticalIndicator that show percentage of training
12 *
13 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
14 */
15 public class VerticalIndicator extends JPanel {
16
17
18 private float actual;
19 private int total;
20
21
22
23 /***
24 * Creates a new VerticalIndicator object.
25 *
26 * @param _actual actual points
27 * @param _total skillup points
28 */
29 public VerticalIndicator(float _actual, int _total) {
30 super();
31 setLayout(new BorderLayout());
32 setOpaque(false);
33 this.actual = _actual;
34 this.total = _total;
35
36 if (actual > 0) {
37 int pct = (int) (actual / total * 100);
38
39 if (pct > 100) {
40 pct = 100;
41 }
42
43 StateBar bar = new StateBar(pct, 100, Color.GREEN, Color.RED);
44
45 bar.setOpaque(false);
46 bar.setBackground(Color.YELLOW);
47 add(bar, BorderLayout.CENTER);
48 }
49 }
50
51
52
53 /***
54 * Get Training Percentage
55 *
56 * @return
57 */
58 public double getPercentage() {
59 return actual / total * 100d;
60 }
61
62 /***
63 * Get Text describing training situation
64 *
65 * @return
66 */
67 public String getText() {
68 return actual + "(" + total + ")";
69 }
70
71 /***
72 * Return toolTip text
73 *
74 * @return
75 */
76 public String getToolTipText() {
77 return actual + "(" + total + ")";
78 }
79
80 /***
81 * Get number of training points for skillup
82 *
83 * @return
84 */
85 public double getTotal() {
86 return total;
87 }
88 }