001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.widgets;
003
004import java.awt.Component;
005
006import javax.swing.JList;
007import javax.swing.ListCellRenderer;
008
009/**
010 * A convenience list cell renderer to override.
011 *
012 * @param <E> The type of the ListCellRenderer
013 * @since 18221
014 */
015public class JosmListCellRenderer<E> implements ListCellRenderer<E> {
016    protected ListCellRenderer<? super E> renderer;
017    protected Component component;
018
019    /**
020     * Constructor.
021     * @param component the component
022     * @param renderer The inner renderer
023     */
024    public JosmListCellRenderer(Component component, ListCellRenderer<? super E> renderer) {
025        this.component = component;
026        this.renderer = renderer;
027    }
028
029    @Override
030    public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
031        Component l = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
032        l.setComponentOrientation(component.getComponentOrientation());
033        return l;
034    }
035}