public class Chr
extends Object
Chr
class encapsulates a single character (intended for
display within a TextRegion) and all its attributes (the on-screen position
is not included because it is managed independently by the TextRegion class).
The usual event listeners can also be tracked on a per-character basis with this class, and will gracefully disappear once removed from the TextRegion (and there is an event that can be listened to for that as well).
The name "Chr" was chosen to prevent confusion with Java's "char" primitive and the "java.lang.Character" class, and also embraces the obvious nature of this class by duplicating the functionally similar "Chr" keyword used in some well-known software technologies (e.g., Perl, BASIC, PostgreSQL, etc.) that first became popular in the pre-GUI computing era.
Modifier and Type | Class and Description |
---|---|
static class |
Chr.Cmd
The Chr.Cmd class provides a subset of the TextRegion.Cmd class's static
constants that are supported by the "randolf.fx.textmode.Chr" class.
While the constants hold the same values as those by the same names in the
TextRegion.Cmd class, it's important to note that the Chr class is specific
in its scope that focuses only on static attributes such as the foreground
and background colours, effects (e.g., underline, bold, etc.), and so on.
|
Constructor and Description |
---|
Chr(byte chr,
int... cmds)
Basic "Chr" constructor, starting with the character only. Attributes
are optional, but if defined will override TextRegion defaults.
|
Chr(char chr,
int... cmds)
Basic "Chr" constructor, starting with the character only. Attributes
are optional, but if defined will override TextRegion defaults.
|
Chr(int chr,
int... cmds)
Basic "Chr" constructor, starting with the character only. Attributes
are optional, but if defined will override TextRegion defaults.
|
Chr(int chr,
int bg_argb_int,
int fg_argb_int,
boolean underline,
boolean strike,
boolean blink,
boolean transparent,
boolean reverse,
boolean hidden,
int... cmds)
Advanced "Chr" constructor, starting with the character, its colours, and
all attributes, which will override TextRegion defaults. Additional
attributes are optional.
|
Chr(int chr,
TextRegion tr,
int... cmds)
Autonomic "Chr" constructor, starting with the character, and a TextRegion
object upon which to base its attribute defaults. Additional
attributes are optional.
|
Chr(String chr,
int... cmds)
Basic "Chr" constructor, starting with the character only. Attributes
are optional, but if defined will override TextRegion defaults.
|
Modifier and Type | Method and Description |
---|---|
Chr |
clone()
Instantiate a new Chr object that is a duplicate of this one.
|
int |
getBackground()
Returns the current BACKGROUND colour attribute. If the attribute was
not set, then the default of BLACK will be returned.
|
int |
getForeground()
Returns the current FOREGROUND colour attribute. If the attribute was
not set, then the default of WHITE will be returned.
|
boolean |
isBackgroundDefined()
Indicates whether the BACKGROUND colour attribute is set.
|
boolean |
isBlink()
Indicates the current status of the BLINK attribute. If the BLINK
attribute was not set, then FALSE will be returned.
|
boolean |
isBlinkDefined()
Indicates whether the BLINK attribute was set.
|
boolean |
isChanged()
Indicates whether this character needs to be re-drawn (this setting is
normally only managed by the owning TextRegion object).
|
boolean |
isForegroundDefined()
Indicates whether the FOREGROUND colour attribute is set.
|
boolean |
isHidden()
Indicates the current status of the HIDDEN attribute. If the
attribute was not set, then FALSE will be returned.
|
boolean |
isHiddenDefined()
Indicates whether the HIDDEN attribute was set.
|
boolean |
isReverse()
Indicates the current status of the REVERSE attribute. If the
attribute was not set, then FALSE will be returned.
|
boolean |
isReverseDefined()
Indicates whether the REVERSE attribute was set.
|
boolean |
isStrike()
Indicates the current status of the STRIKE attribute. If the
attribute was not set, then FALSE will be returned.
|
boolean |
isStrikeDefined()
Indicates whether the STRIKE attribute was set.
|
boolean |
isTransparent()
Indicates the current status of the TRANSPARENT attribute. If the
attribute was not set, then FALSE will be returned.
|
boolean |
isTransparentDefined()
Indicates whether the TRANSPARENT attribute was set.
|
boolean |
isUnderline()
Indicates the current status of the UNDERLINE attribute. If the
attribute was not set, then FALSE will be returned.
|
boolean |
isUnderlineDefined()
Indicates whether the UNDERLINE attribute was set.
|
Chr |
set(int... cmds)
Alters the value of any number of parameters (in any order).
|
Chr |
setChanged(boolean changed)
Sets the internal "changed" flag (this setting is normally only managed by
the owning TextRegion object).
|
Chr |
setColours(int bg_argb_int,
int fg_argb_int)
Specify both the background and foreground colours (formatted as ARGB
integers).
|
char |
toChar()
Returns the current character as a native "char" type.
|
int |
toInteger()
Returns the current character's ASCII (or other) value as an integer.
|
static Chr |
zero(int bg_argb_int,
int fg_argb_int)
Instantiate a new Chr object that is character 0 using the specified
background and foreground colours (formatted as ARGB integers).
|
static Chr |
zero(int bg_argb_int,
int fg_argb_int,
boolean underline,
boolean strike,
boolean blink,
boolean transparent,
boolean reverse,
boolean hidden)
Instantiate a new Chr object that is character 0 using the specified
background and foreground colours (formatted as ARGB integers), and various
other attributes (which should normally all be "FALSE" by default).
|
static Chr |
zero(TextRegion tr)
Instantiate a new Chr object that is character 0 using the specified
background and foreground colours (formatted as ARGB integers).
|
public Chr(byte chr, int... cmds)
chr
- Character code to use (e.g., by its ASCII value), as a byte (which
will be interpreted as an unsigned byte)cmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr(char chr, int... cmds)
chr
- The native "char" to usecmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr(int chr, int... cmds)
chr
- Character code to use (e.g., by its ASCII value)cmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr(int chr, int bg_argb_int, int fg_argb_int, boolean underline, boolean strike, boolean blink, boolean transparent, boolean reverse, boolean hidden, int... cmds)
chr
- Character code to use (e.g., by its ASCII value)bg_argb_int
- Background colourfg_argb_int
- Foreground colourunderline
- underline attributestrike
- strike-through attributeblink
- blink attributetransparent
- transparency attributereverse
- reverse attributehidden
- hidden attributecmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr(int chr, TextRegion tr, int... cmds)
chr
- Character code to use (e.g., by its ASCII value)tr
- TextRegion object to obtain colour and other attributes fromcmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr(String chr, int... cmds)
chr
- The String to obtain the first native "char" from (NULL or empty
String will be interpreted as character 0)cmds
- Attribute commands (and their required parameters)set(int...)
,
TextRegion.Cmd
public Chr clone()
clone
in class Object
public int getBackground()
isBackgroundDefined()
,
Chr.Cmd.BLACK
public int getForeground()
isForegroundDefined()
,
Chr.Cmd.WHITE
public boolean isBackgroundDefined()
getBackground()
public boolean isBlink()
isBlinkDefined()
public boolean isBlinkDefined()
isBlink()
public boolean isChanged()
setChanged(boolean)
public boolean isForegroundDefined()
getForeground()
public boolean isHidden()
isHiddenDefined()
public boolean isHiddenDefined()
isHidden()
public boolean isReverse()
isReverseDefined()
public boolean isReverseDefined()
isReverse()
public boolean isStrike()
isStrikeDefined()
public boolean isStrikeDefined()
isStrike()
public boolean isTransparent()
isTransparentDefined()
public boolean isTransparentDefined()
isTransparent()
public boolean isUnderline()
isUnderlineDefined()
public boolean isUnderlineDefined()
isUnderline()
public Chr set(int... cmds)
The following Attribute Commands, which are defined in the TextRegion.Cmd class, may be used (all others will be ignored):
cmds
- Attribute commands (and their required parameters)Chr.Cmd
public Chr setChanged(boolean changed)
setChanged(boolean)
public Chr setColours(int bg_argb_int, int fg_argb_int)
bg_argb_int
- Background colourfg_argb_int
- Foreground colourpublic char toChar()
public int toInteger()
public static Chr zero(int bg_argb_int, int fg_argb_int)
bg_argb_int
- Background colourfg_argb_int
- Foreground colourpublic static Chr zero(int bg_argb_int, int fg_argb_int, boolean underline, boolean strike, boolean blink, boolean transparent, boolean reverse, boolean hidden)
bg_argb_int
- Background colourfg_argb_int
- Foreground colourunderline
- underline attributestrike
- strike-through attributeblink
- blink attributetransparent
- transparency attributereverse
- reverse attributehidden
- hidden attributepublic static Chr zero(TextRegion tr)
tr
- TextRegion object to obtain colour and other attributes from