package kiyut.alkitab.swing;

import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import org.crosswire.jsword.book.Book;

public class BooksTreeCellRenderer extends DefaultTreeCellRenderer {
    
    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
        Object obj = treeNode.getUserObject();
        
        if (obj instanceof Book) {
            Book book = (Book)obj;
            value = book.getInitials() + " - " + book.toString();
        } 
        
        super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
        
        return this;
    }
}
