import java.awt.*;
import javax.swing.*;

/**
 * A ListCellRenderer that can be used for a JList containing Shape objects.
 * 
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class ShapeCellRenderer extends ShapeLabel implements ListCellRenderer<Shape> 
{
  private static final long serialVersionUID = 1L;

  /**
   * Default Constructor.
   */
  public ShapeCellRenderer()
  {
    super();
  }
  
  /**
   * Get the component that does the rendering.
   *
   * @param table      The JTable that is being rendered
   * @param value      The value of the cell to be rendered
   * @param isSelected true if the cell is to be rendered with highlighting
   * @param hasFocise  true if the cell has the focus
   * @param row        The row of the cell being rendered
   * @param column     The column of the cell being rendered
   * @return           The Component to use as the renderer
   */
  public Component getListCellRendererComponent(JList<? extends Shape> list, Shape value, int index,
      boolean isSelected, boolean cellHasFocus)
  {
    if (isSelected) setBorder(BorderFactory.createLineBorder(list.getForeground()));
    else            setBorder(BorderFactory.createLineBorder(list.getBackground()));
    setShape(value);

    return this;
  }

}
