*/
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (mCache[row][column] != null) {
if (value instanceof Channel && ((ChannelLabel)mCache[row][column]).getChannel().equals(value)) {
mCache[row][column].setForeground(label.getForeground());
mCache[row][column].setBackground(label.getBackground());
return mCache[row][column];
} else if (value instanceof Program && mProgramPanel[row][column - 1].getProgram().equals(value)) {
if (mProgramPanel[row][column - 1].getHeight() < table.getRowHeight(row)) {
mProgramPanel[row][column - 1].setHeight(table.getRowHeight(row));
} else if (mProgramPanel[row][column - 1].getHeight() > table.getRowHeight(row)) {
int other = 0;
if (column == 2) {
other = 1;
}
int otherHeight = mProgramPanel[row][other].getHeight();
int height = Math.max(mProgramPanel[row][column - 1].getHeight(), Math.max(table.getRowHeight(row), otherHeight));
if (otherHeight < height) {
mProgramPanel[row][other].setHeight(height);
} else if (height < mProgramPanel[row][column - 1].getHeight()) {
mProgramPanel[row][column - 1].setHeight(height);
}
table.setRowHeight(row, height);
}
mProgramPanel[row][column - 1].setTextColor(label.getForeground());
mProgramPanel[row][column - 1].setBackground(label.getBackground());
mCache[row][column].setForeground(label.getForeground());
mCache[row][column].setBackground(label.getBackground());
return mCache[row][column];
} else {
mCache[row][column] = null;
}
}
if (value instanceof Channel) {
Channel channel = (Channel) value;
ChannelLabel channelLabel = new ChannelLabel();
channelLabel.setChannel(channel);
channelLabel.setOpaque(label.isOpaque());
channelLabel.setForeground(label.getForeground());
channelLabel.setBackground(label.getBackground());
mCache[row][0] = channelLabel;
updateHeight(table, row);
return channelLabel;
} else if (value instanceof Program) {
int index = column - 1;
Program program = (Program) value;
mProgramPanel[row][index] = new ProgramPanel(program, new ProgramPanelSettings(ListViewPlugin.getInstance().getPictureSettings(),false, ProgramPanelSettings.X_AXIS));
JPanel rpanel = new JPanel(new BorderLayout());
rpanel.add(mProgramPanel[row][index], BorderLayout.CENTER);
mProgramPanel[row][index].setTextColor(label.getForeground());
if (ListViewPlugin.PROGRAMTABLEWIDTH > table.getColumnModel().getColumn(column).getMinWidth()) {
int width = ListViewPlugin.PROGRAMTABLEWIDTH;
table.getColumnModel().getColumn(column).setMinWidth(width);
}
mCache[row][column] = rpanel;
mCache[row][column].setForeground(label.getForeground());
mCache[row][column].setBackground(label.getBackground());
updateHeight(table, row);
return rpanel;
}
JPanel panel = new JPanel(new BorderLayout());
panel.add(label, BorderLayout.CENTER);
panel.setBackground(label.getBackground());
return panel;
}