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

Last change on this file since 5899 was 5627, checked in by jttt, 11 years ago

use diff to show relation members in history dialog, jump to first change when different version is selected

  • 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 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
50 int row, int column) {
51
52 renderNode((TwoColumnDiff.Item)value, isSelected);
53 return this;
54 }
55}
Note: See TracBrowser for help on using the repository browser.