src/share/classes/java/awt/font/TextAttribute.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  48 /**
  49  * The <code>TextAttribute</code> class defines attribute keys and
  50  * attribute values used for text rendering.
  51  * <p>
  52  * <code>TextAttribute</code> instances are used as attribute keys to
  53  * identify attributes in
  54  * {@link java.awt.Font Font},
  55  * {@link java.awt.font.TextLayout TextLayout},
  56  * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
  57  * and other classes handling text attributes. Other constants defined
  58  * in this class can be used as attribute values.
  59  * <p>
  60  * For each text attribute, the documentation provides:
  61  * <UL>
  62  *   <LI>the type of its value,
  63  *   <LI>the relevant predefined constants, if any
  64  *   <LI>the default effect if the attribute is absent
  65  *   <LI>the valid values if there are limitations
  66  *   <LI>a description of the effect.
  67  * </UL>
  68  * <p>
  69  * <H3>Values</H3>
  70  * <UL>
  71  *   <LI>The values of attributes must always be immutable.
  72  *   <LI>Where value limitations are given, any value outside of that
  73  *   set is reserved for future use; the value will be treated as
  74  *   the default.
  75  *   <LI>The value <code>null</code> is treated the same as the
  76  *   default value and results in the default behavior.
  77  *   <li>If the value is not of the proper type, the attribute
  78  *   will be ignored.
  79  *   <li>The identity of the value does not matter, only the actual
  80  *   value.  For example, <code>TextAttribute.WEIGHT_BOLD</code> and
  81  *   <code>new Float(2.0)</code>
  82  *   indicate the same <code>WEIGHT</code>.
  83  *   <li>Attribute values of type <code>Number</code> (used for
  84  *   <code>WEIGHT</code>, <code>WIDTH</code>, <code>POSTURE</code>,
  85  *   <code>SIZE</code>, <code>JUSTIFICATION</code>, and
  86  *   <code>TRACKING</code>) can vary along their natural range and are
  87  *   not restricted to the predefined constants.
  88  *   <code>Number.floatValue()</code> is used to get the actual value
  89  *   from the <code>Number</code>.
  90  *   <li>The values for <code>WEIGHT</code>, <code>WIDTH</code>, and
  91  *   <code>POSTURE</code> are interpolated by the system, which
  92  *   can select the 'nearest available' font or use other techniques to
  93  *   approximate the user's request.
  94  *
  95  * </UL>
  96  *
  97  * <h4>Summary of attributes</h4>
  98  * <p>
  99  * <table style="float:center" border="0" cellspacing="0" cellpadding="2" width="%95"
 100  *     summary="Key, value type, principal constants, and default value
 101  *     behavior of all TextAttributes">
 102  * <tr style="background-color:#ccccff">
 103  * <th valign="TOP" align="CENTER">Key</th>
 104  * <th valign="TOP" align="CENTER">Value Type</th>
 105  * <th valign="TOP" align="CENTER">Principal Constants</th>
 106  * <th valign="TOP" align="CENTER">Default Value</th>
 107  * </tr>
 108  * <tr>
 109  * <td valign="TOP">{@link #FAMILY}</td>
 110  * <td valign="TOP">String</td>
 111  * <td valign="TOP">See Font {@link java.awt.Font#DIALOG DIALOG},
 112  * {@link java.awt.Font#DIALOG_INPUT DIALOG_INPUT},<br> {@link java.awt.Font#SERIF SERIF},
 113  * {@link java.awt.Font#SANS_SERIF SANS_SERIF}, and {@link java.awt.Font#MONOSPACED MONOSPACED}.
 114  * </td>
 115  * <td valign="TOP">"Default" (use platform default)</td>
 116  * </tr>
 117  * <tr style="background-color:#eeeeff">
 118  * <td valign="TOP">{@link #WEIGHT}</td>


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  48 /**
  49  * The <code>TextAttribute</code> class defines attribute keys and
  50  * attribute values used for text rendering.
  51  * <p>
  52  * <code>TextAttribute</code> instances are used as attribute keys to
  53  * identify attributes in
  54  * {@link java.awt.Font Font},
  55  * {@link java.awt.font.TextLayout TextLayout},
  56  * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
  57  * and other classes handling text attributes. Other constants defined
  58  * in this class can be used as attribute values.
  59  * <p>
  60  * For each text attribute, the documentation provides:
  61  * <UL>
  62  *   <LI>the type of its value,
  63  *   <LI>the relevant predefined constants, if any
  64  *   <LI>the default effect if the attribute is absent
  65  *   <LI>the valid values if there are limitations
  66  *   <LI>a description of the effect.
  67  * </UL>
  68  *
  69  * <H3>Values</H3>
  70  * <UL>
  71  *   <LI>The values of attributes must always be immutable.
  72  *   <LI>Where value limitations are given, any value outside of that
  73  *   set is reserved for future use; the value will be treated as
  74  *   the default.
  75  *   <LI>The value <code>null</code> is treated the same as the
  76  *   default value and results in the default behavior.
  77  *   <li>If the value is not of the proper type, the attribute
  78  *   will be ignored.
  79  *   <li>The identity of the value does not matter, only the actual
  80  *   value.  For example, <code>TextAttribute.WEIGHT_BOLD</code> and
  81  *   <code>new Float(2.0)</code>
  82  *   indicate the same <code>WEIGHT</code>.
  83  *   <li>Attribute values of type <code>Number</code> (used for
  84  *   <code>WEIGHT</code>, <code>WIDTH</code>, <code>POSTURE</code>,
  85  *   <code>SIZE</code>, <code>JUSTIFICATION</code>, and
  86  *   <code>TRACKING</code>) can vary along their natural range and are
  87  *   not restricted to the predefined constants.
  88  *   <code>Number.floatValue()</code> is used to get the actual value
  89  *   from the <code>Number</code>.
  90  *   <li>The values for <code>WEIGHT</code>, <code>WIDTH</code>, and
  91  *   <code>POSTURE</code> are interpolated by the system, which
  92  *   can select the 'nearest available' font or use other techniques to
  93  *   approximate the user's request.
  94  *
  95  * </UL>
  96  *
  97  * <h4>Summary of attributes</h4>

  98  * <table style="float:center" border="0" cellspacing="0" cellpadding="2" width="%95"
  99  *     summary="Key, value type, principal constants, and default value
 100  *     behavior of all TextAttributes">
 101  * <tr style="background-color:#ccccff">
 102  * <th valign="TOP" align="CENTER">Key</th>
 103  * <th valign="TOP" align="CENTER">Value Type</th>
 104  * <th valign="TOP" align="CENTER">Principal Constants</th>
 105  * <th valign="TOP" align="CENTER">Default Value</th>
 106  * </tr>
 107  * <tr>
 108  * <td valign="TOP">{@link #FAMILY}</td>
 109  * <td valign="TOP">String</td>
 110  * <td valign="TOP">See Font {@link java.awt.Font#DIALOG DIALOG},
 111  * {@link java.awt.Font#DIALOG_INPUT DIALOG_INPUT},<br> {@link java.awt.Font#SERIF SERIF},
 112  * {@link java.awt.Font#SANS_SERIF SANS_SERIF}, and {@link java.awt.Font#MONOSPACED MONOSPACED}.
 113  * </td>
 114  * <td valign="TOP">"Default" (use platform default)</td>
 115  * </tr>
 116  * <tr style="background-color:#eeeeff">
 117  * <td valign="TOP">{@link #WEIGHT}</td>