Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StateBarComponent |
|
| 1.0;1 | ||||
StateBarComponent$Position |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.view.able.components; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import javax.swing.JComponent; | |
20 | import java.awt.Component; | |
21 | ||
22 | /** | |
23 | * A state bar component. | |
24 | * | |
25 | * @author Baptiste Wicht | |
26 | */ | |
27 | public final class StateBarComponent { | |
28 | private final JComponent component; | |
29 | private final Position position; | |
30 | ||
31 | /** | |
32 | * A position for state bar component. | |
33 | * | |
34 | * @author Baptiste Wicht | |
35 | */ | |
36 | 0 | public enum Position { |
37 | 0 | LEFT, |
38 | 0 | CENTER, |
39 | 0 | RIGHT, |
40 | } | |
41 | ||
42 | /** | |
43 | * Construct a new StateBarComponent. | |
44 | * | |
45 | * @param component The component. | |
46 | * @param position The position of the component. | |
47 | */ | |
48 | public StateBarComponent(JComponent component, Position position) { | |
49 | 0 | super(); |
50 | ||
51 | 0 | this.component = component; |
52 | 0 | this.position = position; |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * Construct a new StateBarComponent with a default position. | |
57 | * | |
58 | * @param component The component. | |
59 | */ | |
60 | public StateBarComponent(JComponent component) { | |
61 | 0 | this(component, Position.LEFT); |
62 | 0 | } |
63 | ||
64 | /** | |
65 | * Return the component. | |
66 | * | |
67 | * @return The component. | |
68 | */ | |
69 | public Component getComponent() { | |
70 | 0 | return component; |
71 | } | |
72 | ||
73 | /** | |
74 | * Return the position of the state bar component. | |
75 | * | |
76 | * @return The position of the component. | |
77 | */ | |
78 | public Position getPosition() { | |
79 | 0 | return position; |
80 | } | |
81 | ||
82 | /** | |
83 | * Indicate if the state bar is positioned to the left. | |
84 | * | |
85 | * @return true if the state bar is positioned to the left. | |
86 | */ | |
87 | public boolean isLeft() { | |
88 | 0 | return position == Position.LEFT; |
89 | } | |
90 | ||
91 | /** | |
92 | * Indicate if the state bar is positioned to the right. | |
93 | * | |
94 | * @return true if the state bar is positioned to the right. | |
95 | */ | |
96 | public boolean isCenter() { | |
97 | 0 | return position == Position.CENTER; |
98 | } | |
99 | ||
100 | /** | |
101 | * Indicate if the state bar is positioned to the center. | |
102 | * | |
103 | * @return true if the state bar is positioned to the center. | |
104 | */ | |
105 | public boolean isRight() { | |
106 | 0 | return position == Position.RIGHT; |
107 | } | |
108 | } |