source: josm/src/org/openstreetmap/josm/gui/OsmPrimitivRenderer.java@ 86

Last change on this file since 86 was 86, checked in by imi, 19 years ago
  • added conflicts and resolve conflict dialog

This is one of those "changed everything" checkpoint.

File size: 948 bytes
Line 
1package org.openstreetmap.josm.gui;
2
3import java.awt.Component;
4
5import javax.swing.DefaultListCellRenderer;
6import javax.swing.JLabel;
7import javax.swing.JList;
8
9import org.openstreetmap.josm.data.osm.OsmPrimitive;
10import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor;
11
12/**
13 * Renderer that renders the objects from an OsmPrimitive as data.
14 * @author imi
15 */
16public class OsmPrimitivRenderer extends DefaultListCellRenderer {
17
18 private SelectionComponentVisitor visitor = new SelectionComponentVisitor();
19
20 @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
21 Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
22 if (c instanceof JLabel && value != null) {
23 ((OsmPrimitive)value).visit(visitor);
24 ((JLabel)c).setText(visitor.name);
25 ((JLabel)c).setIcon(visitor.icon);
26 }
27 return c;
28 }
29}
Note: See TracBrowser for help on using the repository browser.