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
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import java.awt.Component;
|
---|
5 |
|
---|
6 | import javax.swing.DefaultListCellRenderer;
|
---|
7 | import javax.swing.JList;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
10 | import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Renderer that renders the objects from an OsmPrimitive as data.
|
---|
14 | * @author imi
|
---|
15 | */
|
---|
16 | public 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.