/*
 *      Luis Israel Diéguez Arjona
 *      Sonia Cejas Soria
 *      Sergio Cabello García
 *      María José González Cordero
 *
 *      Ingeniería del Software de Gestión II
 *      Ingeniería Técnica Informática de Gestión
 *      Universidad de Huelva
 */

package controlador;

import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;



public class RendererArbol extends DefaultTreeCellRenderer{

    public RendererArbol() { }


    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus){

        super.getTreeCellRendererComponent(tree,value,selected,expanded,leaf,row,hasFocus);
        DefaultMutableTreeNode nodo = (DefaultMutableTreeNode)value;

        if(nodo.getUserObject().toString().contains("SEC-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Seccion.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("APE-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Apendice.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("PRG-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Parrafo.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("GRF-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Imagen.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("ORG-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Organizacion.png"));
            setIcon(cu);
        }

       if(nodo.getUserObject().toString().contains("STK-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Participante.png"));
            setIcon(cu);
        }
        if(nodo.getUserObject().toString().contains("MET-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Reunion.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("OBJ-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Objetivo.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("ACT-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Actor.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("IRQ-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/ReqInformacion.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("CRQ-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/ReqRestriccion.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("UC-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/CasoUso.png"));
            setIcon(cu);
        }

         if(nodo.getUserObject().toString().contains("UCP-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Paso.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("UCE-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Excepcion.png"));
            setIcon(cu);
        }

        if(nodo.getUserObject().toString().contains("FRQ-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/ReqFuncional.png"));
            setIcon(cu);
        }

         if(nodo.getUserObject().toString().contains("NFR-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/ReqNoFuncional.png"));
            setIcon(cu);
        }
        
         if(nodo.getUserObject().toString().contains("TRM-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/MatrizRastreabilidad.png"));
            setIcon(cu);
        }
        
         if(nodo.getUserObject().toString().contains("DTE-")){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/DatoEspecifico.png"));
            setIcon(cu);
        }

         if(nodo.isRoot()){
            ImageIcon cu= new ImageIcon(getClass().getResource("/vista/icons/Seccion.png"));
            setIcon(cu);
        }

        return this;

    }
}
