diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text/StyleConstants.java')
-rw-r--r-- | libjava/classpath/javax/swing/text/StyleConstants.java | 823 |
1 files changed, 725 insertions, 98 deletions
diff --git a/libjava/classpath/javax/swing/text/StyleConstants.java b/libjava/classpath/javax/swing/text/StyleConstants.java index 598eaf621bc..c7906b8ad32 100644 --- a/libjava/classpath/javax/swing/text/StyleConstants.java +++ b/libjava/classpath/javax/swing/text/StyleConstants.java @@ -1,5 +1,5 @@ /* StyleConstants.java -- - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,45 +43,124 @@ import java.awt.Component; import javax.swing.Icon; +/** + * Represents standard attribute keys. This class also contains a set of + * useful static utility methods for querying and populating an + * {@link AttributeSet}. + * + * @since 1.2 + */ public class StyleConstants { + /** + * A value representing left alignment for the + * {@link ParagraphConstants#Alignment} attribute. + */ public static final int ALIGN_LEFT = 0; + + /** + * A value representing center alignment for the + * {@link ParagraphConstants#Alignment} attribute. + */ public static final int ALIGN_CENTER = 1; + + /** + * A value representing right alignment for the + * {@link ParagraphConstants#Alignment} attribute. + */ public static final int ALIGN_RIGHT = 2; + + /** + * A value representing ful justification for the + * {@link ParagraphConstants#Alignment} attribute. + */ public static final int ALIGN_JUSTIFIED = 3; + /** An alias for {@link CharacterConstants#Background}. */ public static final Object Background = CharacterConstants.Background; + + /** An alias for {@link CharacterConstants#BidiLevel}. */ public static final Object BidiLevel = CharacterConstants.BidiLevel; + + /** An alias for {@link CharacterConstants#Bold}. */ public static final Object Bold = CharacterConstants.Bold; - public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute; + + /** An alias for {@link CharacterConstants#ComponentAttribute}. */ + public static final Object ComponentAttribute + = CharacterConstants.ComponentAttribute; + + /** An alias for {@link CharacterConstants#Family}. */ public static final Object Family = CharacterConstants.Family; + + /** An alias for {@link CharacterConstants#Family}. */ public static final Object FontFamily = CharacterConstants.Family; + + /** An alias for {@link CharacterConstants#Size}. */ public static final Object FontSize = CharacterConstants.Size; + + /** An alias for {@link CharacterConstants#Foreground}. */ public static final Object Foreground = CharacterConstants.Foreground; + + /** An alias for {@link CharacterConstants#IconAttribute}. */ public static final Object IconAttribute = CharacterConstants.IconAttribute; + + /** An alias for {@link CharacterConstants#Italic}. */ public static final Object Italic = CharacterConstants.Italic; + + /** An alias for {@link CharacterConstants#Size}. */ public static final Object Size = CharacterConstants.Size; + + /** An alias for {@link CharacterConstants#StrikeThrough}. */ public static final Object StrikeThrough = CharacterConstants.StrikeThrough; + + /** An alias for {@link CharacterConstants#Subscript}. */ public static final Object Subscript = CharacterConstants.Subscript; + + /** An alias for {@link CharacterConstants#Superscript}. */ public static final Object Superscript = CharacterConstants.Superscript; + + /** An alias for {@link CharacterConstants#Underline}. */ public static final Object Underline = CharacterConstants.Underline; + /** An alias for {@link ParagraphConstants#Alignment}. */ public static final Object Alignment = ParagraphConstants.Alignment; - public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent; + + /** An alias for {@link ParagraphConstants#FirstLineIndent}. */ + public static final Object FirstLineIndent + = ParagraphConstants.FirstLineIndent; + + /** An alias for {@link ParagraphConstants#LeftIndent}. */ public static final Object LeftIndent = ParagraphConstants.LeftIndent; + + /** An alias for {@link ParagraphConstants#LineSpacing}. */ public static final Object LineSpacing = ParagraphConstants.LineSpacing; + + /** An alias for {@link ParagraphConstants#Orientation}. */ public static final Object Orientation = ParagraphConstants.Orientation; + + /** An alias for {@link ParagraphConstants#RightIndent}. */ public static final Object RightIndent = ParagraphConstants.RightIndent; + + /** An alias for {@link ParagraphConstants#SpaceAbove}. */ public static final Object SpaceAbove = ParagraphConstants.SpaceAbove; + + /** An alias for {@link ParagraphConstants#SpaceBelow}. */ public static final Object SpaceBelow = ParagraphConstants.SpaceBelow; + + /** An alias for {@link ParagraphConstants#TabSet}. */ public static final Object TabSet = ParagraphConstants.TabSet; public static final String ComponentElementName = "component"; + public static final String IconElementName = "icon"; - public static final Object ComposedTextAttribute = new StyleConstants("composed text"); + public static final Object ComposedTextAttribute + = new StyleConstants("composed text"); + public static final Object ModelAttribute = new StyleConstants("model"); + public static final Object NameAttribute = new StyleConstants("name"); + public static final Object ResolveAttribute = new StyleConstants("resolver"); String keyname; @@ -93,279 +172,727 @@ public class StyleConstants keyname = k; } + /** + * Returns a string representation of the attribute key. + * + * @return A string representation of the attribute key. + */ public String toString() { return keyname; } + /** + * Returns the alignment specified in the given attributes, or + * {@link #ALIGN_LEFT} if no alignment is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The alignment (typically one of {@link #ALIGN_LEFT}, + * {@link #ALIGN_RIGHT}, {@link #ALIGN_CENTER} or + * {@link #ALIGN_JUSTIFIED}). + * + * @see #setAlignment(MutableAttributeSet, int) + */ public static int getAlignment(AttributeSet a) { - if (a.isDefined(Alignment)) - return ((Integer)a.getAttribute(Alignment)).intValue(); + Integer i = (Integer) a.getAttribute(Alignment); + if (i != null) + return i.intValue(); else return ALIGN_LEFT; } + /** + * Returns the background color specified in the given attributes, or + * {@link Color#BLACK} if no background color is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The background color. + * + * @see #setBackground(MutableAttributeSet, Color) + */ public static Color getBackground(AttributeSet a) { - if (a.isDefined(Background)) - return (Color) a.getAttribute(Background); + Color c = (Color) a.getAttribute(Background); + if (c != null) + return c; else - return Color.WHITE; + return Color.BLACK; } - + + /** + * Returns the bidi level specified in the given attributes, or + * <code>0</code> if no bidi level is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The bidi level. + * + * @see #setBidiLevel(MutableAttributeSet, int) + */ public static int getBidiLevel(AttributeSet a) { - if (a.isDefined(BidiLevel)) - return ((Integer)a.getAttribute(BidiLevel)).intValue(); + Integer i = (Integer) a.getAttribute(BidiLevel); + if (i != null) + return i.intValue(); else return 0; } + /** + * Returns the component specified in the given attributes, or + * <code>null</code> if no component is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The component (possibly <code>null</code>). + * + * @see #setComponent(MutableAttributeSet, Component) + */ public static Component getComponent(AttributeSet a) { - if (a.isDefined(ComponentAttribute)) - return (Component) a.getAttribute(ComponentAttribute); + Component c = (Component) a.getAttribute(ComponentAttribute); + if (c != null) + return c; else - return (Component) null; + return null; } + /** + * Returns the indentation specified in the given attributes, or + * <code>0.0f</code> if no indentation is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The indentation. + * + * @see #setFirstLineIndent(MutableAttributeSet, float) + */ public static float getFirstLineIndent(AttributeSet a) { - if (a.isDefined(FirstLineIndent)) - return ((Float)a.getAttribute(FirstLineIndent)).floatValue(); + Float f = (Float) a.getAttribute(FirstLineIndent); + if (f != null) + return f.floatValue(); else - return 0.f; + return 0.0f; } + /** + * Returns the font family specified in the given attributes, or + * <code>Monospaced</code> if no font family is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The font family. + * + * @see #setFontFamily(MutableAttributeSet, String) + */ public static String getFontFamily(AttributeSet a) { - if (a.isDefined(FontFamily)) - return (String) a.getAttribute(FontFamily); + String ff = (String) a.getAttribute(FontFamily); + if (ff != null) + return ff; else return "Monospaced"; } + /** + * Returns the font size specified in the given attributes, or + * <code>12</code> if no font size is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The font size. + * + * @see #setFontSize(MutableAttributeSet, int) + */ public static int getFontSize(AttributeSet a) { - if (a.isDefined(FontSize)) - return ((Integer)a.getAttribute(FontSize)).intValue(); + Integer i = (Integer) a.getAttribute(FontSize); + if (i != null) + return i.intValue(); else return 12; } + /** + * Returns the foreground color specified in the given attributes, or + * {@link Color#BLACK} if no foreground color is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The foreground color. + * + * @see #setForeground(MutableAttributeSet, Color) + */ public static Color getForeground(AttributeSet a) { - if (a.isDefined(Foreground)) - return (Color) a.getAttribute(Foreground); + Color c = (Color) a.getAttribute(Foreground); + if (c != null) + return c; else return Color.BLACK; } + /** + * Returns the icon specified in the given attributes, or + * <code>null</code> if no icon is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The icon (possibly <code>null</code>). + * + * @see #setIcon(MutableAttributeSet, Icon) + */ public static Icon getIcon(AttributeSet a) { - if (a.isDefined(IconAttribute)) - return (Icon) a.getAttribute(IconAttribute); - else - return (Icon) null; + return (Icon) a.getAttribute(IconAttribute); } + /** + * Returns the left indentation specified in the given attributes, or + * <code>0.0f</code> if no left indentation is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The left indentation. + * + * @see #setLeftIndent(MutableAttributeSet, float) + */ public static float getLeftIndent(AttributeSet a) { - if (a.isDefined(LeftIndent)) - return ((Float)a.getAttribute(LeftIndent)).floatValue(); + Float f = (Float) a.getAttribute(LeftIndent); + if (f != null) + return f.floatValue(); else - return 0.f; + return 0.0f; } + /** + * Returns the line spacing specified in the given attributes, or + * <code>0.0f</code> if no line spacing is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The line spacing. + * + * @see #setLineSpacing(MutableAttributeSet, float) + */ public static float getLineSpacing(AttributeSet a) { - if (a.isDefined(LineSpacing)) - return ((Float)a.getAttribute(LineSpacing)).floatValue(); + Float f = (Float) a.getAttribute(LineSpacing); + if (f != null) + return f.floatValue(); else - return 0.f; + return 0.0f; } + /** + * Returns the right indentation specified in the given attributes, or + * <code>0.0f</code> if no right indentation is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The right indentation. + * + * @see #setRightIndent(MutableAttributeSet, float) + */ public static float getRightIndent(AttributeSet a) { - if (a.isDefined(RightIndent)) - return ((Float)a.getAttribute(RightIndent)).floatValue(); + Float f = (Float) a.getAttribute(RightIndent); + if (f != null) + return f.floatValue(); else - return 0.f; + return 0.0f; } + /** + * Returns the 'space above' specified in the given attributes, or + * <code>0.0f</code> if no 'space above' is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The 'space above'. + * + * @see #setSpaceAbove(MutableAttributeSet, float) + */ public static float getSpaceAbove(AttributeSet a) { - if (a.isDefined(SpaceAbove)) - return ((Float)a.getAttribute(SpaceAbove)).floatValue(); - else - return 0.f; + Float f = (Float) a.getAttribute(SpaceAbove); + if (f != null) + return f.floatValue(); + else + return 0.0f; } + /** + * Returns the 'space below' specified in the given attributes, or + * <code>0.0f</code> if no 'space below' is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The 'space below'. + * + * @see #setSpaceBelow(MutableAttributeSet, float) + */ public static float getSpaceBelow(AttributeSet a) { - if (a.isDefined(SpaceBelow)) - return ((Float)a.getAttribute(SpaceBelow)).floatValue(); + Float f = (Float) a.getAttribute(SpaceBelow); + if (f != null) + return f.floatValue(); else - return 0.f; + return 0.0f; } + /** + * Returns the tab set specified in the given attributes, or + * <code>null</code> if no tab set is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The tab set. + * + * @see #setTabSet(MutableAttributeSet, javax.swing.text.TabSet) + */ public static javax.swing.text.TabSet getTabSet(AttributeSet a) { - if (a.isDefined(StyleConstants.TabSet)) - return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet); - else - return (javax.swing.text.TabSet) null; + // I'm guessing that the fully qualified class name is to differentiate + // between the TabSet class and the TabSet (attribute) instance on some + // compiler... + return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet); } + /** + * Returns the value of the bold flag in the given attributes, or + * <code>false</code> if no bold flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The bold flag. + * + * @see #setBold(MutableAttributeSet, boolean) + */ public static boolean isBold(AttributeSet a) { - if (a.isDefined(Bold)) - return ((Boolean) a.getAttribute(Bold)).booleanValue(); + Boolean b = (Boolean) a.getAttribute(Bold); + if (b != null) + return b.booleanValue(); else - return false; + return false; } + /** + * Returns the value of the italic flag in the given attributes, or + * <code>false</code> if no italic flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The italic flag. + * + * @see #setItalic(MutableAttributeSet, boolean) + */ public static boolean isItalic(AttributeSet a) { - if (a.isDefined(Italic)) - return ((Boolean) a.getAttribute(Italic)).booleanValue(); + Boolean b = (Boolean) a.getAttribute(Italic); + if (b != null) + return b.booleanValue(); else - return false; + return false; } + /** + * Returns the value of the strike-through flag in the given attributes, or + * <code>false</code> if no strike-through flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The strike-through flag. + * + * @see #setStrikeThrough(MutableAttributeSet, boolean) + */ public static boolean isStrikeThrough(AttributeSet a) { - if (a.isDefined(StrikeThrough)) - return ((Boolean) a.getAttribute(StrikeThrough)).booleanValue(); + Boolean b = (Boolean) a.getAttribute(StrikeThrough); + if (b != null) + return b.booleanValue(); else - return false; + return false; } + /** + * Returns the value of the subscript flag in the given attributes, or + * <code>false</code> if no subscript flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The subscript flag. + * + * @see #setSubscript(MutableAttributeSet, boolean) + */ public static boolean isSubscript(AttributeSet a) { - if (a.isDefined(Subscript)) - return ((Boolean) a.getAttribute(Subscript)).booleanValue(); + Boolean b = (Boolean) a.getAttribute(Subscript); + if (b != null) + return b.booleanValue(); else - return false; + return false; } + /** + * Returns the value of the superscript flag in the given attributes, or + * <code>false</code> if no superscript flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The superscript flag. + * + * @see #setSuperscript(MutableAttributeSet, boolean) + */ public static boolean isSuperscript(AttributeSet a) { - if (a.isDefined(Superscript)) - return ((Boolean) a.getAttribute(Superscript)).booleanValue(); - else - return false; + Boolean b = (Boolean) a.getAttribute(Superscript); + if (b != null) + return b.booleanValue(); + else + return false; } + /** + * Returns the value of the underline flag in the given attributes, or + * <code>false</code> if no underline flag is specified. + * + * @param a the attribute set (<code>null</code> not permitted). + * + * @return The underline flag. + * + * @see #setUnderline(MutableAttributeSet, boolean) + */ public static boolean isUnderline(AttributeSet a) { - if (a.isDefined(Underline)) - return ((Boolean) a.getAttribute(Underline)).booleanValue(); + Boolean b = (Boolean) a.getAttribute(Underline); + if (b != null) + return b.booleanValue(); else - return false; + return false; } + /** + * Adds an alignment attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param align the alignment (typically one of + * {@link StyleConstants#ALIGN_LEFT}, + * {@link StyleConstants#ALIGN_RIGHT}, + * {@link StyleConstants#ALIGN_CENTER} or + * {@link StyleConstants#ALIGN_JUSTIFIED}). + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getAlignment(AttributeSet) + */ public static void setAlignment(MutableAttributeSet a, int align) { a.addAttribute(Alignment, new Integer(align)); } - public static void setBackground(MutableAttributeSet a, Color fg) + /** + * Adds a background attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param bg the background (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getBackground(AttributeSet) + */ + public static void setBackground(MutableAttributeSet a, Color bg) { - a.addAttribute(Background, fg); + a.addAttribute(Background, bg); } + /** + * Adds a bidi-level attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param lev the level. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getBidiLevel(AttributeSet) + */ public static void setBidiLevel(MutableAttributeSet a, int lev) { a.addAttribute(BidiLevel, new Integer(lev)); } + /** + * Adds a bold attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the new value of the bold attribute. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isBold(AttributeSet) + */ public static void setBold(MutableAttributeSet a, boolean b) { a.addAttribute(Bold, Boolean.valueOf(b)); } + /** + * Adds a component attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param c the component (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getComponent(AttributeSet) + */ public static void setComponent(MutableAttributeSet a, Component c) { a.addAttribute(ComponentAttribute, c); } + /** + * Adds a first line indentation attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the indentation. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getFirstLineIndent(AttributeSet) + */ public static void setFirstLineIndent(MutableAttributeSet a, float i) { a.addAttribute(FirstLineIndent, new Float(i)); } + /** + * Adds a font family attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param fam the font family name (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getFontFamily(AttributeSet) + */ public static void setFontFamily(MutableAttributeSet a, String fam) { a.addAttribute(FontFamily, fam); } + /** + * Adds a font size attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param s the font size (in points). + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getFontSize(AttributeSet) + */ public static void setFontSize(MutableAttributeSet a, int s) { a.addAttribute(FontSize, new Integer(s)); } + /** + * Adds a foreground color attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param fg the foreground color (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getForeground(AttributeSet) + */ public static void setForeground(MutableAttributeSet a, Color fg) { a.addAttribute(Foreground, fg); } + /** + * Adds an icon attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param c the icon (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getIcon(AttributeSet) + */ public static void setIcon(MutableAttributeSet a, Icon c) { a.addAttribute(IconAttribute, c); } + /** + * Adds an italic attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the new value of the italic attribute. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isItalic(AttributeSet) + */ public static void setItalic(MutableAttributeSet a, boolean b) { a.addAttribute(Italic, Boolean.valueOf(b)); } + /** + * Adds a left indentation attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the indentation. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getLeftIndent(AttributeSet) + */ public static void setLeftIndent(MutableAttributeSet a, float i) { a.addAttribute(LeftIndent, new Float(i)); } + /** + * Adds a line spacing attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the line spacing. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getLineSpacing(AttributeSet) + */ public static void setLineSpacing(MutableAttributeSet a, float i) { a.addAttribute(LineSpacing, new Float(i)); } + /** + * Adds a right indentation attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the right indentation. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getRightIndent(AttributeSet) + */ public static void setRightIndent(MutableAttributeSet a, float i) { a.addAttribute(RightIndent, new Float(i)); } + /** + * Adds a 'space above' attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the space above attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getSpaceAbove(AttributeSet) + */ public static void setSpaceAbove(MutableAttributeSet a, float i) { a.addAttribute(SpaceAbove, new Float(i)); } + /** + * Adds a 'space below' attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param i the space below attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #getSpaceBelow(AttributeSet) + */ public static void setSpaceBelow(MutableAttributeSet a, float i) { a.addAttribute(SpaceBelow, new Float(i)); } + /** + * Adds a strike-through attribue to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the strike-through attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isStrikeThrough(AttributeSet) + */ public static void setStrikeThrough(MutableAttributeSet a, boolean b) { a.addAttribute(StrikeThrough, Boolean.valueOf(b)); } + /** + * Adds a subscript attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the subscript attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isSubscript(AttributeSet) + */ public static void setSubscript(MutableAttributeSet a, boolean b) { a.addAttribute(Subscript, Boolean.valueOf(b)); } + /** + * Adds a superscript attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the superscript attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isSuperscript(AttributeSet) + */ public static void setSuperscript(MutableAttributeSet a, boolean b) { a.addAttribute(Superscript, Boolean.valueOf(b)); } - public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs) + /** + * Adds a {@link TabSet} attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param tabs the tab set (<code>null</code> not permitted). + * + * @throws NullPointerException if either argument is <code>null</code>. + * + * @see #getTabSet(AttributeSet) + */ + public static void setTabSet(MutableAttributeSet a, + javax.swing.text.TabSet tabs) { a.addAttribute(StyleConstants.TabSet, tabs); } + /** + * Adds an underline attribute to the specified set. + * + * @param a the attribute set (<code>null</code> not permitted). + * @param b the underline attribute value. + * + * @throws NullPointerException if <code>a</code> is <code>null</code>. + * + * @see #isUnderline(AttributeSet) + */ public static void setUnderline(MutableAttributeSet a, boolean b) { a.addAttribute(Underline, Boolean.valueOf(b)); @@ -373,73 +900,173 @@ public class StyleConstants // The remainder are so-called "typesafe enumerations" which // alias subsets of the above constants. + + /** + * A set of keys for attributes that apply to characters. + */ public static class CharacterConstants extends StyleConstants implements AttributeSet.CharacterAttribute { + /** + * Private constructor prevents new instances being created. + * + * @param k the key name. + */ private CharacterConstants(String k) { super(k); } - public static Object Background = ColorConstants.Background; - public static Object BidiLevel = new CharacterConstants("bidiLevel"); - public static Object Bold = FontConstants.Bold; - public static Object ComponentAttribute = new CharacterConstants("component"); - public static Object Family = FontConstants.Family; - public static Object Size = FontConstants.Size; - public static Object Foreground = ColorConstants.Foreground; - public static Object IconAttribute = new CharacterConstants("icon"); - public static Object Italic = FontConstants.Italic; - public static Object StrikeThrough = new CharacterConstants("strikethrough"); - public static Object Subscript = new CharacterConstants("subscript"); - public static Object Superscript = new CharacterConstants("superscript"); - public static Object Underline = new CharacterConstants("underline"); + /** An alias for {@link ColorConstants#Background}. */ + public static final Object Background = ColorConstants.Background; + + /** A key for the bidi level character attribute. */ + public static final Object BidiLevel = new CharacterConstants("bidiLevel"); + + /** An alias for {@link FontConstants#Bold}. */ + public static final Object Bold = FontConstants.Bold; + + /** A key for the component character attribute. */ + public static final Object ComponentAttribute + = new CharacterConstants("component"); + + /** An alias for {@link FontConstants#Family}. */ + public static final Object Family = FontConstants.Family; + + /** An alias for {@link FontConstants#Size}. */ + public static final Object Size = FontConstants.Size; + + /** An alias for {@link ColorConstants#Foreground}. */ + public static final Object Foreground = ColorConstants.Foreground; + + /** A key for the icon character attribute. */ + public static final Object IconAttribute = new CharacterConstants("icon"); + + /** A key for the italic character attribute. */ + public static final Object Italic = FontConstants.Italic; + + /** A key for the strike through character attribute. */ + public static final Object StrikeThrough + = new CharacterConstants("strikethrough"); + + /** A key for the subscript character attribute. */ + public static final Object Subscript = new CharacterConstants("subscript"); + + /** A key for the superscript character attribute. */ + public static final Object Superscript + = new CharacterConstants("superscript"); + + /** A key for the underline character attribute. */ + public static final Object Underline = new CharacterConstants("underline"); + } + /** + * A set of keys for attributes that relate to colors. + */ public static class ColorConstants extends StyleConstants implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute { + /** + * Private constructor prevents new instances being created. + * + * @param k the key name. + */ private ColorConstants(String k) { super(k); } - public static Object Foreground = new ColorConstants("foreground"); - public static Object Background = new ColorConstants("background"); + + /** A key for the foreground color attribute. */ + public static final Object Foreground = new ColorConstants("foreground"); + + /** A key for the background color attribute. */ + public static final Object Background = new ColorConstants("background"); } + /** + * A set of keys for attributes that apply to fonts. + */ public static class FontConstants extends StyleConstants implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute { + /** + * Private constructor prevents new instances being created. + * + * @param k the key name. + */ private FontConstants(String k) { super(k); } - public static Object Bold = new FontConstants("bold"); - public static Object Family = new FontConstants("family"); - public static Object Italic = new FontConstants("italic"); - public static Object Size = new FontConstants("size"); + + /** A key for the bold font attribute. */ + public static final Object Bold = new FontConstants("bold"); + + /** A key for the family font attribute. */ + public static final Object Family = new FontConstants("family"); + + /** A key for the italic font attribute. */ + public static final Object Italic = new FontConstants("italic"); + + /** A key for the size font attribute. */ + public static final Object Size = new FontConstants("size"); } + /** + * A set of keys for attributes that apply to paragraphs. + */ public static class ParagraphConstants extends StyleConstants implements AttributeSet.ParagraphAttribute { + /** + * Private constructor prevents new instances being created. + * + * @param k the key name. + */ private ParagraphConstants(String k) { super(k); } - public static Object Alignment = new ParagraphConstants("Alignment"); - public static Object FirstLineIndent = new ParagraphConstants("FirstLineIndent"); - public static Object LeftIndent = new ParagraphConstants("LeftIndent"); - public static Object LineSpacing = new ParagraphConstants("LineSpacing"); - public static Object Orientation = new ParagraphConstants("Orientation"); - public static Object RightIndent = new ParagraphConstants("RightIndent"); - public static Object SpaceAbove = new ParagraphConstants("SpaceAbove"); - public static Object SpaceBelow = new ParagraphConstants("SpaceBelow"); - public static Object TabSet = new ParagraphConstants("TabSet"); + + /** A key for the alignment paragraph attribute. */ + public static final Object Alignment = new ParagraphConstants("Alignment"); + + /** A key for the first line indentation paragraph attribute. */ + public static final Object FirstLineIndent + = new ParagraphConstants("FirstLineIndent"); + + /** A key for the left indentation paragraph attribute. */ + public static final Object LeftIndent + = new ParagraphConstants("LeftIndent"); + + /** A key for the line spacing paragraph attribute. */ + public static final Object LineSpacing + = new ParagraphConstants("LineSpacing"); + + /** A key for the orientation paragraph attribute. */ + public static final Object Orientation + = new ParagraphConstants("Orientation"); + + /** A key for the right indentation paragraph attribute. */ + public static final Object RightIndent + = new ParagraphConstants("RightIndent"); + + /** A key for the 'space above' paragraph attribute. */ + public static final Object SpaceAbove + = new ParagraphConstants("SpaceAbove"); + + /** A key for the 'space below' paragraph attribute. */ + public static final Object SpaceBelow + = new ParagraphConstants("SpaceBelow"); + + /** A key for the tabset paragraph attribute. */ + public static final Object TabSet = new ParagraphConstants("TabSet"); + } } |