20 package net.sf.gridarta.gui.dialog.gameobjectattributes;
22 import java.awt.Component;
23 import javax.swing.text.Document;
24 import javax.swing.text.JTextComponent;
25 import javax.swing.text.Style;
32 import org.apache.log4j.Category;
33 import org.apache.log4j.Logger;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
53 private final JTextComponent
input;
80 final String archetypeAttributeName =
getRef().getArchetypeAttributeName();
81 String oldValue = archetype.getAttributeString(archetypeAttributeName);
82 if (oldValue.isEmpty()) {
86 if (!oldValue.equals(encodedValue)) {
87 return archetypeAttributeName +
" " + encodedValue;
94 public void appendSummary(@NotNull
final Document doc, @NotNull
final Style style) {
95 final String text = input.getText();
100 final String tmp = text.trim();
101 if (tmp.isEmpty() || tmp.startsWith(
"<")) {
105 addLine(doc, style,
"",
" = " + tmp);
131 if (bitmask != null) {
132 input.setText(bitmask.
getText(value));
134 LOG.warn(
"null bitmask");
144 assert bitmask != null;
DialogAttribute for types with bitmasks to choose from.
String getObjectText(@NotNull final G gameObject, @NotNull final Archetype< G, A, R > archetype, @NotNull final String[] newMsg, @NotNull final ArchetypeType archetypeType)
int getValue()
Get the active bitmask value.
void appendSummary(@NotNull final Document doc, @NotNull final Style style)
Contains the data of one Gridarta Object-Type.
T getRef()
Returns the attribute data.
void setEncodedValue(@NotNull final String encodedValue)
Set the active bitmask value in external file representation.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
String encodeValue(final int value)
Convert a value to external representation.
AttributeBitmask getBitmask()
GameObjects are the objects based on Archetypes found on maps.
This class manages bitmask values which appear in Gridarta archetype attributes.
final T ref
Reference to the attribute data.
int decodeValue(@NotNull final String encodedValue)
Convert a value from external representation.
void setBitmask(@Nullable final AttributeBitmask bitmask)
An ArchetypeAttribute for selecting bitmask values.
Component getInput()
Returns the input ui component for editing the value.
static final Category LOG
The Logger for printing log messages.
A single Attribute, combining an ArchetypeAttribute with its input component(s).
final JTextComponent input
The input ui component for editing the value.
DialogAttributeBitmask(@NotNull final ArchetypeAttributeBitmask ref, @NotNull final JTextComponent input)
Creates a new instance.
int value
Active bitmask value.
void addLine( @NotNull final Document doc, @NotNull final AttributeSet style, @NotNull final String prefix, @NotNull final String postfix)
Appends a line to a Document.
String getText(final int value)
Generate the text to be displayed for a given bitmask value.
void setValue(final int value)
Set the active bitmask value.
Defines types of GameObjects with corresponding attributes.
String getEncodedValue()
Get the active bitmask value in external file representation.
Interface for MapArchObjects.
AttributeBitmask bitmask
Reference to the bitmask data.