1 package nl.tudelft.simulation.introspection.mapping;
2
3 import java.awt.Color;
4 import java.awt.Component;
5
6 import javax.swing.BorderFactory;
7 import javax.swing.JPanel;
8 import javax.swing.JTable;
9 import javax.swing.table.TableCellRenderer;
10
11 /***
12 * The color renderer
13 * <p>
14 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
15 * University of Technology </a>, the Netherlands. <br>
16 * See for project information <a
17 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
18 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
19 * License (GPL) </a>, no warranty <br>
20 *
21 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
22 * Jacobs </a>
23 * @version 1.2 Apr 15, 2004
24 * @since 1.4
25 */
26 public class MyColorRenderer implements TableCellRenderer
27 {
28 /***
29 * @see javax.swing.table.TableCellRenderer
30 * #getTableCellRendererComponent(javax.swing.JTable, java.lang.Object,
31 * boolean, boolean, int, int)
32 */
33 public Component getTableCellRendererComponent(final JTable table,
34 final Object value, final boolean isSelected,
35 final boolean hasFocus, final int row, final int column)
36 {
37 JPanel result = new JPanel();
38 Color color = (Color) value;
39 if (isSelected)
40 {
41 color = color.darker();
42 }
43 if (hasFocus)
44 {
45 result.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
46 }
47 result.setBackground(color);
48 return result;
49 }
50 }