/*
 * 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.marcacoes;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

import siprp.higiene.*;

/**
 *
 * @author Frederico
 */
public class TecnicoRenderer
	implements TableCellRenderer
{
	protected JLabel labels[];
	protected Color defaultColor;
	
	/** Creates a new instance of DiaRenderer */
	public TecnicoRenderer()
	{
		labels = new JLabel[ 3 ];
		for( int n = 0; n < 3; n++ )
		{
			labels[ n ] = new JLabel();
		}
		defaultColor = labels[ 0 ].getBackground();
		labels[ 2 ].setOpaque( true );
	}

	public Component getTableCellRendererComponent( JTable table, Object value, 
													boolean isSelected, 
													boolean hasFocus, 
													int row, int column )
	{
		switch( column )
		{
			case 2:
				labels[ 2 ].setText( "  " );
				labels[ 2 ].setBackground( value == null ? defaultColor : 
											HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ] );
				break;
			default:
				labels[ column ].setText( ( String ) value );
				break;
		}
		return labels[ column ];
	}
}
