1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.api.RendererListenerI; |
24 |
|
|
25 |
|
import java.awt.BorderLayout; |
26 |
|
import java.awt.CardLayout; |
27 |
|
import java.awt.Color; |
28 |
|
import java.awt.Dimension; |
29 |
|
import java.beans.PropertyChangeEvent; |
30 |
|
|
31 |
|
import javax.swing.BorderFactory; |
32 |
|
import javax.swing.JLabel; |
33 |
|
import javax.swing.JPanel; |
34 |
|
import javax.swing.JProgressBar; |
35 |
|
import javax.swing.border.EmptyBorder; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@author |
42 |
|
|
43 |
|
|
|
|
| 97.6% |
Uncovered Elements: 1 (41) |
Complexity: 7 |
Complexity Density: 0.22 |
|
44 |
|
public class ProgressPanel extends JPanel implements RendererListenerI |
45 |
|
{ |
46 |
|
|
47 |
|
private final int MAXVALUE = 100; |
48 |
|
|
49 |
|
private final String VISIBLE = "VISIBLE"; |
50 |
|
|
51 |
|
private final String INVISIBLE = "INVISIBLE"; |
52 |
|
|
53 |
|
|
54 |
|
private String eventName; |
55 |
|
|
56 |
|
private JProgressBar progressBar; |
57 |
|
|
58 |
|
private JLabel progressLabel; |
59 |
|
|
60 |
|
private JPanel labelPanel = new JPanel(); |
61 |
|
|
62 |
|
private CardLayout labelLayout = new CardLayout(); |
63 |
|
|
64 |
|
private JPanel barPanel = new JPanel(); |
65 |
|
|
66 |
|
private CardLayout barLayout = new CardLayout(); |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
@param |
72 |
|
|
73 |
|
@param |
74 |
|
|
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
|
76 |
43 |
public ProgressPanel(String eventPropertyName, String label, int maxwidth)... |
77 |
|
{ |
78 |
43 |
super(new BorderLayout(10, 0)); |
79 |
43 |
setBorder(new EmptyBorder(0, 3, 0, 0)); |
80 |
|
|
81 |
43 |
eventName = eventPropertyName; |
82 |
43 |
String labelText = label; |
83 |
|
|
84 |
43 |
final int w = maxwidth; |
85 |
|
|
86 |
43 |
progressBar = new JProgressBar() |
87 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
43 |
@Override... |
89 |
|
public Dimension getMaximumSize() |
90 |
|
{ |
91 |
43 |
return new Dimension(w, 1); |
92 |
|
} |
93 |
|
}; |
94 |
43 |
progressBar.setMinimum(0); |
95 |
43 |
progressBar.setPreferredSize(progressBar.getMaximumSize()); |
96 |
43 |
progressLabel = new JLabel(labelText); |
97 |
43 |
progressLabel.setFont(new java.awt.Font("Verdana", 0, 11)); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
43 |
labelPanel.setLayout(labelLayout); |
102 |
43 |
barPanel.setLayout(barLayout); |
103 |
|
|
104 |
43 |
labelPanel.add(progressLabel, VISIBLE); |
105 |
43 |
labelPanel.add(new JPanel(), INVISIBLE); |
106 |
43 |
barPanel.add(progressBar, VISIBLE); |
107 |
43 |
barPanel.add(new JPanel(), INVISIBLE); |
108 |
|
|
109 |
43 |
labelLayout.show(labelPanel, VISIBLE); |
110 |
43 |
barLayout.show(barPanel, VISIBLE); |
111 |
|
|
112 |
43 |
add(labelPanel, BorderLayout.WEST); |
113 |
43 |
add(barPanel, BorderLayout.CENTER); |
114 |
43 |
add(new JLabel(" "), BorderLayout.EAST); |
115 |
|
|
116 |
43 |
setBorder(BorderFactory.createLineBorder(Color.black)); |
117 |
|
|
118 |
|
} |
119 |
|
|
|
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
120 |
13243 |
@Override... |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
public void propertyChange(PropertyChangeEvent evt) |
126 |
|
{ |
127 |
13243 |
if (evt.getPropertyName().equals(eventName)) |
128 |
|
{ |
129 |
13243 |
int progress = (int) evt.getNewValue(); |
130 |
13243 |
progressBar.setValue(progress); |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
13243 |
if (progress < MAXVALUE && !progressBar.isVisible()) |
137 |
|
{ |
138 |
430 |
labelLayout.show(labelPanel, VISIBLE); |
139 |
430 |
barLayout.show(barPanel, VISIBLE); |
140 |
|
} |
141 |
13243 |
if (progress >= MAXVALUE) |
142 |
|
{ |
143 |
466 |
labelLayout.show(labelPanel, INVISIBLE); |
144 |
466 |
barLayout.show(barPanel, INVISIBLE); |
145 |
|
} |
146 |
|
} |
147 |
|
} |
148 |
|
} |