package Common.Visual.Trees;
import Common.MainModule_;
import Common.Visual.Fonts.VisualiserFonts;
import Common.Visual.Selectable;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class SelectionTreeCellRenderer extends StyledTreeCellRenderer {
    public java.awt.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);
        Object o = ((DefaultMutableTreeNode) value).getUserObject();
        if (o instanceof Selectable) {
            Selectable selectable = (Selectable) o;
            setText(selectable.getSelectionText());
            setIcon(selectable.GetSelectionIcon());
        } else {
            setFont(MainModule_.instance.getUI().getTheme().Fonts.get(VisualiserFonts.TreeItalic));
            setIcon(null);
        }
        setForeground(tree.getForeground());
        return this;
    }
}
