20 package net.sf.gridarta.gui.treasurelist;
22 import java.awt.Color;
23 import java.awt.Component;
25 import javax.swing.BorderFactory;
26 import javax.swing.JTree;
27 import javax.swing.tree.DefaultMutableTreeNode;
28 import javax.swing.tree.DefaultTreeCellRenderer;
42 import org.jetbrains.annotations.NotNull;
79 private final DefaultMutableTreeNode
root;
89 setIcon(faceObjectProviders.getFace(archetypeSet.
getArchetype(treasureObj.getName())));
93 setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
101 public void visit(@NotNull
final NoTreasureObj treasureObj) {
102 setForeground(Color.gray);
109 if (treasureObj.getName().equalsIgnoreCase(
"none")) {
111 setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
113 setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
117 if (treasureObj.getName().equalsIgnoreCase(
"none")) {
119 setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
121 setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
129 setForeground(Color.gray);
151 public Component
getTreeCellRendererComponent(
final JTree tree,
final Object value,
final boolean sel,
final boolean expanded,
final boolean leaf,
final int row,
final boolean hasFocus) {
152 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
154 final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
156 setFont(getFont().deriveFont(Font.PLAIN));
158 setForeground(Color.gray);
162 content.
visit(treasureObjVisitor);
164 if (node.getParent() ==
root) {
166 setFont(getFont().deriveFont(Font.BOLD));
171 setFont(getFont().deriveFont(Font.BOLD));
A TreasureObj representing a "no" entry.
Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus)
static final String TREASURE_LIST
TreasureObj getTreasureObj()
static final String TREASURE_YES
TreasureCellRenderer(@NotNull final ArchetypeSet<?, ?, ?> archetypeSet, @NotNull final DefaultMutableTreeNode root, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ResourceIcons resourceIcons)
Create a TreasureCellRenderer: load icons and initialize fonts.
static final String SQUARE_NO_ARCH
Base package of all Gridarta classes.
final TreasureObjVisitor treasureObjVisitor
The TreasureObjVisitor for setting rendering parameters.
final ResourceIcons resourceIcons
The ResourceIcons for creating icons.
R getArchetype(@NotNull String archetypeName)
Returns an Archetype by its name.
final ArchetypeSet<?, ?, ?> archetypeSet
The ArchetypeSet.
abstract void visit(@NotNull TreasureObjVisitor visitor)
Calls the TreasureObjVisitor callback function appropriate for this instance.
static final String TREASUREONE_LIST
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
A TreasureObj representing a folder.
Type of TreasureListTreasureObj instances.
Exception thrown if an Archetype does not exist.
A TreasureObj representing an "arch" entry.
A TreasureObj representing a "treasure" entry.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
Creates ImageIcon instances from resources.
This cell renderer is responsible for drawing the treasure-object cells in the JTree.
A TreasureObj representing a "yes" entry.
Subclass: Nodes in the CFTreasureListTree.
final DefaultMutableTreeNode root
The root node.
Interface that captures similarities between different ArchetypeSet implementations.
Subclass: UserObject (= content object) for nodes in the CFTreasureListTree These can be either treas...
ImageIcon getResourceIcon(@NotNull final String iconName)
Returns the image icon for the given icon name.
Interface for visitors of TreasureObj instances.
static final String TREASURE_NO
static final long serialVersionUID
Serial Version UID.