javalib.worldimages
Enum TextStyle
java.lang.Object
java.lang.Enum<TextStyle>
javalib.worldimages.TextStyle
- All Implemented Interfaces:
- Serializable, Comparable<TextStyle>
public enum TextStyle
- extends Enum<TextStyle>
The available TextStyles are NORMAL (aka REGULAR), ITALIC, BOLD, and BOLD_ITALIC (aka ITALIC_BOLD).
I really didn't like the idea of users passing in the numbers 0, 1, 2, or 3
to specify text styles, even if that's the way Graphics2D.drawText wants them.
And the ints actually bit me: since both the text style and the font size are
optional, and they're right next to one another in the constructor parameter list,
I created some text that I thought was NORMAL and was instead font-size 0, or
what I thought was ITALIC and was instead font-size 1. This version is safer
against that kind of mistake.
- Version:
- Dec. 5, 2012
- Author:
- Stephen Bloch
Method Summary |
int |
toInt()
|
static TextStyle |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static TextStyle[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared. |
BOLD
public static final TextStyle BOLD
BOLD_ITALIC
public static final TextStyle BOLD_ITALIC
ITALIC
public static final TextStyle ITALIC
NORMAL
public static final TextStyle NORMAL
ITALIC_BOLD
public static final TextStyle ITALIC_BOLD
- A synonym for BOLD_ITALIC.
REGULAR
public static final TextStyle REGULAR
- A synonym for NORMAL.
toInt
public int toInt()
valueOf
public static TextStyle valueOf(String name)
- Returns the enum constant of this type with the specified name.
The string must match exactly an identifier used to declare an
enum constant in this type. (Extraneous whitespace characters are
not permitted.)
- Parameters:
name
- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is null
values
public static TextStyle[] values()
- Returns an array containing the constants of this enum type, in
the order they are declared. This method may be used to iterate
over the constants as follows:
for (TextStyle c : TextStyle.values())
System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in
the order they are declared