/*
 * TableCellRenderer.java
 *
 * Created on September 29, 2006, 11:05 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.businesslogic.ireport.gui.sheet;

import it.businesslogic.ireport.chart.MeterInterval;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author gtoffoli
 */
public class MeterIntervalTableCellRenderer extends DefaultTableCellRenderer {
    
    /** Creates a new instance of TableCellRenderer */
    public MeterIntervalTableCellRenderer() {
        super();
    }
    
    public Component getTableCellRendererComponent(JTable table, 
                                            Object value,
                                            boolean isSelected,
                                            boolean hasFocus, int row, int column)
    {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus,row, column);
        
        if (value instanceof MeterInterval && value != null)
        {
            setText( ((MeterInterval)value).getLabel() );

            setIcon( new ColorIcon( ( (MeterInterval)value).getColor() ));
            
        }
        
        return this;
    }
}
