jdk/src/java.desktop/share/classes/javax/swing/text/AttributeSet.java
author serb
Mon, 06 Mar 2017 22:52:45 +0300
changeset 44155 1bf93336ea45
parent 25859 3317bb8137f4
permissions -rw-r--r--
8158209: Editing in TableView breaks the layout, when the document is I18n Reviewed-by: serb, alexsch Contributed-by: Abossolo Foh Guy <guy.abossolo.foh@scientificware.com>
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: 20428
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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * A collection of unique attributes.  This is a read-only,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * immutable interface.  An attribute is basically a key and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * a value assigned to the key.  The collection may represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * something like a style run, a logical style, etc.  These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * are generally used to describe features that will contribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * to some graphical representation such as a font.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * set of possible keys is unbounded and can be anything.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Typically View implementations will respond to attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * definitions and render something to represent the attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Attributes can potentially resolve in a hierarchy.  If a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * key doesn't resolve locally, and a resolving parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * exists, the key will be resolved through the parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see MutableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public interface AttributeSet {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * This interface is the type signature that is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * to be present on any attribute key that contributes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * the determination of what font to use to render some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * text.  This is not considered to be a closed set, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * definition can change across version of the platform and can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * be amended by additional user added entries that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * correspond to logical settings that are specific to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * some type of content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public interface FontAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * This interface is the type signature that is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * to be present on any attribute key that contributes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * presentation of color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public interface ColorAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * This interface is the type signature that is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * to be present on any attribute key that contributes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * character level presentation.  This would be any attribute
20158
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 5506
diff changeset
    74
     * that applies to a so-called <i>run</i> of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * style.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public interface CharacterAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * This interface is the type signature that is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * to be present on any attribute key that contributes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * the paragraph level presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public interface ParagraphAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Returns the number of attributes that are defined locally in this set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Attributes that are defined in the parent set are not included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 20158
diff changeset
    92
     * @return the number of attributes &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public int getAttributeCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Checks whether the named attribute has a value specified in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * the set without resolving through another attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param attrName the attribute name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return true if the attribute has a value specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public boolean isDefined(Object attrName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Determines if the two attribute sets are equivalent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param attr an attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @return true if the sets are equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public boolean isEqual(AttributeSet attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Returns an attribute set that is guaranteed not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * to change over time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return a copy of the attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public AttributeSet copyAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Fetches the value of the given attribute. If the value is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * locally, the search is continued upward through the resolving
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * parent (if one exists) until the value is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * found or there are no more parents.  If the value is not found,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param key the non-null key of the attribute binding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return the value of the attribute, or {@code null} if not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public Object getAttribute(Object key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Returns an enumeration over the names of the attributes that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * defined locally in the set. Names of attributes defined in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * resolving parent, if any, are not included. The values of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <code>Enumeration</code> may be anything and are not constrained to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * a particular <code>Object</code> type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * This method never returns {@code null}. For a set with no attributes, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * returns an empty {@code Enumeration}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @return the names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public Enumeration<?> getAttributeNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Returns {@code true} if this set defines an attribute with the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * name and an equal value. If such an attribute is not found locally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * it is searched through in the resolving parent hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param name the non-null attribute name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param value the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @return {@code true} if the set defines the attribute with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *     equal value, either locally or through its resolving parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @throws NullPointerException if either {@code name} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *      {@code value} is {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public boolean containsAttribute(Object name, Object value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Returns {@code true} if this set defines all the attributes from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * given set with equal values. If an attribute is not found locally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * it is searched through in the resolving parent hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param attributes the set of attributes to check against
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @return {@code true} if this set defines all the attributes with equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *              values, either locally or through its resolving parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @throws NullPointerException if {@code attributes} is {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public boolean containsAttributes(AttributeSet attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Gets the resolving parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @return the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public AttributeSet getResolveParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Attribute name used to name the collection of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public static final Object NameAttribute = StyleConstants.NameAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Attribute name used to identify the resolving parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * set of attributes, if one is defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public static final Object ResolveAttribute = StyleConstants.ResolveAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
}