public static JPanel createBitratePanel(final Statistic statistic) {
JPanel result = new JPanel(new GridBagLayout());
StringCountRecord[] records = statistic
.getRecords(Statistic.MAP_BITRATE);
Arrays.sort(records, NUMBER_SORTER);
final DefaultListModel listModel = new DefaultListModel();
for (int i = 0; i < records.length; i++) {
listModel.addElement(records[i]);
}
final JList list = new JList(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel desc = new JLabel(LangageManager
.getProperty("statistic.categorydescription.bitrate"));
final JCheckBox compressBox = new JCheckBox(LangageManager
.getProperty("statistic.compressbitrates"));
compressBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent arg0) {
if (compressBox.isSelected()) {
StringCountRecord[] recs = statistic
.getRecords(Statistic.MAP_BITRATE);
String[] compressed = compressBitrates(recs);
listModel.removeAllElements();
for (int i = 0; i < compressed.length; i++) {
listModel.addElement(compressed[i]);
}
} else {
StringCountRecord[] recs = statistic
.getRecords(Statistic.MAP_BITRATE);
Arrays.sort(recs, NUMBER_SORTER);
listModel.removeAllElements();
for (int i = 0; i < recs.length; i++) {
listModel.addElement(recs[i]);
}
}
list.repaint();
}
});