/*
 * DiaRenderer.java
 *
 * Created on 8 de Fevereiro de 2006, 21:45
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package siprp.higiene.mapa;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.util.*;
/**
 *
 * @author Frederico
 */
public class DiaRenderer extends DefaultCellEditor
	implements TableCellRenderer
{
	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();
	}
}
