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