jdk/src/share/classes/javax/swing/text/StyleConstants.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 21244 7c2ac5ca05a2
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.Icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A collection of <em>well known</em> or common attribute keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * and methods to apply to an AttributeSet or MutableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * to get/set the properties in a typesafe manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * The paragraph attributes form the definition of a paragraph to be rendered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * All sizes are specified in points (such as found in postscript), a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * device independent measure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * </p>
21244
7c2ac5ca05a2 8026021: more fix of javadoc errors and warnings reported by doclint, see the description
cl
parents: 5506
diff changeset
    42
 * <p style="text-align:center"><img src="doc-files/paragraph.gif"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * alt="Diagram shows SpaceAbove, FirstLineIndent, LeftIndent, RightIndent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      and SpaceBelow a paragraph."></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class StyleConstants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Name of elements used to represent components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public static final String ComponentElementName = "component";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Name of elements used to represent icons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public static final String IconElementName = "icon";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Attribute name used to name the collection of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final Object NameAttribute = new StyleConstants("name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21244
diff changeset
    68
     * Attribute name used to identify the resolving parent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * set of attributes, if one is defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static final Object ResolveAttribute = new StyleConstants("resolver");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Attribute used to identify the model for embedded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * objects that have a model view separation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public static final Object ModelAttribute = new StyleConstants("model");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Returns the string representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @return the string
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        return representation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    // ---- character constants -----------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Bidirectional level of a character as assigned by the Unicode bidi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public static final Object BidiLevel = new CharacterConstants("bidiLevel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Name of the font family.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public static final Object FontFamily = new FontConstants("family");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * Name of the font family.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public static final Object Family = FontFamily;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Name of the font size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public static final Object FontSize = new FontConstants("size");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Name of the font size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public static final Object Size = FontSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Name of the bold attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public static final Object Bold = new FontConstants("bold");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Name of the italic attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public static final Object Italic = new FontConstants("italic");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Name of the underline attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public static final Object Underline = new CharacterConstants("underline");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Name of the Strikethrough attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public static final Object StrikeThrough = new CharacterConstants("strikethrough");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Name of the Superscript attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public static final Object Superscript = new CharacterConstants("superscript");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Name of the Subscript attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public static final Object Subscript = new CharacterConstants("subscript");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Name of the foreground color attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public static final Object Foreground = new ColorConstants("foreground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Name of the background color attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public static final Object Background = new ColorConstants("background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Name of the component attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public static final Object ComponentAttribute = new CharacterConstants("component");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Name of the icon attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public static final Object IconAttribute = new CharacterConstants("icon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Name of the input method composed text attribute. The value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * this attribute is an instance of AttributedString which represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public static final Object ComposedTextAttribute = new StyleConstants("composed text");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * The amount of space to indent the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * line of the paragraph.  This value may be negative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * to offset in the reverse direction.  The type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * is Float and specifies the size of the space
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * in points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public static final Object FirstLineIndent = new ParagraphConstants("FirstLineIndent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * The amount to indent the left side
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * of the paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Type is float and specifies the size in points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public static final Object LeftIndent = new ParagraphConstants("LeftIndent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * The amount to indent the right side
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * of the paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Type is float and specifies the size in points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public static final Object RightIndent = new ParagraphConstants("RightIndent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * The amount of space between lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * of the paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Type is float and specifies the size as a factor of the line height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public static final Object LineSpacing = new ParagraphConstants("LineSpacing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * The amount of space above the paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Type is float and specifies the size in points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public static final Object SpaceAbove = new ParagraphConstants("SpaceAbove");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * The amount of space below the paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * Type is float and specifies the size in points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public static final Object SpaceBelow = new ParagraphConstants("SpaceBelow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Alignment for the paragraph.  The type is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Integer.  Valid values are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <li>ALIGN_LEFT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <li>ALIGN_RIGHT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <li>ALIGN_CENTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * <li>ALIGN_JUSTIFED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public static final Object Alignment = new ParagraphConstants("Alignment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * TabSet for the paragraph, type is a TabSet containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * TabStops.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public static final Object TabSet = new ParagraphConstants("TabSet");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Orientation for a paragraph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public static final Object Orientation = new ParagraphConstants("Orientation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * A possible value for paragraph alignment.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * specifies that the text is aligned to the left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * indent and extra whitespace should be placed on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * the right.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public static final int ALIGN_LEFT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * A possible value for paragraph alignment.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * specifies that the text is aligned to the center
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * and extra whitespace should be placed equally on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * the left and right.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public static final int ALIGN_CENTER = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * A possible value for paragraph alignment.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * specifies that the text is aligned to the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * indent and extra whitespace should be placed on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * the left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public static final int ALIGN_RIGHT = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * A possible value for paragraph alignment.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * specifies that extra whitespace should be spread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * out through the rows of the paragraph with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * text lined up with the left and right indent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * except on the last line which should be aligned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * to the left.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public static final int ALIGN_JUSTIFIED = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    // --- character attribute accessors ---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Gets the BidiLevel setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @return the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public static int getBidiLevel(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        Integer o = (Integer) a.getAttribute(BidiLevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (o != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            return o.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        return 0;  // Level 0 is base level (non-embedded) left-to-right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * Sets the BidiLevel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @param o the bidi level value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public static void setBidiLevel(MutableAttributeSet a, int o) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   299
        a.addAttribute(BidiLevel, Integer.valueOf(o));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * Gets the component setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @return the component, null if none
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    public static Component getComponent(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        return (Component) a.getAttribute(ComponentAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * Sets the component attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @param c the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public static void setComponent(MutableAttributeSet a, Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        a.addAttribute(AbstractDocument.ElementNameAttribute, ComponentElementName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        a.addAttribute(ComponentAttribute, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Gets the icon setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return the icon, null if none
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public static Icon getIcon(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        return (Icon) a.getAttribute(IconAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Sets the icon attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @param c the icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public static void setIcon(MutableAttributeSet a, Icon c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        a.addAttribute(AbstractDocument.ElementNameAttribute, IconElementName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        a.addAttribute(IconAttribute, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * Gets the font family setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @return the font family, "Monospaced" as the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public static String getFontFamily(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        String family = (String) a.getAttribute(FontFamily);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        if (family == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            family = "Monospaced";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return family;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Sets the font attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @param fam the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public static void setFontFamily(MutableAttributeSet a, String fam) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        a.addAttribute(FontFamily, fam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Gets the font size setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @return the font size, 12 as the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public static int getFontSize(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        Integer size = (Integer) a.getAttribute(FontSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if (size != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            return size.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * Sets the font size attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @param s the font size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public static void setFontSize(MutableAttributeSet a, int s) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   389
        a.addAttribute(FontSize, Integer.valueOf(s));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Checks whether the bold attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    public static boolean isBold(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        Boolean bold = (Boolean) a.getAttribute(Bold);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        if (bold != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            return bold.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * Sets the bold attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    public static void setBold(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        a.addAttribute(Bold, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * Checks whether the italic attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public static boolean isItalic(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        Boolean italic = (Boolean) a.getAttribute(Italic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if (italic != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            return italic.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * Sets the italic attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    public static void setItalic(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        a.addAttribute(Italic, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * Checks whether the underline attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public static boolean isUnderline(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        Boolean underline = (Boolean) a.getAttribute(Underline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        if (underline != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            return underline.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Checks whether the strikethrough attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    public static boolean isStrikeThrough(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        Boolean strike = (Boolean) a.getAttribute(StrikeThrough);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (strike != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            return strike.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Checks whether the superscript attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public static boolean isSuperscript(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        Boolean superscript = (Boolean) a.getAttribute(Superscript);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        if (superscript != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            return superscript.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * Checks whether the subscript attribute is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @return true if set else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public static boolean isSubscript(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        Boolean subscript = (Boolean) a.getAttribute(Subscript);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        if (subscript != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            return subscript.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * Sets the underline attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    public static void setUnderline(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        a.addAttribute(Underline, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * Sets the strikethrough attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    public static void setStrikeThrough(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        a.addAttribute(StrikeThrough, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * Sets the superscript attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public static void setSuperscript(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        a.addAttribute(Superscript, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Sets the subscript attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @param b specifies true/false for setting the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public static void setSubscript(MutableAttributeSet a, boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        a.addAttribute(Subscript, Boolean.valueOf(b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * Gets the foreground color setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @return the color, Color.black as the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    public static Color getForeground(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        Color fg = (Color) a.getAttribute(Foreground);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (fg == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            fg = Color.black;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        return fg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * Sets the foreground color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @param fg the color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    public static void setForeground(MutableAttributeSet a, Color fg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        a.addAttribute(Foreground, fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * Gets the background color setting from the attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @return the color, Color.black as the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    public static Color getBackground(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        Color fg = (Color) a.getAttribute(Background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        if (fg == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            fg = Color.black;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        return fg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * Sets the background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @param fg the color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    public static void setBackground(MutableAttributeSet a, Color fg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        a.addAttribute(Background, fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    // --- paragraph attribute accessors ----------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * Gets the first line indent setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    public static float getFirstLineIndent(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        Float indent = (Float) a.getAttribute(FirstLineIndent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        if (indent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            return indent.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * Sets the first line indent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public static void setFirstLineIndent(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        a.addAttribute(FirstLineIndent, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * Gets the right indent setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    public static float getRightIndent(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        Float indent = (Float) a.getAttribute(RightIndent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        if (indent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            return indent.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Sets right indent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    public static void setRightIndent(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        a.addAttribute(RightIndent, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * Gets the left indent setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public static float getLeftIndent(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        Float indent = (Float) a.getAttribute(LeftIndent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        if (indent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            return indent.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * Sets left indent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public static void setLeftIndent(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        a.addAttribute(LeftIndent, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * Gets the line spacing setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    public static float getLineSpacing(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        Float space = (Float) a.getAttribute(LineSpacing);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        if (space != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            return space.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * Sets line spacing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    public static void setLineSpacing(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        a.addAttribute(LineSpacing, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * Gets the space above setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    public static float getSpaceAbove(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        Float space = (Float) a.getAttribute(SpaceAbove);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        if (space != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            return space.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * Sets space above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    public static void setSpaceAbove(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        a.addAttribute(SpaceAbove, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * Gets the space below setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * @return the value, 0 if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    public static float getSpaceBelow(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        Float space = (Float) a.getAttribute(SpaceBelow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        if (space != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            return space.floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * Sets space below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * @param i the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    public static void setSpaceBelow(MutableAttributeSet a, float i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        a.addAttribute(SpaceBelow, new Float(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * Gets the alignment setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @return the value <code>StyleConstants.ALIGN_LEFT</code> if not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    public static int getAlignment(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        Integer align = (Integer) a.getAttribute(Alignment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if (align != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            return align.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        return ALIGN_LEFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * Sets alignment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * @param align the alignment value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    public static void setAlignment(MutableAttributeSet a, int align) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   756
        a.addAttribute(Alignment, Integer.valueOf(align));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * Gets the TabSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * @param a the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * @return the <code>TabSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    public static TabSet getTabSet(AttributeSet a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        TabSet tabs = (TabSet)a.getAttribute(TabSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        // PENDING: should this return a default?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        return tabs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * Sets the TabSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @param a the attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @param tabs the TabSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    public static void setTabSet(MutableAttributeSet a, TabSet tabs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        a.addAttribute(TabSet, tabs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    // --- privates ---------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    static Object[] keys = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        NameAttribute, ResolveAttribute, BidiLevel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        FontFamily, FontSize, Bold, Italic, Underline,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        StrikeThrough, Superscript, Subscript, Foreground,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        Background, ComponentAttribute, IconAttribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        FirstLineIndent, LeftIndent, RightIndent, LineSpacing,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        SpaceAbove, SpaceBelow, Alignment, TabSet, Orientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        ModelAttribute, ComposedTextAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    StyleConstants(String representation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        this.representation = representation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    private String representation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * This is a typesafe enumeration of the <em>well-known</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * attributes that contribute to a paragraph style.  These are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * aliased by the outer class for general presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    public static class ParagraphConstants extends StyleConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        implements AttributeSet.ParagraphAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        private ParagraphConstants(String representation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            super(representation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     * This is a typesafe enumeration of the <em>well-known</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * attributes that contribute to a character style.  These are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * aliased by the outer class for general presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    public static class CharacterConstants extends StyleConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        implements AttributeSet.CharacterAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        private CharacterConstants(String representation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            super(representation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * This is a typesafe enumeration of the <em>well-known</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * attributes that contribute to a color.  These are aliased
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * by the outer class for general presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    public static class ColorConstants extends StyleConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        implements AttributeSet.ColorAttribute,  AttributeSet.CharacterAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        private ColorConstants(String representation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            super(representation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * This is a typesafe enumeration of the <em>well-known</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * attributes that contribute to a font.  These are aliased
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * by the outer class for general presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    public static class FontConstants extends StyleConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        private FontConstants(String representation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            super(representation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
}