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

Print this page
rev 10196 : [mq]: 8038092
   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


  27  * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
  28  * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
  29  *
  30  * The original version of this source code and documentation is
  31  * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
  32  * of IBM. These materials are provided under terms of a License
  33  * Agreement between Taligent and Sun. This technology is protected
  34  * by multiple US and International patents.
  35  *
  36  * This notice and attribution to Taligent may not be removed.
  37  * Taligent is a registered trademark of Taligent, Inc.
  38  *
  39  */
  40 
  41 package java.awt.font;
  42 
  43 import java.io.InvalidObjectException;
  44 import java.text.AttributedCharacterIterator.Attribute;
  45 import java.util.Map;
  46 import java.util.HashMap;

  47 
  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.


 240  * <td valign="TOP">0 (do not form optional ligatures)</td>
 241  * </tr>
 242  * <tr>
 243  * <td valign="TOP">{@link #TRACKING}</td>
 244  * <td valign="TOP">Number</td>
 245  * <td valign="TOP">TRACKING_LOOSE, TRACKING_TIGHT</td>
 246  * <td valign="TOP">0 (do not add tracking)</td>
 247  * </tr>
 248  * </table>
 249  *
 250  * @see java.awt.Font
 251  * @see java.awt.font.TextLayout
 252  * @see java.text.AttributedCharacterIterator
 253  */
 254 public final class TextAttribute extends Attribute {
 255 
 256     // table of all instances in this class, used by readResolve
 257     private static final Map<String, TextAttribute>
 258             instanceMap = new HashMap<String, TextAttribute>(29);
 259 







 260     /**
 261      * Constructs a <code>TextAttribute</code> with the specified name.
 262      * @param name the attribute name to assign to this
 263      * <code>TextAttribute</code>
 264      */
 265     protected TextAttribute(String name) {
 266         super(name);
 267         if (this.getClass() == TextAttribute.class) {
 268             instanceMap.put(name, this);
 269         }
 270     }
 271 
 272     /**
 273      * Resolves instances being deserialized to the predefined constants.
 274      */
 275     protected Object readResolve() throws InvalidObjectException {
 276         if (this.getClass() != TextAttribute.class) {
 277             throw new InvalidObjectException(
 278                 "subclass didn't correctly implement readResolve");
 279         }


   1 /*
   2  * Copyright (c) 1997, 2014, 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


  27  * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
  28  * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
  29  *
  30  * The original version of this source code and documentation is
  31  * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
  32  * of IBM. These materials are provided under terms of a License
  33  * Agreement between Taligent and Sun. This technology is protected
  34  * by multiple US and International patents.
  35  *
  36  * This notice and attribution to Taligent may not be removed.
  37  * Taligent is a registered trademark of Taligent, Inc.
  38  *
  39  */
  40 
  41 package java.awt.font;
  42 
  43 import java.io.InvalidObjectException;
  44 import java.text.AttributedCharacterIterator.Attribute;
  45 import java.util.Map;
  46 import java.util.HashMap;
  47 import sun.misc.SharedSecrets;
  48 
  49 /**
  50  * The <code>TextAttribute</code> class defines attribute keys and
  51  * attribute values used for text rendering.
  52  * <p>
  53  * <code>TextAttribute</code> instances are used as attribute keys to
  54  * identify attributes in
  55  * {@link java.awt.Font Font},
  56  * {@link java.awt.font.TextLayout TextLayout},
  57  * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
  58  * and other classes handling text attributes. Other constants defined
  59  * in this class can be used as attribute values.
  60  * <p>
  61  * For each text attribute, the documentation provides:
  62  * <UL>
  63  *   <LI>the type of its value,
  64  *   <LI>the relevant predefined constants, if any
  65  *   <LI>the default effect if the attribute is absent
  66  *   <LI>the valid values if there are limitations
  67  *   <LI>a description of the effect.


 241  * <td valign="TOP">0 (do not form optional ligatures)</td>
 242  * </tr>
 243  * <tr>
 244  * <td valign="TOP">{@link #TRACKING}</td>
 245  * <td valign="TOP">Number</td>
 246  * <td valign="TOP">TRACKING_LOOSE, TRACKING_TIGHT</td>
 247  * <td valign="TOP">0 (do not add tracking)</td>
 248  * </tr>
 249  * </table>
 250  *
 251  * @see java.awt.Font
 252  * @see java.awt.font.TextLayout
 253  * @see java.text.AttributedCharacterIterator
 254  */
 255 public final class TextAttribute extends Attribute {
 256 
 257     // table of all instances in this class, used by readResolve
 258     private static final Map<String, TextAttribute>
 259             instanceMap = new HashMap<String, TextAttribute>(29);
 260 
 261     // For access from java.text.Bidi
 262     static {
 263         if (SharedSecrets.getJavaAWTFontAccess() == null) {
 264             SharedSecrets.setJavaAWTFontAccess(new JavaAWTFontAccessImpl());
 265         }
 266     }
 267 
 268     /**
 269      * Constructs a <code>TextAttribute</code> with the specified name.
 270      * @param name the attribute name to assign to this
 271      * <code>TextAttribute</code>
 272      */
 273     protected TextAttribute(String name) {
 274         super(name);
 275         if (this.getClass() == TextAttribute.class) {
 276             instanceMap.put(name, this);
 277         }
 278     }
 279 
 280     /**
 281      * Resolves instances being deserialized to the predefined constants.
 282      */
 283     protected Object readResolve() throws InvalidObjectException {
 284         if (this.getClass() != TextAttribute.class) {
 285             throw new InvalidObjectException(
 286                 "subclass didn't correctly implement readResolve");
 287         }