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);
}
}
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++;
}
}
}
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;
}
Aggregations