Search in sources :

Example 1 with ListItem

use of main.swing.generic.components.list.ListItem in project Eidolons by IDemiurge.

the class AV_TreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (tree == null) {
        LogMaster.log(1, "NULL TREE!");
        return null;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    String typeName = node.toString();
    ObjType type = null;
    String parent = null;
    try {
        parent = ((DefaultMutableTreeNode) node.getParent()).getUserObject().toString();
    } catch (Exception e) {
    }
    try {
        if (DataManager.isTypeName(typeName, TYPE))
            if (workspace != null) {
                type = DataManager.getType(typeName, workspace.getOBJ_TYPE(typeName, parent));
            } else {
                type = DataManager.getType(typeName, TYPE);
            }
        if (type == null) {
            if (node.isLeaf()) {
                LogMaster.log(1, "No such type: " + " " + typeName);
            }
            return getDefaultComp(tree, value, selected, expanded, leaf, row, hasFocus);
        }
        Image img = ImageManager.getImage(type.getImagePath());
        if (img == null) {
            // typeName);
            return getDefaultComp(tree, value, selected, expanded, leaf, row, hasFocus);
        }
        size = Math.min(getMaxTreeIconSize(), img.getWidth(null));
        G_Panel comp = new G_Panel();
        ListItem<ObjType> item = new ListItem<>(type, selected, hasFocus, size);
        comp.add(item, "id item, pos 0 0");
        JLabel lbl = new JLabel(typeName);
        if (selected || hasFocus) {
            Color aspectColor = ColorManager.getAspectColor(type);
            Color bgColor = ColorManager.OBSIDIAN;
            // if (colorsInverted) {
            // bgColor = ColorManager.GOLDEN_WHITE;
            // aspectColor = ColorManager.getDarkerColor(aspectColor, 50);
            // }
            lbl.setForeground(aspectColor);
            lbl.setBackground(bgColor);
        } else if (colorsInverted) {
            lbl.setForeground(ColorManager.GOLDEN_WHITE);
        }
        comp.add(lbl, "pos item.x2+" + FontMaster.SIZE / 4 + " item.y2/2-" + FontMaster.SIZE / 2 + "");
        return comp;
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
        return getDefaultComp(tree, value, selected, expanded, leaf, row, hasFocus);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ObjType(main.entity.type.ObjType) G_Panel(main.swing.generic.components.G_Panel) ListItem(main.swing.generic.components.list.ListItem)

Example 2 with ListItem

use of main.swing.generic.components.list.ListItem in project Eidolons by IDemiurge.

the class ClassLine method init.

public void init() {
    int x = 0;
    int y = 0;
    // TODO empty items?
    for (String string : StringMaster.open(hero.getProperty(PROPS.CLASSES))) {
        string = VariableManager.removeVarPart(string);
        ObjType type = DataManager.getType(string, DC_TYPE.CLASSES);
        if (!StringMaster.isEmpty(hero.getProperty(PROPS.SECOND_CLASS))) {
            String property = (prime) ? hero.getProperty(PROPS.FIRST_CLASS) : hero.getProperty(PROPS.SECOND_CLASS);
            if (hero.getProperty(PROPS.FIRST_CLASS).contains(ClassView.MULTICLASS)) {
                boolean multi = hero.checkProperty(PROPS.MULTICLASSES, type.getName());
                if (prime) {
                    if (!multi) {
                        continue;
                    }
                } else if (multi) {
                    continue;
                }
            } else {
                String property2 = type.getProperty(G_PROPS.CLASS_GROUP);
                if (!StringMaster.compare(property, property2)) {
                    continue;
                }
            }
        }
        String pos = (vertical) ? "pos 0 " + (MAX_CLASSES - y - 1) * GuiManager.getSmallObjSize() : "pos " + x * GuiManager.getSmallObjSize() + " 0";
        final DC_FeatObj classObj = hero.getFeat(false, type);
        ListItem<ObjType> item = new ListItem<ObjType>(type, false, false, GuiManager.getSmallObjSize()) {

            public BORDER getSpecialBorder() {
                return classObj.getRankBorder();
            }
        };
        add(item, pos);
        if (vertical) {
            y++;
        } else {
            x++;
        }
    }
}
Also used : DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) ObjType(main.entity.type.ObjType) ListItem(main.swing.generic.components.list.ListItem)

Example 3 with ListItem

use of main.swing.generic.components.list.ListItem in project Eidolons by IDemiurge.

the class ListObjRenderer method getListCellRendererComponent.

@Override
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) {
    if (TYPE == null) {
        return getLabel(value, isSelected);
    }
    Entity type = null;
    if (value != null) {
        type = DataManager.getType(value.toString(), TYPE);
    }
    if (type == null) {
        return new JLabel(value.toString());
    }
    ListItem<Entity> item = new ListItem<>(type, isSelected, cellHasFocus, 0);
    // item.setIcon(ListRenderer.getCompIcon(type, isSelected));
    if (mods != null) {
        Component component = item;
        for (LC_MODS sub : mods) {
            switch(sub) {
                case TEXT_DISPLAYED:
                    component = SwingMaster.decorateWithText(type.getName(), Color.black, component, "pos 0 20");
                    break;
                default:
                    break;
            }
        }
        return component;
    }
    return item;
}
Also used : Entity(main.entity.Entity) LC_MODS(main.swing.generic.components.editors.lists.GenericListChooser.LC_MODS) ListItem(main.swing.generic.components.list.ListItem)

Aggregations

ListItem (main.swing.generic.components.list.ListItem)3 ObjType (main.entity.type.ObjType)2 DC_FeatObj (eidolons.entity.obj.attach.DC_FeatObj)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 Entity (main.entity.Entity)1 G_Panel (main.swing.generic.components.G_Panel)1 LC_MODS (main.swing.generic.components.editors.lists.GenericListChooser.LC_MODS)1