* @see ListSelectionModel
* @see ListModel
*/
public Component getListCellRendererComponent(final JList list, Object value, final int index, boolean isSelected,
boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Program) {
Program program = (Program) value;
Insets borderInsets = label.getBorder().getBorderInsets(label);
mProgramPanel.setWidth(list.getWidth() - borderInsets.left - borderInsets.right);
mProgramPanel.setProgram(program);
mProgramPanel.setPaintExpiredProgramsPale(!isSelected);
mProgramPanel.setTextColor(label.getForeground());
mProgramPanel.setBackground(label.getBackground());
if (!mProgramSet.contains(program)) {
mProgramSet.add(program);
program.addChangeListener(new ProgramListChangeListener(list));
}
StringBuilder labelString = new StringBuilder();
int days = program.getDate().getNumberOfDaysSince(Date.getCurrentDate());
switch (days) {
case -1: {
labelString.append(Localizer.getLocalization(Localizer.I18N_YESTERDAY));
labelString.append(", ").append(program.getDateString());
break;
}
case 0: {
labelString.append(Localizer.getLocalization(Localizer.I18N_TODAY));
labelString.append(", ").append(program.getDateString());
break;
}
case 1: {
labelString.append(Localizer.getLocalization(Localizer.I18N_TOMORROW));
labelString.append(", ").append(program.getDateString());
break;
}
default: {
labelString.append(program.getDate().toString());
}
}
labelString.append(" - ").append(program.getChannel().getName());
mHeaderLb.setText(labelString.toString());
if (program.isExpired() && !isSelected) {
mHeaderLb.setForeground(Color.gray);
} else {
mHeaderLb.setForeground(label.getForeground());
}
mMainPanel.setBackground(label.getBackground());
if (isSelected) {
mMainPanel.setForeground(label.getForeground());
}
mMainPanel.setEnabled(label.isEnabled());
mMainPanel.setBorder(label.getBorder());
if (((index & 1) == 1) && (!isSelected) && program.getMarkPriority() < Program.MIN_MARK_PRIORITY) {
mMainPanel.setBackground(program.isExpired() ? SECOND_ROW_COLOR_EXPIRED : SECOND_ROW_COLOR);
}