java.lang.Object
javax.swing.text.StyleConstants
- Direct Known Subclasses:
StyleConstants.CharacterConstants
,StyleConstants.ColorConstants
,StyleConstants.FontConstants
,StyleConstants.ParagraphConstants
public sealed class StyleConstants
extends Object
permits StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants, StyleConstants.ParagraphConstants
A collection of well known or common attribute keys and methods to apply to an AttributeSet or MutableAttributeSet to get/set the properties in a typesafe manner.
The paragraph attributes form the definition of a paragraph to be rendered. All sizes are specified in points (such as found in postscript), a device independent measure.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
This is a typesafe enumeration of the well-known attributes that contribute to a character style.static final class
This is a typesafe enumeration of the well-known attributes that contribute to a color.static final class
This is a typesafe enumeration of the well-known attributes that contribute to a font.static final class
This is a typesafe enumeration of the well-known attributes that contribute to a paragraph style. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
A possible value for paragraph alignment.static final int
A possible value for paragraph alignment.static final int
A possible value for paragraph alignment.static final int
A possible value for paragraph alignment.static final Object
Alignment for the paragraph.static final Object
Name of the background color attribute.static final Object
Bidirectional level of a character as assigned by the Unicode bidi algorithm.static final Object
Name of the bold attribute.static final Object
Name of the component attribute.static final String
Name of elements used to represent components.static final Object
Name of the input method composed text attribute.static final Object
Name of the font family.static final Object
The amount of space to indent the first line of the paragraph.static final Object
Name of the font family.static final Object
Name of the font size.static final Object
Name of the foreground color attribute.static final Object
Name of the icon attribute.static final String
Name of elements used to represent icons.static final Object
Name of the italic attribute.static final Object
The amount to indent the left side of the paragraph.static final Object
The amount of space between lines of the paragraph.static final Object
Attribute used to identify the model for embedded objects that have a model view separation.static final Object
Attribute name used to name the collection of attributes.static final Object
Orientation for a paragraph.static final Object
Attribute name used to identify the resolving parent set of attributes, if one is defined.static final Object
The amount to indent the right side of the paragraph.static final Object
Name of the font size.static final Object
The amount of space above the paragraph.static final Object
The amount of space below the paragraph.static final Object
Name of the Strikethrough attribute.static final Object
Name of the Subscript attribute.static final Object
Name of the Superscript attribute.static final Object
TabSet for the paragraph, type is a TabSet containing TabStops.static final Object
Name of the underline attribute. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Gets the alignment setting.static Color
Gets the background color setting from the attribute list.static int
Gets the BidiLevel setting.static Component
Gets the component setting from the attribute list.static float
Gets the first line indent setting.static String
Gets the font family setting from the attribute list.static int
Gets the font size setting from the attribute list.static Color
Gets the foreground color setting from the attribute list.static Icon
Gets the icon setting from the attribute list.static float
Gets the left indent setting.static float
Gets the line spacing setting.static float
Gets the right indent setting.static float
Gets the space above setting.static float
Gets the space below setting.static TabSet
Gets the TabSet.static boolean
Checks whether the bold attribute is set.static boolean
Checks whether the italic attribute is set.static boolean
Checks whether the strikethrough attribute is set.static boolean
Checks whether the subscript attribute is set.static boolean
Checks whether the superscript attribute is set.static boolean
Checks whether the underline attribute is set.static void
setAlignment
(MutableAttributeSet a, int align) Sets alignment.static void
Sets the background color.static void
setBidiLevel
(MutableAttributeSet a, int o) Sets the BidiLevel.static void
setBold
(MutableAttributeSet a, boolean b) Sets the bold attribute.static void
Sets the component attribute.static void
setFirstLineIndent
(MutableAttributeSet a, float i) Sets the first line indent.static void
setFontFamily
(MutableAttributeSet a, String fam) Sets the font attribute.static void
setFontSize
(MutableAttributeSet a, int s) Sets the font size attribute.static void
Sets the foreground color.static void
setIcon
(MutableAttributeSet a, Icon c) Sets the icon attribute.static void
setItalic
(MutableAttributeSet a, boolean b) Sets the italic attribute.static void
setLeftIndent
(MutableAttributeSet a, float i) Sets left indent.static void
setLineSpacing
(MutableAttributeSet a, float i) Sets line spacing.static void
setRightIndent
(MutableAttributeSet a, float i) Sets right indent.static void
setSpaceAbove
(MutableAttributeSet a, float i) Sets space above.static void
setSpaceBelow
(MutableAttributeSet a, float i) Sets space below.static void
setStrikeThrough
(MutableAttributeSet a, boolean b) Sets the strikethrough attribute.static void
setSubscript
(MutableAttributeSet a, boolean b) Sets the subscript attribute.static void
setSuperscript
(MutableAttributeSet a, boolean b) Sets the superscript attribute.static void
setTabSet
(MutableAttributeSet a, TabSet tabs) Sets the TabSet.static void
setUnderline
(MutableAttributeSet a, boolean b) Sets the underline attribute.toString()
Returns the string representation.
-
Field Details
-
ComponentElementName
Name of elements used to represent components.- See Also:
-
IconElementName
Name of elements used to represent icons.- See Also:
-
NameAttribute
Attribute name used to name the collection of attributes. -
ResolveAttribute
Attribute name used to identify the resolving parent set of attributes, if one is defined. -
ModelAttribute
Attribute used to identify the model for embedded objects that have a model view separation. -
BidiLevel
Bidirectional level of a character as assigned by the Unicode bidi algorithm. -
FontFamily
Name of the font family. -
Family
Name of the font family.- Since:
- 1.5
-
FontSize
Name of the font size. -
Size
Name of the font size.- Since:
- 1.5
-
Bold
Name of the bold attribute. -
Italic
Name of the italic attribute. -
Underline
Name of the underline attribute. -
StrikeThrough
Name of the Strikethrough attribute. -
Superscript
Name of the Superscript attribute. -
Subscript
Name of the Subscript attribute. -
Foreground
Name of the foreground color attribute. -
Background
Name of the background color attribute. -
ComponentAttribute
Name of the component attribute. -
IconAttribute
Name of the icon attribute. -
ComposedTextAttribute
Name of the input method composed text attribute. The value of this attribute is an instance of AttributedString which represents the composed text. -
FirstLineIndent
The amount of space to indent the first line of the paragraph. This value may be negative to offset in the reverse direction. The type is Float and specifies the size of the space in points. -
LeftIndent
The amount to indent the left side of the paragraph. Type is float and specifies the size in points. -
RightIndent
The amount to indent the right side of the paragraph. Type is float and specifies the size in points. -
LineSpacing
The amount of space between lines of the paragraph. Type is float and specifies the size as a factor of the line height -
SpaceAbove
The amount of space above the paragraph. Type is float and specifies the size in points. -
SpaceBelow
The amount of space below the paragraph. Type is float and specifies the size in points. -
Alignment
Alignment for the paragraph. The type is Integer. Valid values are:- ALIGN_LEFT
- ALIGN_RIGHT
- ALIGN_CENTER
- ALIGN_JUSTIFED
-
TabSet
TabSet for the paragraph, type is a TabSet containing TabStops. -
Orientation
Orientation for a paragraph. -
ALIGN_LEFT
public static final int ALIGN_LEFTA possible value for paragraph alignment. This specifies that the text is aligned to the left indent and extra whitespace should be placed on the right.- See Also:
-
ALIGN_CENTER
public static final int ALIGN_CENTERA possible value for paragraph alignment. This specifies that the text is aligned to the center and extra whitespace should be placed equally on the left and right.- See Also:
-
ALIGN_RIGHT
public static final int ALIGN_RIGHTA possible value for paragraph alignment. This specifies that the text is aligned to the right indent and extra whitespace should be placed on the left.- See Also:
-
ALIGN_JUSTIFIED
public static final int ALIGN_JUSTIFIEDA possible value for paragraph alignment. This specifies that extra whitespace should be spread out through the rows of the paragraph with the text lined up with the left and right indent except on the last line which should be aligned to the left.- See Also:
-
-
Method Details
-
toString
Returns the string representation. -
getBidiLevel
Gets the BidiLevel setting.- Parameters:
a
- the attribute set- Returns:
- the value
-
setBidiLevel
Sets the BidiLevel.- Parameters:
a
- the attribute seto
- the bidi level value
-
getComponent
Gets the component setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the component, null if none
-
setComponent
Sets the component attribute.- Parameters:
a
- the attribute setc
- the component
-
getIcon
Gets the icon setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the icon, null if none
-
setIcon
Sets the icon attribute.- Parameters:
a
- the attribute setc
- the icon
-
getFontFamily
Gets the font family setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the font family, "Monospaced" as the default
-
setFontFamily
Sets the font attribute.- Parameters:
a
- the attribute setfam
- the font
-
getFontSize
Gets the font size setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the font size, 12 as the default
-
setFontSize
Sets the font size attribute.- Parameters:
a
- the attribute sets
- the font size
-
isBold
Checks whether the bold attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
setBold
Sets the bold attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
isItalic
Checks whether the italic attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
setItalic
Sets the italic attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
isUnderline
Checks whether the underline attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
isStrikeThrough
Checks whether the strikethrough attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
isSuperscript
Checks whether the superscript attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
isSubscript
Checks whether the subscript attribute is set.- Parameters:
a
- the attribute set- Returns:
- true if set else false
-
setUnderline
Sets the underline attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
setStrikeThrough
Sets the strikethrough attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
setSuperscript
Sets the superscript attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
setSubscript
Sets the subscript attribute.- Parameters:
a
- the attribute setb
- specifies true/false for setting the attribute
-
getForeground
Gets the foreground color setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the color, Color.black as the default
-
setForeground
Sets the foreground color.- Parameters:
a
- the attribute setfg
- the color
-
getBackground
Gets the background color setting from the attribute list.- Parameters:
a
- the attribute set- Returns:
- the color, Color.black as the default
-
setBackground
Sets the background color.- Parameters:
a
- the attribute setfg
- the color
-
getFirstLineIndent
Gets the first line indent setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setFirstLineIndent
Sets the first line indent.- Parameters:
a
- the attribute seti
- the value
-
getRightIndent
Gets the right indent setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setRightIndent
Sets right indent.- Parameters:
a
- the attribute seti
- the value
-
getLeftIndent
Gets the left indent setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setLeftIndent
Sets left indent.- Parameters:
a
- the attribute seti
- the value
-
getLineSpacing
Gets the line spacing setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setLineSpacing
Sets line spacing.- Parameters:
a
- the attribute seti
- the value
-
getSpaceAbove
Gets the space above setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setSpaceAbove
Sets space above.- Parameters:
a
- the attribute seti
- the value
-
getSpaceBelow
Gets the space below setting.- Parameters:
a
- the attribute set- Returns:
- the value, 0 if not set
-
setSpaceBelow
Sets space below.- Parameters:
a
- the attribute seti
- the value
-
getAlignment
Gets the alignment setting.- Parameters:
a
- the attribute set- Returns:
- the value
StyleConstants.ALIGN_LEFT
if not set
-
setAlignment
Sets alignment.- Parameters:
a
- the attribute setalign
- the alignment value
-
getTabSet
Gets the TabSet.- Parameters:
a
- the attribute set- Returns:
- the
TabSet
-
setTabSet
Sets the TabSet.- Parameters:
a
- the attribute set.tabs
- the TabSet
-