/*
 * EstruturaProcessoRenderer.java
 *
 * Created on 29 de Abril de 2007, 18:52
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package siprp.medicina.processo.estrutura;

import java.awt.Color;
import java.awt.Component;

import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 *
 * @author Frederico
 */
public class EstruturaProcessoRenderer extends DefaultTreeCellRenderer
{
	
	/** Creates a new instance of EstruturaProcessoRenderer */
	public EstruturaProcessoRenderer()
	{
	}
	
	public Component getTreeCellRendererComponent(
                        JTree tree,
                        Object value,
                        boolean sel,
                        boolean expanded,
                        boolean leaf,
                        int row,
                        boolean hasFocus) {

        super.getTreeCellRendererComponent(
                        tree, value, sel,
                        expanded, leaf, row,
                        hasFocus);
		EstruturaProcessoMutableTreeNode node = ( EstruturaProcessoMutableTreeNode ) value;
		Icon icon = node.getIcon();
		Color color = node.getColor();
		if( icon != null )
		{
			setIcon( icon );
		}
		if(color != null)
		{
			setForeground( color );
		}

        return this;
    }
}
