    001// License: GPL. For details, see LICENSE file.
    002package org.openstreetmap.josm.plugins.streetside.gui;
    003
    004import java.awt.Component;
    005
    006import javax.swing.Icon;
    007import javax.swing.JTree;
    008import javax.swing.tree.DefaultTreeCellRenderer;
    009
    010import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    011import org.openstreetmap.josm.tools.ImageProvider;
    012
    013/**
    014 * Renders an item in a {@link JTree} that represents a {@link StreetsideAbstractImage}.
    015 */
    016public class StreetsideImageTreeCellRenderer extends DefaultTreeCellRenderer {
    017  private static final long serialVersionUID = 5359276673450659572L;
    018
    019  private static final Icon ICON = new ImageProvider("mapicon").setMaxSize(16).get();
    020
    021  @Override
    022  public Component getTreeCellRendererComponent(
    023    JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus
    024  ) {
    025    super.getTreeCellRendererComponent(tree, value.toString(), sel, expanded, leaf, row, hasFocus);
    026    setIcon(ICON);
    027    return this;
    028  }
    029}