package siprp.higiene.mapa;

import java.awt.Component;

import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
/**
 *
 * @author Frederico
 */
public class DiaRenderer extends DefaultCellEditor implements TableCellRenderer
{

	private static final long serialVersionUID = 1L;
	
	protected JLabel diaLabel;
	protected DiaPanel diaPanel;
	
	/** Creates a new instance of DiaRenderer */
	public DiaRenderer()
	{
		super( new JCheckBox() );
		diaLabel = new JLabel();
		diaPanel = new DiaPanel();
	}

	public Component getTableCellRendererComponent( JTable table, Object value, 
													boolean isSelected, 
													boolean hasFocus, 
													int row, int column )
	{
		if( column == 0 )
		{
			diaLabel.setText( "" + value );
			return diaLabel;
		}
		diaPanel.fill( value );
		return diaPanel;
	}
	
	public Component getTableCellEditorComponent( JTable table, Object value, 
													boolean isSelected, 
													int row, int column )
	{
		if( column == 0 )
		{
			diaLabel.setText( "" + value );
			return diaLabel;
		}
		diaPanel.fill( value );
		return diaPanel;
	}
	
	public Object getCellEditorValue()
	{
		return diaPanel.save();
	}
}
