use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.
the class ComponentCellRenderer method getTableCellRendererComponent.
/**
* @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
* java.lang.Object, boolean, boolean, int, int)
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JPanel newPanel = new JPanel();
newPanel.setLayout(new OverlayLayout(newPanel));
Color bgColor;
if (isSelected)
bgColor = table.getSelectionBackground();
else
bgColor = table.getBackground();
newPanel.setBackground(bgColor);
if (hasFocus) {
Border border = null;
if (isSelected)
border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
if (border == null)
border = UIManager.getBorder("Table.focusCellHighlightBorder");
if (border != null)
newPanel.setBorder(border);
}
if (value != null) {
if (value instanceof JComponent) {
newPanel.add((JComponent) value);
} else {
JLabel newLabel = new JLabel();
if (value instanceof IIsotope) {
IIsotope is = (IIsotope) value;
newLabel.setText(is.getSymbol());
} else {
newLabel.setText(value.toString());
}
if (font != null)
newLabel.setFont(font);
else if (table.getFont() != null)
newLabel.setFont(table.getFont());
newPanel.add(newLabel);
}
if (createTooltips)
newPanel.setToolTipText(value.toString());
}
return newPanel;
}
Aggregations