source: josm/trunk/src/org/openstreetmap/josm/gui/history/NodeListTableCellRenderer.java@ 6827

Last change on this file since 6827 was 6084, checked in by bastiK, 11 years ago

see #8902 - add missing @Override annotations (patch by shinigami)

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Color;
7import java.awt.Component;
8
9import javax.swing.ImageIcon;
10import javax.swing.JLabel;
11import javax.swing.JTable;
12import javax.swing.table.TableCellRenderer;
13
14import org.openstreetmap.josm.gui.history.TwoColumnDiff.Item.DiffItemType;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17public class NodeListTableCellRenderer extends JLabel implements TableCellRenderer {
18
19 public final static Color BGCOLOR_SELECTED = new Color(143,170,255);
20
21 private ImageIcon nodeIcon;
22
23 public NodeListTableCellRenderer(){
24 setOpaque(true);
25 nodeIcon = ImageProvider.get("data", "node");
26 setIcon(nodeIcon);
27 }
28
29 protected void renderNode(TwoColumnDiff.Item item, boolean isSelected) {
30 String text = "";
31 Color bgColor = Color.WHITE;
32 setIcon(nodeIcon);
33 if (item.value != null) {
34 text = tr("Node {0}", item.value.toString());
35 }
36 bgColor = item.state.getColor();
37 if (item.state == DiffItemType.EMPTY) {
38 text = "";
39 setIcon(null);
40 }
41 if (isSelected) {
42 bgColor = BGCOLOR_SELECTED;
43 }
44 setText(text);
45 setBackground(bgColor);
46 }
47
48 // Warning: The model pads with null-rows to match the size of the opposite table. 'value' could be null
49 @Override
50 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
51 int row, int column) {
52
53 renderNode((TwoColumnDiff.Item)value, isSelected);
54 return this;
55 }
56}
Note: See TracBrowser for help on using the repository browser.