/*
Tiamat - a role-playing game framework
ScriptTableCellRenderer.java - cell renderer for ScriptTable
 
 Copyright  (C) 2006 Hugues Johnson
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.huguesjohnson.tiamat.tools.scriptTable;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;

/**
 * ScriptTableCellRenderer - cell renderer for ScriptTable
 * @author Hugues Johnson
 */
public class ScriptTableCellRenderer extends JTextArea implements TableCellRenderer{
	/* Determines if a de-serialized file is compatible with this class. See <a href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html">Java Object Serialization Specifications</a>. */
	private static final long serialVersionUID=-1202225877037279612L;

	public ScriptTableCellRenderer(){
		this.setOpaque(true);
	    this.setLineWrap(true);
	    this.setWrapStyleWord(true);
	}
	
	public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int rowIndex,int columnIndex){
		if(isSelected){
			this.setBackground(UIManager.getColor("Label.foreground"));
			this.setForeground(UIManager.getColor("Label.background"));
		} else{
			this.setBackground(UIManager.getColor("Label.background"));
			this.setForeground(UIManager.getColor("Label.foreground"));
		}
		this.setText(value.toString());
		this.setToolTipText((String)value);
		return(this);
	}
}