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

Last change on this file since 298 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 883 bytes
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui;
3
4import java.awt.Component;
5
6import javax.swing.DefaultListCellRenderer;
7import javax.swing.JList;
8
9import org.openstreetmap.josm.data.osm.OsmPrimitive;
10import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
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 NameVisitor visitor = new NameVisitor();
19
20 @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
21 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
22 if (value != null) {
23 ((OsmPrimitive)value).visit(visitor);
24 setText(visitor.name);
25 setIcon(visitor.icon);
26 }
27 return this;
28 }
29}
Note: See TracBrowser for help on using the repository browser.