javax.swing.text

Class StyleConstants

Known Direct Subclasses:
StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants, StyleConstants.ParagraphConstants

public class StyleConstants
extends Object

Represents standard attribute keys. This class also contains a set of useful static utility methods for querying and populating an AttributeSet.
Since:
1.2

Nested Class Summary

static class
StyleConstants.CharacterConstants
A set of keys for attributes that apply to characters.
static class
StyleConstants.ColorConstants
A set of keys for attributes that relate to colors.
static class
StyleConstants.FontConstants
A set of keys for attributes that apply to fonts.
static class
StyleConstants.ParagraphConstants
A set of keys for attributes that apply to paragraphs.

Field Summary

static int
ALIGN_CENTER
A value representing center alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
static int
ALIGN_JUSTIFIED
A value representing ful justification for the StyleConstants.ParagraphConstants.Alignment attribute.
static int
ALIGN_LEFT
A value representing left alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
static int
ALIGN_RIGHT
A value representing right alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
static Object
Alignment
An alias for StyleConstants.ParagraphConstants.Alignment.
static Object
Background
An alias for StyleConstants.CharacterConstants.Background.
static Object
BidiLevel
An alias for StyleConstants.CharacterConstants.BidiLevel.
static Object
Bold
An alias for StyleConstants.CharacterConstants.Bold.
static Object
ComponentAttribute
An alias for StyleConstants.CharacterConstants.ComponentAttribute.
static String
ComponentElementName
static Object
ComposedTextAttribute
static Object
Family
An alias for StyleConstants.CharacterConstants.Family.
static Object
FirstLineIndent
An alias for StyleConstants.ParagraphConstants.FirstLineIndent.
static Object
FontFamily
An alias for StyleConstants.CharacterConstants.Family.
static Object
FontSize
An alias for StyleConstants.CharacterConstants.Size.
static Object
Foreground
An alias for StyleConstants.CharacterConstants.Foreground.
static Object
IconAttribute
An alias for StyleConstants.CharacterConstants.IconAttribute.
static String
IconElementName
static Object
Italic
An alias for StyleConstants.CharacterConstants.Italic.
static Object
LeftIndent
An alias for StyleConstants.ParagraphConstants.LeftIndent.
static Object
LineSpacing
An alias for StyleConstants.ParagraphConstants.LineSpacing.
static Object
ModelAttribute
static Object
NameAttribute
static Object
Orientation
An alias for StyleConstants.ParagraphConstants.Orientation.
static Object
ResolveAttribute
static Object
RightIndent
An alias for StyleConstants.ParagraphConstants.RightIndent.
static Object
Size
An alias for StyleConstants.CharacterConstants.Size.
static Object
SpaceAbove
An alias for StyleConstants.ParagraphConstants.SpaceAbove.
static Object
SpaceBelow
An alias for StyleConstants.ParagraphConstants.SpaceBelow.
static Object
StrikeThrough
An alias for StyleConstants.CharacterConstants.StrikeThrough.
static Object
Subscript
An alias for StyleConstants.CharacterConstants.Subscript.
static Object
Superscript
An alias for StyleConstants.CharacterConstants.Superscript.
static Object
TabSet
An alias for StyleConstants.ParagraphConstants.TabSet.
static Object
Underline
An alias for StyleConstants.CharacterConstants.Underline.

Method Summary

static int
getAlignment(AttributeSet a)
Returns the alignment specified in the given attributes, or ALIGN_LEFT if no alignment is specified.
static Color
getBackground(AttributeSet a)
Returns the background color specified in the given attributes, or Color.BLACK if no background color is specified.
static int
getBidiLevel(AttributeSet a)
Returns the bidi level specified in the given attributes, or 0 if no bidi level is specified.
static Component
getComponent(AttributeSet a)
Returns the component specified in the given attributes, or null if no component is specified.
static float
getFirstLineIndent(AttributeSet a)
Returns the indentation specified in the given attributes, or 0.0f if no indentation is specified.
static String
getFontFamily(AttributeSet a)
Returns the font family specified in the given attributes, or Monospaced if no font family is specified.
static int
getFontSize(AttributeSet a)
Returns the font size specified in the given attributes, or 12 if no font size is specified.
static Color
getForeground(AttributeSet a)
Returns the foreground color specified in the given attributes, or Color.BLACK if no foreground color is specified.
static Icon
getIcon(AttributeSet a)
Returns the icon specified in the given attributes, or null if no icon is specified.
static float
getLeftIndent(AttributeSet a)
Returns the left indentation specified in the given attributes, or 0.0f if no left indentation is specified.
static float
getLineSpacing(AttributeSet a)
Returns the line spacing specified in the given attributes, or 0.0f if no line spacing is specified.
static float
getRightIndent(AttributeSet a)
Returns the right indentation specified in the given attributes, or 0.0f if no right indentation is specified.
static float
getSpaceAbove(AttributeSet a)
Returns the 'space above' specified in the given attributes, or 0.0f if no 'space above' is specified.
static float
getSpaceBelow(AttributeSet a)
Returns the 'space below' specified in the given attributes, or 0.0f if no 'space below' is specified.
static TabSet
getTabSet(AttributeSet a)
Returns the tab set specified in the given attributes, or null if no tab set is specified.
static boolean
isBold(AttributeSet a)
Returns the value of the bold flag in the given attributes, or false if no bold flag is specified.
static boolean
isItalic(AttributeSet a)
Returns the value of the italic flag in the given attributes, or false if no italic flag is specified.
static boolean
isStrikeThrough(AttributeSet a)
Returns the value of the strike-through flag in the given attributes, or false if no strike-through flag is specified.
static boolean
isSubscript(AttributeSet a)
Returns the value of the subscript flag in the given attributes, or false if no subscript flag is specified.
static boolean
isSuperscript(AttributeSet a)
Returns the value of the superscript flag in the given attributes, or false if no superscript flag is specified.
static boolean
isUnderline(AttributeSet a)
Returns the value of the underline flag in the given attributes, or false if no underline flag is specified.
static void
setAlignment(MutableAttributeSet a, int align)
Adds an alignment attribute to the specified set.
static void
setBackground(MutableAttributeSet a, Color bg)
Adds a background attribute to the specified set.
static void
setBidiLevel(MutableAttributeSet a, int lev)
Adds a bidi-level attribute to the specified set.
static void
setBold(MutableAttributeSet a, boolean b)
Adds a bold attribute to the specified set.
static void
setComponent(MutableAttributeSet a, Component c)
Adds a component attribute to the specified set.
static void
setFirstLineIndent(MutableAttributeSet a, float i)
Adds a first line indentation attribute to the specified set.
static void
setFontFamily(MutableAttributeSet a, String fam)
Adds a font family attribute to the specified set.
static void
setFontSize(MutableAttributeSet a, int s)
Adds a font size attribute to the specified set.
static void
setForeground(MutableAttributeSet a, Color fg)
Adds a foreground color attribute to the specified set.
static void
setIcon(MutableAttributeSet a, Icon c)
Adds an icon attribute to the specified set.
static void
setItalic(MutableAttributeSet a, boolean b)
Adds an italic attribute to the specified set.
static void
setLeftIndent(MutableAttributeSet a, float i)
Adds a left indentation attribute to the specified set.
static void
setLineSpacing(MutableAttributeSet a, float i)
Adds a line spacing attribute to the specified set.
static void
setRightIndent(MutableAttributeSet a, float i)
Adds a right indentation attribute to the specified set.
static void
setSpaceAbove(MutableAttributeSet a, float i)
Adds a 'space above' attribute to the specified set.
static void
setSpaceBelow(MutableAttributeSet a, float i)
Adds a 'space below' attribute to the specified set.
static void
setStrikeThrough(MutableAttributeSet a, boolean b)
Adds a strike-through attribue to the specified set.
static void
setSubscript(MutableAttributeSet a, boolean b)
Adds a subscript attribute to the specified set.
static void
setSuperscript(MutableAttributeSet a, boolean b)
Adds a superscript attribute to the specified set.
static void
setTabSet(MutableAttributeSet a, TabSet tabs)
Adds a TabSet attribute to the specified set.
static void
setUnderline(MutableAttributeSet a, boolean b)
Adds an underline attribute to the specified set.
String
toString()
Returns a string representation of the attribute key.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

ALIGN_CENTER

public static final int ALIGN_CENTER
A value representing center alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
Field Value:
1

ALIGN_JUSTIFIED

public static final int ALIGN_JUSTIFIED
A value representing ful justification for the StyleConstants.ParagraphConstants.Alignment attribute.
Field Value:
3

ALIGN_LEFT

public static final int ALIGN_LEFT
A value representing left alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
Field Value:
0

ALIGN_RIGHT

public static final int ALIGN_RIGHT
A value representing right alignment for the StyleConstants.ParagraphConstants.Alignment attribute.
Field Value:
2

Alignment

public static final Object Alignment

Background

public static final Object Background

BidiLevel

public static final Object BidiLevel

Bold

public static final Object Bold

ComponentAttribute

public static final Object ComponentAttribute

ComponentElementName

public static final String ComponentElementName
Field Value:
"component"

ComposedTextAttribute

public static final Object ComposedTextAttribute

Family

public static final Object Family

FirstLineIndent

public static final Object FirstLineIndent

FontFamily

public static final Object FontFamily

FontSize

public static final Object FontSize

Foreground

public static final Object Foreground

IconAttribute

public static final Object IconAttribute

IconElementName

public static final String IconElementName
Field Value:
"icon"

Italic

public static final Object Italic

LeftIndent

public static final Object LeftIndent

LineSpacing

public static final Object LineSpacing

ModelAttribute

public static final Object ModelAttribute

NameAttribute

public static final Object NameAttribute

Orientation

public static final Object Orientation

ResolveAttribute

public static final Object ResolveAttribute

RightIndent

public static final Object RightIndent

Size

public static final Object Size

SpaceAbove

public static final Object SpaceAbove

SpaceBelow

public static final Object SpaceBelow

StrikeThrough

public static final Object StrikeThrough

Subscript

public static final Object Subscript

Superscript

public static final Object Superscript

TabSet

public static final Object TabSet

Underline

public static final Object Underline

Method Details

getAlignment

public static int getAlignment(AttributeSet a)
Returns the alignment specified in the given attributes, or ALIGN_LEFT if no alignment is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The alignment (typically one of ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER or ALIGN_JUSTIFIED).

getBackground

public static Color getBackground(AttributeSet a)
Returns the background color specified in the given attributes, or Color.BLACK if no background color is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The background color.

getBidiLevel

public static int getBidiLevel(AttributeSet a)
Returns the bidi level specified in the given attributes, or 0 if no bidi level is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The bidi level.

getComponent

public static Component getComponent(AttributeSet a)
Returns the component specified in the given attributes, or null if no component is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The component (possibly null).

getFirstLineIndent

public static float getFirstLineIndent(AttributeSet a)
Returns the indentation specified in the given attributes, or 0.0f if no indentation is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The indentation.

getFontFamily

public static String getFontFamily(AttributeSet a)
Returns the font family specified in the given attributes, or Monospaced if no font family is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The font family.

getFontSize

public static int getFontSize(AttributeSet a)
Returns the font size specified in the given attributes, or 12 if no font size is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The font size.

getForeground

public static Color getForeground(AttributeSet a)
Returns the foreground color specified in the given attributes, or Color.BLACK if no foreground color is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The foreground color.

getIcon

public static Icon getIcon(AttributeSet a)
Returns the icon specified in the given attributes, or null if no icon is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The icon (possibly null).

getLeftIndent

public static float getLeftIndent(AttributeSet a)
Returns the left indentation specified in the given attributes, or 0.0f if no left indentation is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The left indentation.

getLineSpacing

public static float getLineSpacing(AttributeSet a)
Returns the line spacing specified in the given attributes, or 0.0f if no line spacing is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The line spacing.

getRightIndent

public static float getRightIndent(AttributeSet a)
Returns the right indentation specified in the given attributes, or 0.0f if no right indentation is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The right indentation.

getSpaceAbove

public static float getSpaceAbove(AttributeSet a)
Returns the 'space above' specified in the given attributes, or 0.0f if no 'space above' is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The 'space above'.

getSpaceBelow

public static float getSpaceBelow(AttributeSet a)
Returns the 'space below' specified in the given attributes, or 0.0f if no 'space below' is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The 'space below'.

getTabSet

public static TabSet getTabSet(AttributeSet a)
Returns the tab set specified in the given attributes, or null if no tab set is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The tab set.

isBold

public static boolean isBold(AttributeSet a)
Returns the value of the bold flag in the given attributes, or false if no bold flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The bold flag.

isItalic

public static boolean isItalic(AttributeSet a)
Returns the value of the italic flag in the given attributes, or false if no italic flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The italic flag.

isStrikeThrough

public static boolean isStrikeThrough(AttributeSet a)
Returns the value of the strike-through flag in the given attributes, or false if no strike-through flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The strike-through flag.

isSubscript

public static boolean isSubscript(AttributeSet a)
Returns the value of the subscript flag in the given attributes, or false if no subscript flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The subscript flag.

isSuperscript

public static boolean isSuperscript(AttributeSet a)
Returns the value of the superscript flag in the given attributes, or false if no superscript flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The superscript flag.

isUnderline

public static boolean isUnderline(AttributeSet a)
Returns the value of the underline flag in the given attributes, or false if no underline flag is specified.
Parameters:
a - the attribute set (null not permitted).
Returns:
The underline flag.

setAlignment

public static void setAlignment(MutableAttributeSet a,
                                int align)
Adds an alignment attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
align - the alignment (typically one of ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER or ALIGN_JUSTIFIED).
Throws:
NullPointerException - if a is null.

setBackground

public static void setBackground(MutableAttributeSet a,
                                 Color bg)
Adds a background attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
bg - the background (null not permitted).
Throws:
NullPointerException - if either argument is null.

setBidiLevel

public static void setBidiLevel(MutableAttributeSet a,
                                int lev)
Adds a bidi-level attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
lev - the level.
Throws:
NullPointerException - if a is null.

setBold

public static void setBold(MutableAttributeSet a,
                           boolean b)
Adds a bold attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the new value of the bold attribute.
Throws:
NullPointerException - if a is null.

setComponent

public static void setComponent(MutableAttributeSet a,
                                Component c)
Adds a component attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
c - the component (null not permitted).
Throws:
NullPointerException - if either argument is null.

setFirstLineIndent

public static void setFirstLineIndent(MutableAttributeSet a,
                                      float i)
Adds a first line indentation attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the indentation.
Throws:
NullPointerException - if a is null.

setFontFamily

public static void setFontFamily(MutableAttributeSet a,
                                 String fam)
Adds a font family attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
fam - the font family name (null not permitted).
Throws:
NullPointerException - if either argument is null.

setFontSize

public static void setFontSize(MutableAttributeSet a,
                               int s)
Adds a font size attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
s - the font size (in points).
Throws:
NullPointerException - if a is null.

setForeground

public static void setForeground(MutableAttributeSet a,
                                 Color fg)
Adds a foreground color attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
fg - the foreground color (null not permitted).
Throws:
NullPointerException - if either argument is null.

setIcon

public static void setIcon(MutableAttributeSet a,
                           Icon c)
Adds an icon attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
c - the icon (null not permitted).
Throws:
NullPointerException - if either argument is null.

setItalic

public static void setItalic(MutableAttributeSet a,
                             boolean b)
Adds an italic attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the new value of the italic attribute.
Throws:
NullPointerException - if a is null.

setLeftIndent

public static void setLeftIndent(MutableAttributeSet a,
                                 float i)
Adds a left indentation attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the indentation.
Throws:
NullPointerException - if a is null.

setLineSpacing

public static void setLineSpacing(MutableAttributeSet a,
                                  float i)
Adds a line spacing attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the line spacing.
Throws:
NullPointerException - if a is null.

setRightIndent

public static void setRightIndent(MutableAttributeSet a,
                                  float i)
Adds a right indentation attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the right indentation.
Throws:
NullPointerException - if a is null.

setSpaceAbove

public static void setSpaceAbove(MutableAttributeSet a,
                                 float i)
Adds a 'space above' attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the space above attribute value.
Throws:
NullPointerException - if a is null.

setSpaceBelow

public static void setSpaceBelow(MutableAttributeSet a,
                                 float i)
Adds a 'space below' attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
i - the space below attribute value.
Throws:
NullPointerException - if a is null.

setStrikeThrough

public static void setStrikeThrough(MutableAttributeSet a,
                                    boolean b)
Adds a strike-through attribue to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the strike-through attribute value.
Throws:
NullPointerException - if a is null.

setSubscript

public static void setSubscript(MutableAttributeSet a,
                                boolean b)
Adds a subscript attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the subscript attribute value.
Throws:
NullPointerException - if a is null.

setSuperscript

public static void setSuperscript(MutableAttributeSet a,
                                  boolean b)
Adds a superscript attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the superscript attribute value.
Throws:
NullPointerException - if a is null.

setTabSet

public static void setTabSet(MutableAttributeSet a,
                             TabSet tabs)
Adds a TabSet attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
tabs - the tab set (null not permitted).
Throws:
NullPointerException - if either argument is null.

setUnderline

public static void setUnderline(MutableAttributeSet a,
                                boolean b)
Adds an underline attribute to the specified set.
Parameters:
a - the attribute set (null not permitted).
b - the underline attribute value.
Throws:
NullPointerException - if a is null.

toString

public String toString()
Returns a string representation of the attribute key.
Overrides:
toString in interface Object
Returns:
A string representation of the attribute key.

StyleConstants.java -- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.