package _VisualDVM.ProjectData.SapforData.Arrays.UI;
import Common.MainModule_;
import Common.Visual.Fonts.VisualiserFonts;
import Common.Visual.Trees.StyledTreeCellRenderer;
import _VisualDVM.ProjectData.SapforData.Regions.ParallelRegion;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class RendererTreeRule 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 String) {
            setFont(MainModule_.instance.getUI().getTheme().Fonts.get(VisualiserFonts.Distribution));
        } else if (o instanceof ParallelRegion)
            setFont(MainModule_.instance.getUI().getTheme().Fonts.get(VisualiserFonts.TreeItalic));
        setForeground(tree.getForeground());
        return this;
    }
}
