/*
 * TreeUI.java
 *
 * Created on September 8, 2005, 5:01 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package net.ws.compendium;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreePath;

/**
 *
 * @author adam
 */
public class TigerTreeUI extends BasicTreeUI{
    
    
    /** Creates a new instance of TreeUI */
    public TigerTreeUI() {
        super();
    }

    /*protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, 
            Rectangle bounds, TreePath path, int row, boolean isExpanded,
            boolean hasBeenExpanded, boolean isLeaf) {

        super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, 
                hasBeenExpanded, isLeaf);
    }*/

    protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int param, boolean param6, boolean param7, boolean param8) {

        boolean selected = treeSelectionModel.isPathSelected(path);
        
        if(selected){
            DefaultTreeCellRenderer ren = (DefaultTreeCellRenderer)tree.getCellRenderer();
            Color c = ren.getBackgroundSelectionColor();
            g.setColor(c);
            g.fillRect(0,bounds.y,clipBounds.width,bounds.height);
        }
        // Do not call super. We don't want the lines.
    }

    protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, 
            Insets insets, TreePath path) {
        // Do not call super. We don't want the lines.
    }

    protected void paintExpandControl(Graphics g, Rectangle clipBounds, 
            Insets insets, Rectangle bounds, TreePath path, int row, 
            boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
        
        super.paintExpandControl(g, clipBounds, insets, bounds, path, row, 
                isExpanded, hasBeenExpanded, isLeaf);
    }

    public void installUI(javax.swing.JComponent jComponent) {

        super.installUI(jComponent);
        try{
            expandedIcon = new ImageIcon(getClass().getResource("images/expanded.png"));
            collapsedIcon = new ImageIcon(getClass().getResource("images/collapsed.png"));
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
}
