jdk/src/share/classes/java/awt/RenderingHints.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 15994 5c8a3d840366
child 21777 c0a423e43b0d
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2006, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.awt.SunHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * The {@code RenderingHints} class defines and manages collections of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * keys and associated values which allow an application to provide input
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * into the choice of algorithms used by other classes which perform
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * rendering and image manipulation services.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The {@link java.awt.Graphics2D} class, and classes that implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * {@link java.awt.image.BufferedImageOp} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * {@link java.awt.image.RasterOp} all provide methods to get and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * possibly to set individual or groups of {@code RenderingHints}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * keys and their associated values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * When those implementations perform any rendering or image manipulation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * operations they should examine the values of any {@code RenderingHints}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * that were requested by the caller and tailor the algorithms used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * accordingly and to the best of their ability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Note that since these keys and values are <i>hints</i>, there is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * no requirement that a given implementation supports all possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * choices indicated below or that it can respond to requests to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * modify its choice of algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The values of the various hint keys may also interact such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * while all variants of a given key are supported in one situation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * the implementation may be more restricted when the values associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * with other keys are modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * For example, some implementations may be able to provide several
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * types of dithering when the antialiasing hint is turned off, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * have little control over dithering when antialiasing is on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * The full set of supported keys and hints may also vary by destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * since runtimes may use different underlying modules to render to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * the screen, or to {@link java.awt.image.BufferedImage} objects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * or while printing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * Implementations are free to ignore the hints completely, but should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * try to use an implementation algorithm that is as close as possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * to the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * If an implementation supports a given algorithm when any value is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * for an associated hint key, then minimally it must do so when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * value for that key is the exact value that specifies the algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * The keys used to control the hints are all special values that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * subclass the associated {@link RenderingHints.Key} class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Many common hints are expressed below as static constants in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * class, but the list is not meant to be exhaustive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Other hints may be created by other packages by defining new objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * which subclass the {@code Key} class and defining the associated values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
public class RenderingHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    implements Map<Object,Object>, Cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Defines the base type of all keys used along with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * {@link RenderingHints} class to control various
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * algorithm choices in the rendering and imaging pipelines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Instances of this class are immutable and unique which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * means that tests for matches can be made using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * {@code ==} operator instead of the more expensive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * {@code equals()} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public abstract static class Key {
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 10419
diff changeset
    95
        private static HashMap<Object,Object> identitymap = new HashMap<>(17);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        private String getIdentity() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            // Note that the identity string is dependent on 3 variables:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            //     - the name of the subclass of Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            //     - the identityHashCode of the subclass of Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            //     - the integer key of the Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            // It is theoretically possible for 2 distinct keys to collide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            // along all 3 of those attributes in the context of multiple
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 15994
diff changeset
   104
            // class loaders, but that occurrence will be extremely rare and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            // we account for that possibility below in the recordIdentity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            // method by slightly relaxing our uniqueness guarantees if we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            // end up in that situation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            return getClass().getName()+"@"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                Integer.toHexString(System.identityHashCode(getClass()))+":"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                Integer.toHexString(privatekey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        private synchronized static void recordIdentity(Key k) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            Object identity = k.getIdentity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            Object otherref = identitymap.get(identity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            if (otherref != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                Key otherkey = (Key) ((WeakReference) otherref).get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                if (otherkey != null && otherkey.getClass() == k.getClass()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    throw new IllegalArgumentException(identity+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                                       " already registered");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                // Note that this system can fail in a mostly harmless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                // way.  If we end up generating the same identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                // String for 2 different classes (a very rare case)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                // then we correctly avoid throwing the exception above,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                // but we are about to drop through to a statement that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                // will replace the entry for the old Key subclass with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                // an entry for the new Key subclass.  At that time the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                // old subclass will be vulnerable to someone generating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                // a duplicate Key instance for it.  We could bail out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                // of the method here and let the old identity keep its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                // record in the map, but we are more likely to see a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                // duplicate key go by for the new class than the old
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                // one since the new one is probably still in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                // initialization stage.  In either case, the probability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                // of loading 2 classes in the same VM with the same name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                // and identityHashCode should be nearly impossible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            // Note: Use a weak reference to avoid holding on to extra
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            // objects and classes after they should be unloaded.
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 10419
diff changeset
   141
            identitymap.put(identity, new WeakReference<Key>(k));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        private int privatekey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
         * Construct a key using the indicated private key.  Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
         * subclass of Key maintains its own unique domain of integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         * keys.  No two objects with the same integer key and of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         * same specific subclass can be constructed.  An exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
         * will be thrown if an attempt is made to construct another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
         * object of a given class with the same integer key as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
         * pre-existing instance of that subclass of Key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
         * @param privatekey the specified key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        protected Key(int privatekey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            this.privatekey = privatekey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            recordIdentity(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
         * Returns true if the specified object is a valid value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         * for this Key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
         * @param val the <code>Object</code> to test for validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * @return <code>true</code> if <code>val</code> is valid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         *         <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        public abstract boolean isCompatibleValue(Object val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
         * Returns the private integer key that the subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         * instantiated this Key with.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * @return the private integer key that the subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         * instantiated this Key with.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        protected final int intKey() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            return privatekey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         * The hash code for all Key objects will be the same as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
         * system identity code of the object as defined by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
         * System.identityHashCode() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        public final int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            return super.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
         * The equals method for all Key objects will return the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
         * result as the equality operator '=='.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        public final boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            return this == o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 10419
diff changeset
   198
    HashMap<Object,Object> hintmap = new HashMap<>(7);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Antialiasing hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * The {@code ANTIALIASING} hint controls whether or not the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * geometry rendering methods of a {@link Graphics2D} object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * will attempt to reduce aliasing artifacts along the edges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * of shapes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * A typical antialiasing algorithm works by blending the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * colors of the pixels along the boundary of a shape with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * requested fill paint according to the estimated partial pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * coverage of the shape.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * <li>{@link #VALUE_ANTIALIAS_ON}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * <li>{@link #VALUE_ANTIALIAS_OFF}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <li>{@link #VALUE_ANTIALIAS_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public static final Key KEY_ANTIALIASING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        SunHints.KEY_ANTIALIASING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Antialiasing hint value -- rendering is done with antialiasing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @see #KEY_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public static final Object VALUE_ANTIALIAS_ON =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        SunHints.VALUE_ANTIALIAS_ON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * Antialiasing hint value -- rendering is done without antialiasing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @see #KEY_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public static final Object VALUE_ANTIALIAS_OFF =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        SunHints.VALUE_ANTIALIAS_OFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Antialiasing hint value -- rendering is done with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * antialiasing mode chosen by the implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @see #KEY_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public static final Object VALUE_ANTIALIAS_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         SunHints.VALUE_ANTIALIAS_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Rendering hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * The {@code RENDERING} hint is a general hint that provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * a high level recommendation as to whether to bias algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * choices more for speed or quality when evaluating tradeoffs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * This hint could be consulted for any rendering or image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * manipulation operation, but decisions will usually honor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * other, more specific hints in preference to this hint.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <li>{@link #VALUE_RENDER_SPEED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <li>{@link #VALUE_RENDER_QUALITY}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * <li>{@link #VALUE_RENDER_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public static final Key KEY_RENDERING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
         SunHints.KEY_RENDERING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Rendering hint value -- rendering algorithms are chosen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * with a preference for output speed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @see #KEY_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public static final Object VALUE_RENDER_SPEED =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
         SunHints.VALUE_RENDER_SPEED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Rendering hint value -- rendering algorithms are chosen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * with a preference for output quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @see #KEY_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public static final Object VALUE_RENDER_QUALITY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
         SunHints.VALUE_RENDER_QUALITY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Rendering hint value -- rendering algorithms are chosen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * by the implementation for a good tradeoff of performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * vs. quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @see #KEY_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public static final Object VALUE_RENDER_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
         SunHints.VALUE_RENDER_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Dithering hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * The {@code DITHERING} hint controls how closely to approximate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * a color when storing into a destination with limited color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * Some rendering destinations may support a limited number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * color choices which may not be able to accurately represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * the full spectrum of colors that can result during rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * For such a destination the {@code DITHERING} hint controls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * whether rendering is done with a flat solid fill of a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * pixel value which is the closest supported color to what was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * requested, or whether shapes will be filled with a pattern of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * colors which combine to better approximate that color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * <li>{@link #VALUE_DITHER_DISABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * <li>{@link #VALUE_DITHER_ENABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * <li>{@link #VALUE_DITHER_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public static final Key KEY_DITHERING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
         SunHints.KEY_DITHERING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * Dithering hint value -- do not dither when rendering geometry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @see #KEY_DITHERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public static final Object VALUE_DITHER_DISABLE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
         SunHints.VALUE_DITHER_DISABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * Dithering hint value -- dither when rendering geometry, if needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @see #KEY_DITHERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    public static final Object VALUE_DITHER_ENABLE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
         SunHints.VALUE_DITHER_ENABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Dithering hint value -- use a default for dithering chosen by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * the implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @see #KEY_DITHERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public static final Object VALUE_DITHER_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
         SunHints.VALUE_DITHER_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Text antialiasing hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * The {@code TEXT_ANTIALIASING} hint can control the use of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * antialiasing algorithms for text independently of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * choice used for shape rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * Often an application may want to use antialiasing for text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * only and not for other shapes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * Additionally, the algorithms for reducing the aliasing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * artifacts for text are often more sophisticated than those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * that have been developed for general rendering so this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * hint key provides additional values which can control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * the choices of some of those text-specific algorithms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * If left in the {@code DEFAULT} state, this hint will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * generally defer to the value of the regular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * {@link #KEY_ANTIALIASING} hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * <li>{@link #VALUE_TEXT_ANTIALIAS_ON}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * <li>{@link #VALUE_TEXT_ANTIALIAS_OFF}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * <li>{@link #VALUE_TEXT_ANTIALIAS_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <li>{@link #VALUE_TEXT_ANTIALIAS_GASP}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_HBGR}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_VRGB}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_VBGR}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public static final Key KEY_TEXT_ANTIALIASING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
         SunHints.KEY_TEXT_ANTIALIASING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Text antialiasing hint value -- text rendering is done with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * some form of antialiasing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public static final Object VALUE_TEXT_ANTIALIAS_ON =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
         SunHints.VALUE_TEXT_ANTIALIAS_ON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Text antialiasing hint value -- text rendering is done without
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * any form of antialiasing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public static final Object VALUE_TEXT_ANTIALIAS_OFF =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
         SunHints.VALUE_TEXT_ANTIALIAS_OFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * Text antialiasing hint value -- text rendering is done according
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * to the {@link #KEY_ANTIALIASING} hint or a default chosen by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
         SunHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Text antialiasing hint value -- text rendering is requested to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * use information in the font resource which specifies for each point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * size whether to apply {@link #VALUE_TEXT_ANTIALIAS_ON} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * {@link #VALUE_TEXT_ANTIALIAS_OFF}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * TrueType fonts typically provide this information in the 'gasp' table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * In the absence of this information, the behaviour for a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * font and size is determined by implementation defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * <i>Note:</i>A font designer will typically carefully hint a font for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * the most common user interface point sizes. Consequently the 'gasp'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * table will likely specify to use only hinting at those sizes and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * "smoothing". So in many cases the resulting text display is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * equivalent to {@code VALUE_TEXT_ANTIALIAS_OFF}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * This may be unexpected but is correct.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Logical fonts which are composed of multiple physical fonts will for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * consistency will use the setting most appropriate for the overall
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * composite font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public static final Object VALUE_TEXT_ANTIALIAS_GASP =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
         SunHints.VALUE_TEXT_ANTIALIAS_GASP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Text antialiasing hint value -- request that text be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * optimised for an LCD display with subpixels in order from display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * left to right of R,G,B such that the horizontal subpixel resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * is three times that of the full pixel horizontal resolution (HRGB).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * This is the most common configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * Selecting this hint for displays with one of the other LCD subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * configurations will likely result in unfocused text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <i>Notes:</i><br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * An implementation when choosing whether to apply any of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * LCD text hint values may take into account factors including requiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * color depth of the destination to be at least 15 bits per pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * (ie 5 bits per color component),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * characteristics of a font such as whether embedded bitmaps may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * produce better results, or when displaying to a non-local networked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * display device enabling it only if suitable protocols are available,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * or ignoring the hint if performing very high resolution rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * or the target device is not appropriate: eg when printing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * These hints can equally be applied when rendering to software images,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * but these images may not then be suitable for general export, as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * text will have been rendered appropriately for a specific subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * organisation. Also lossy images are not a good choice, nor image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * formats such as GIF which have limited colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * So unless the image is destined solely for rendering on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * display device with the same configuration, some other text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * anti-aliasing hint such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * {@link #VALUE_TEXT_ANTIALIAS_ON}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * may be a better choice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * <p>Selecting a value which does not match the LCD display in use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * will likely lead to a degradation in text quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * On display devices (ie CRTs) which do not have the same characteristics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * as LCD displays, the overall effect may appear similar to standard text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * anti-aliasing, but the quality may be degraded by color distortion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * Analog connected LCD displays may also show little advantage over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * standard text-antialiasing and be similar to CRTs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * In other words for the best results use an LCD display with a digital
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * display connector and specify the appropriate sub-pixel configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public static final Object VALUE_TEXT_ANTIALIAS_LCD_HRGB =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
         SunHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * Text antialiasing hint value -- request that text be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * optimised for an LCD display with subpixels in order from display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * left to right of B,G,R such that the horizontal subpixel resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * is three times that of the full pixel horizontal resolution (HBGR).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * This is a much less common configuration than HRGB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Selecting this hint for displays with one of the other LCD subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * configurations will likely result in unfocused text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * for more information on when this hint is applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    public static final Object VALUE_TEXT_ANTIALIAS_LCD_HBGR =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
         SunHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * Text antialiasing hint value -- request that text be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * optimised for an LCD display with subpixel organisation from display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * top to bottom of R,G,B such that the vertical subpixel resolution is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * three times that of the full pixel vertical resolution (VRGB).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * Vertical orientation is very uncommon and probably mainly useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * for a physically rotated display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * Selecting this hint for displays with one of the other LCD subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * configurations will likely result in unfocused text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * for more information on when this hint is applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public static final Object VALUE_TEXT_ANTIALIAS_LCD_VRGB =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
         SunHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Text antialiasing hint value -- request that text be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * optimised for an LCD display with subpixel organisation from display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * top to bottom of B,G,R such that the vertical subpixel resolution is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * three times that of the full pixel vertical resolution (VBGR).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Vertical orientation is very uncommon and probably mainly useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * for a physically rotated display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * Selecting this hint for displays with one of the other LCD subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * configurations will likely result in unfocused text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * for more information on when this hint is applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    public static final Object VALUE_TEXT_ANTIALIAS_LCD_VBGR =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
         SunHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * LCD text contrast rendering hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * The value is an <code>Integer</code> object which is used as a text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * contrast adjustment when used in conjunction with an LCD text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * anti-aliasing hint such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * <li>Values should be a positive integer in the range 100 to 250.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * <li>A lower value (eg 100) corresponds to higher contrast text when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * displaying dark text on a light background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <li>A higher value (eg 200) corresponds to lower contrast text when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * displaying dark text on a light background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * <li>A typical useful value is in the narrow range 140-180.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * <li>If no value is specified, a system or implementation default value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * will be applied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * The default value can be expected to be adequate for most purposes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * so clients should rarely need to specify a value for this hint unless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * they have concrete information as to an appropriate value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * A higher value does not mean a higher contrast, in fact the opposite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * The correction is applied in a similar manner to a gamma adjustment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * for non-linear perceptual luminance response of display systems, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * does not indicate a full correction for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @see #KEY_TEXT_ANTIALIASING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    public static final Key KEY_TEXT_LCD_CONTRAST =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * Font fractional metrics hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * The {@code FRACTIONALMETRICS} hint controls whether the positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * of individual character glyphs takes into account the sub-pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * accuracy of the scaled character advances of the font or whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * such advance vectors are rounded to an integer number of whole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * device pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * This hint only recommends how much accuracy should be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * position the glyphs and does not specify or recommend whether or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * not the actual rasterization or pixel bounds of the glyph should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * be modified to match.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * Rendering text to a low resolution device like a screen will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * necessarily involve a number of rounding operations as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * high quality and very precise definition of the shape and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * metrics of the character glyphs must be matched to discrete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * device pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * Ideally the positioning of glyphs during text layout would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * calculated by scaling the design metrics in the font according
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * to the point size, but then the scaled advance width will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * necessarily be an integer number of pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * If the glyphs are positioned with sub-pixel accuracy according
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * to these scaled design metrics then the rasterization would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * ideally need to be adjusted for each possible sub-pixel origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Unfortunately, scaling each glyph customized to its exact
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * subpixel origin during text layout would be prohibitively
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * expensive so a simplified system based on integer device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * positions is typically used to lay out the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * The rasterization of the glyph and the scaled advance width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * are both adjusted together to yield text that looks good at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * device resolution and has consistent integer pixel distances
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * between glyphs that help the glyphs look uniformly and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * consistently spaced and readable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * This process of rounding advance widths for rasterized glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * to integer distances means that the character density and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * overall length of a string of text will be different from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * theoretical design measurements due to the accumulation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * a series of small differences in the adjusted widths of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * each glyph.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * The specific differences will be different for each glyph,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * some being wider and some being narrower than their theoretical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * design measurements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * Thus the overall difference in character density and length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * will vary by a number of factors including the font, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * specific device resolution being targeted, and the glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * chosen to represent the string being rendered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * As a result, rendering the same string at multiple device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * resolutions can yield widely varying metrics for whole strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * When {@code FRACTIONALMETRICS} are enabled, the true font design
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * metrics are scaled by the point size and used for layout with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * sub-pixel accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * The average density of glyphs and total length of a long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * string of characters will therefore more closely match the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * theoretical design of the font, but readability may be affected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * since individual pairs of characters may not always appear to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * be consistent distances apart depending on how the sub-pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * accumulation of the glyph origins meshes with the device pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * grid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Enabling this hint may be desirable when text layout is being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * performed that must be consistent across a wide variety of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * output resolutions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * Specifically, this hint may be desirable in situations where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * the layout of text is being previewed on a low resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * device like a screen for output that will eventually be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * rendered on a high resolution printer or typesetting device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * When disabled, the scaled design metrics are rounded or adjusted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * to integer distances for layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * The distances between any specific pair of glyphs will be more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * uniform on the device, but the density and total length of long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * strings may no longer match the theoretical intentions of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * font designer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * Disabling this hint will typically produce more readable results
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * on low resolution devices like computer monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * The allowable values for this key are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * <li>{@link #VALUE_FRACTIONALMETRICS_OFF}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * <li>{@link #VALUE_FRACTIONALMETRICS_ON}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * <li>{@link #VALUE_FRACTIONALMETRICS_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    public static final Key KEY_FRACTIONALMETRICS =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
         SunHints.KEY_FRACTIONALMETRICS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * Font fractional metrics hint value -- character glyphs are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * positioned with advance widths rounded to pixel boundaries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @see #KEY_FRACTIONALMETRICS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public static final Object VALUE_FRACTIONALMETRICS_OFF =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
         SunHints.VALUE_FRACTIONALMETRICS_OFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * Font fractional metrics hint value -- character glyphs are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * positioned with sub-pixel accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @see #KEY_FRACTIONALMETRICS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public static final Object VALUE_FRACTIONALMETRICS_ON =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
         SunHints.VALUE_FRACTIONALMETRICS_ON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * Font fractional metrics hint value -- character glyphs are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * positioned with accuracy chosen by the implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see #KEY_FRACTIONALMETRICS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    public static final Object VALUE_FRACTIONALMETRICS_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
         SunHints.VALUE_FRACTIONALMETRICS_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * Interpolation hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * The {@code INTERPOLATION} hint controls how image pixels are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * filtered or resampled during an image rendering operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * Implicitly images are defined to provide color samples at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * integer coordinate locations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * When images are rendered upright with no scaling onto a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * destination, the choice of which image pixels map to which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * device pixels is obvious and the samples at the integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * coordinate locations in the image are transfered to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * pixels at the corresponding integer locations on the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * pixel grid one for one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * When images are rendered in a scaled, rotated, or otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * transformed coordinate system, then the mapping of device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * pixel coordinates back to the image can raise the question
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * of what color sample to use for the continuous coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * that lie between the integer locations of the provided image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * samples.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Interpolation algorithms define functions which provide a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * color sample for any continuous coordinate in an image based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * on the color samples at the surrounding integer coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * <li>{@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * <li>{@link #VALUE_INTERPOLATION_BILINEAR}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * <li>{@link #VALUE_INTERPOLATION_BICUBIC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    public static final Key KEY_INTERPOLATION =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
         SunHints.KEY_INTERPOLATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * Interpolation hint value -- the color sample of the nearest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * neighboring integer coordinate sample in the image is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * Conceptually the image is viewed as a grid of unit-sized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * square regions of color centered around the center of each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * image pixel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * As the image is scaled up, it will look correspondingly blocky.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * As the image is scaled down, the colors for source pixels will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * be either used unmodified, or skipped entirely in the output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * @see #KEY_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
         SunHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * Interpolation hint value -- the color samples of the 4 nearest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * neighboring integer coordinate samples in the image are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * interpolated linearly to produce a color sample.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * Conceptually the image is viewed as a set of infinitely small
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * point color samples which have value only at the centers of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * integer coordinate pixels and the space between those pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * centers is filled with linear ramps of colors that connect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * adjacent discrete samples in a straight line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * As the image is scaled up, there are no blocky edges between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * the colors in the image as there are with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * {@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR NEAREST_NEIGHBOR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * but the blending may show some subtle discontinuities along the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * horizontal and vertical edges that line up with the samples
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * caused by a sudden change in the slope of the interpolation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * from one side of a sample to the other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * As the image is scaled down, more image pixels have their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * color samples represented in the resulting output since each
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 15994
diff changeset
   732
     * output pixel receives color information from up to 4 image
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @see #KEY_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    public static final Object VALUE_INTERPOLATION_BILINEAR =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
         SunHints.VALUE_INTERPOLATION_BILINEAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * Interpolation hint value -- the color samples of 9 nearby
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * integer coordinate samples in the image are interpolated using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * a cubic function in both {@code X} and {@code Y} to produce
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * a color sample.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * Conceptually the view of the image is very similar to the view
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * used in the {@link #VALUE_INTERPOLATION_BILINEAR BILINEAR}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * algorithm except that the ramps of colors that connect between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * the samples are curved and have better continuity of slope
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * as they cross over between sample boundaries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * As the image is scaled up, there are no blocky edges and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * interpolation should appear smoother and with better depictions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * of any edges in the original image than with {@code BILINEAR}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * As the image is scaled down, even more of the original color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * samples from the original image will have their color information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * carried through and represented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * @see #KEY_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    public static final Object VALUE_INTERPOLATION_BICUBIC =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
         SunHints.VALUE_INTERPOLATION_BICUBIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * Alpha interpolation hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * The {@code ALPHA_INTERPOLATION} hint is a general hint that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * provides a high level recommendation as to whether to bias
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * alpha blending algorithm choices more for speed or quality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * when evaluating tradeoffs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * This hint could control the choice of alpha blending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * calculations that sacrifice some precision to use fast
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * lookup tables or lower precision SIMD instructions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * This hint could also control whether or not the color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * and alpha values are converted into a linear color space
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * during the calculations for a more linear visual effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * at the expense of additional per-pixel calculations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * <li>{@link #VALUE_ALPHA_INTERPOLATION_SPEED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * <li>{@link #VALUE_ALPHA_INTERPOLATION_QUALITY}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * <li>{@link #VALUE_ALPHA_INTERPOLATION_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    public static final Key KEY_ALPHA_INTERPOLATION =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
         SunHints.KEY_ALPHA_INTERPOLATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * Alpha interpolation hint value -- alpha blending algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * are chosen with a preference for calculation speed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * @see #KEY_ALPHA_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    public static final Object VALUE_ALPHA_INTERPOLATION_SPEED =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
         SunHints.VALUE_ALPHA_INTERPOLATION_SPEED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * Alpha interpolation hint value -- alpha blending algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * are chosen with a preference for precision and visual quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * @see #KEY_ALPHA_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
         SunHints.VALUE_ALPHA_INTERPOLATION_QUALITY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * Alpha interpolation hint value -- alpha blending algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * are chosen by the implementation for a good tradeoff of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * performance vs. quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @see #KEY_ALPHA_INTERPOLATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
         SunHints.VALUE_ALPHA_INTERPOLATION_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * Color rendering hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * The {@code COLOR_RENDERING} hint controls the accuracy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * approximation and conversion when storing colors into a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * destination image or surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * When a rendering or image manipulation operation produces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * a color value that must be stored into a destination, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * must first convert that color into a form suitable for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * storing into the destination image or surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * Minimally, the color components must be converted to bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * representations and ordered in the correct order or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * index into a color lookup table must be chosen before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * the data can be stored into the destination memory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * Without this minimal conversion, the data in the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * would likely represent random, incorrect or possibly even
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * unsupported values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * Algorithms to quickly convert the results of rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * operations into the color format of most common destinations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * are well known and fairly optimal to execute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * Simply performing the most basic color format conversion to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * store colors into a destination can potentially ignore a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * difference in the calibration of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * {@link java.awt.color.ColorSpace}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * of the source and destination or other factors such as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * linearity of the gamma correction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * Unless the source and destination {@code ColorSpace} are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * identical, to correctly perform a rendering operation with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * the most care taken for the accuracy of the colors being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * represented, the source colors should be converted to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * device independent {@code ColorSpace} and the results then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * converted back to the destination {@code ColorSpace}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * Furthermore, if calculations such as the blending of multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * source colors are to be performed during the rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * operation, greater visual clarity can be achieved if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * intermediate device independent {@code ColorSpace} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * chosen to have a linear relationship between the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * being calculated and the perception of the human eye to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * the response curves of the output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * <li>{@link #VALUE_COLOR_RENDER_SPEED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * <li>{@link #VALUE_COLOR_RENDER_QUALITY}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * <li>{@link #VALUE_COLOR_RENDER_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    public static final Key KEY_COLOR_RENDERING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
         SunHints.KEY_COLOR_RENDERING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * Color rendering hint value -- perform the fastest color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * conversion to the format of the output device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * @see #KEY_COLOR_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    public static final Object VALUE_COLOR_RENDER_SPEED =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
         SunHints.VALUE_COLOR_RENDER_SPEED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * Color rendering hint value -- perform the color conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * calculations with the highest accuracy and visual quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * @see #KEY_COLOR_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    public static final Object VALUE_COLOR_RENDER_QUALITY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
         SunHints.VALUE_COLOR_RENDER_QUALITY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * Color rendering hint value -- perform color conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * calculations as chosen by the implementation to represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * the best available tradeoff between performance and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * @see #KEY_COLOR_RENDERING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    public static final Object VALUE_COLOR_RENDER_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
         SunHints.VALUE_COLOR_RENDER_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * Stroke normalization control hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * The {@code STROKE_CONTROL} hint controls whether a rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * implementation should or is allowed to modify the geometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * of rendered shapes for various purposes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * Some implementations may be able to use an optimized platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * rendering library which may be faster than traditional software
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * rendering algorithms on a given platform, but which may also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * not support floating point coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * Some implementations may also have sophisticated algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * which perturb the coordinates of a path so that wide lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * appear more uniform in width and spacing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * If an implementation performs any type of modification or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * "normalization" of a path, it should never move the coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     * by more than half a pixel in any direction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     * The allowable values for this hint are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * <li>{@link #VALUE_STROKE_NORMALIZE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * <li>{@link #VALUE_STROKE_PURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * <li>{@link #VALUE_STROKE_DEFAULT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    public static final Key KEY_STROKE_CONTROL =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        SunHints.KEY_STROKE_CONTROL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * Stroke normalization control hint value -- geometry may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * modified or left pure depending on the tradeoffs in a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * Typically this setting allows an implementation to use a fast
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * integer coordinate based platform rendering library, but does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * not specifically request normalization for uniformity or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * aesthetics.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * @see #KEY_STROKE_CONTROL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    public static final Object VALUE_STROKE_DEFAULT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        SunHints.VALUE_STROKE_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * Stroke normalization control hint value -- geometry should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * be normalized to improve uniformity or spacing of lines and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * overall aesthetics.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * Note that different normalization algorithms may be more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * successful than others for given input paths.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * @see #KEY_STROKE_CONTROL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    public static final Object VALUE_STROKE_NORMALIZE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        SunHints.VALUE_STROKE_NORMALIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * Stroke normalization control hint value -- geometry should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * be left unmodified and rendered with sub-pixel accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * @see #KEY_STROKE_CONTROL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    public static final Object VALUE_STROKE_PURE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        SunHints.VALUE_STROKE_PURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * Constructs a new object with keys and values initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * from the specified Map object which may be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * @param init a map of key/value pairs to initialize the hints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     *          or null if the object should be empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    public RenderingHints(Map<Key,?> init) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        if (init != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            hintmap.putAll(init);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     * Constructs a new object with the specified key/value pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * @param key the key of the particular hint property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * @param value the value of the hint property specified with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * <code>key</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    public RenderingHints(Key key, Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        hintmap.put(key, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * Returns the number of key-value mappings in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * @return the number of key-value mappings in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        return hintmap.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * Returns <code>true</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * <code>RenderingHints</code> contains no key-value mappings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * @return <code>true</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * <code>RenderingHints</code> contains no key-value mappings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    public boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        return hintmap.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * Returns <code>true</code> if this <code>RenderingHints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     *  contains a mapping for the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * @param key key whose presence in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * <code>RenderingHints</code> is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @return <code>true</code> if this <code>RenderingHints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *          contains a mapping for the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * @exception <code>ClassCastException</code> if the key can not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *            be cast to <code>RenderingHints.Key</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    public boolean containsKey(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        return hintmap.containsKey((Key) key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * Returns true if this RenderingHints maps one or more keys to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * specified value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * More formally, returns <code>true</code> if and only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * if this <code>RenderingHints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * contains at least one mapping to a value <code>v</code> such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * (value==null ? v==null : value.equals(v))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * </pre>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * This operation will probably require time linear in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * <code>RenderingHints</code> size for most implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * of <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * @param value value whose presence in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     *          <code>RenderingHints</code> is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * @return <code>true</code> if this <code>RenderingHints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     *           maps one or more keys to the specified value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    public boolean containsValue(Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        return hintmap.containsValue(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * Returns the value to which the specified key is mapped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @param   key   a rendering hint key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * @return  the value to which the key is mapped in this object or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     *          <code>null</code> if the key is not mapped to any value in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     *          this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * @exception <code>ClassCastException</code> if the key can not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *            be cast to <code>RenderingHints.Key</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     * @see     #put(Object, Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    public Object get(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        return hintmap.get((Key) key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * Maps the specified <code>key</code> to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * <code>value</code> in this <code>RenderingHints</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * Neither the key nor the value can be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * The value can be retrieved by calling the <code>get</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * with a key that is equal to the original key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * @param      key     the rendering hint key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * @param      value   the rendering hint value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * @return     the previous value of the specified key in this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     *             or <code>null</code> if it did not have one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * @exception <code>NullPointerException</code> if the key is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     *            <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * @exception <code>ClassCastException</code> if the key can not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     *            be cast to <code>RenderingHints.Key</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * @exception <code>IllegalArgumentException</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     *            {@link Key#isCompatibleValue(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     *                   Key.isCompatibleValue()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     *            method of the specified key returns false for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     *            specified value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * @see     #get(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    public Object put(Object key, Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        if (!((Key) key).isCompatibleValue(value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            throw new IllegalArgumentException(value+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                                               " incompatible with "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                                               key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        return hintmap.put((Key) key, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     * Adds all of the keys and corresponding values from the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * <code>RenderingHints</code> object to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * <code>RenderingHints</code> object. Keys that are present in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * this <code>RenderingHints</code> object, but not in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     * <code>RenderingHints</code> object are not affected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * @param hints the set of key/value pairs to be added to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     * <code>RenderingHints</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    public void add(RenderingHints hints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        hintmap.putAll(hints.hintmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * Clears this <code>RenderingHints</code> object of all key/value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * pairs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        hintmap.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * Removes the key and its corresponding value from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     * <code>RenderingHints</code> object. This method does nothing if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * key is not in this <code>RenderingHints</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
     * @param   key   the rendering hints key that needs to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * @exception <code>ClassCastException</code> if the key can not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     *            be cast to <code>RenderingHints.Key</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * @return  the value to which the key had previously been mapped in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     *          <code>RenderingHints</code> object, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     *          if the key did not have a mapping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    public Object remove(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        return hintmap.remove((Key) key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
     * Copies all of the mappings from the specified <code>Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * to this <code>RenderingHints</code>.  These mappings replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * any mappings that this <code>RenderingHints</code> had for any
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * of the keys currently in the specified <code>Map</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * @param m the specified <code>Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * @exception <code>ClassCastException</code> class of a key or value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     *          in the specified <code>Map</code> prevents it from being
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *          stored in this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @exception <code>IllegalArgumentException</code> some aspect
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     *          of a key or value in the specified <code>Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     *           prevents it from being stored in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     *            this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    public void putAll(Map<?,?> m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
        // ## javac bug?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        //if (m instanceof RenderingHints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        if (RenderingHints.class.isInstance(m)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
            //hintmap.putAll(((RenderingHints) m).hintmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
            for (Map.Entry<?,?> entry : m.entrySet())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                hintmap.put(entry.getKey(), entry.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            // Funnel each key/value pair through our protected put method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            for (Map.Entry<?,?> entry : m.entrySet())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                put(entry.getKey(), entry.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * Returns a <code>Set</code> view of the Keys contained in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * <code>RenderingHints</code>.  The Set is backed by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * <code>RenderingHints</code>, so changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * <code>RenderingHints</code> are reflected in the <code>Set</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * and vice-versa.  If the <code>RenderingHints</code> is modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
     * while an iteration over the <code>Set</code> is in progress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * the results of the iteration are undefined.  The <code>Set</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * supports element removal, which removes the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * mapping from the <code>RenderingHints</code>, via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * <code>Iterator.remove</code>, <code>Set.remove</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * <code>removeAll</code> <code>retainAll</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     * <code>clear</code> operations.  It does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * the <code>add</code> or <code>addAll</code> operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * @return a <code>Set</code> view of the keys contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * in this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    public Set<Object> keySet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        return hintmap.keySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     * Returns a <code>Collection</code> view of the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * contained in this <code>RenderinHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * The <code>Collection</code> is backed by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     * <code>RenderingHints</code>, so changes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     * the <code>RenderingHints</code> are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
     * the <code>Collection</code>, and vice-versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * If the <code>RenderingHints</code> is modified while
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * an iteration over the <code>Collection</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * in progress, the results of the iteration are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * The <code>Collection</code> supports element removal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * which removes the corresponding mapping from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     * <code>RenderingHints</code>, via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * <code>Iterator.remove</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * <code>Collection.remove</code>, <code>removeAll</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * <code>retainAll</code> and <code>clear</code> operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * It does not support the <code>add</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     * <code>addAll</code> operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     * @return a <code>Collection</code> view of the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
     *          contained in this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    public Collection<Object> values() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        return hintmap.values();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     * Returns a <code>Set</code> view of the mappings contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * in this <code>RenderingHints</code>.  Each element in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * returned <code>Set</code> is a <code>Map.Entry</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * The <code>Set</code> is backed by the <code>RenderingHints</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     * so changes to the <code>RenderingHints</code> are reflected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
     * in the <code>Set</code>, and vice-versa.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     * <code>RenderingHints</code> is modified while
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
     * while an iteration over the <code>Set</code> is in progress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
     * the results of the iteration are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
     * The entrySet returned from a <code>RenderingHints</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * is not modifiable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     * @return a <code>Set</code> view of the mappings contained in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     * this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    public Set<Map.Entry<Object,Object>> entrySet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        return Collections.unmodifiableMap(hintmap).entrySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
     * Compares the specified <code>Object</code> with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     * <code>RenderingHints</code> for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     * Returns <code>true</code> if the specified object is also a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * <code>Map</code> and the two <code>Map</code> objects represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * the same mappings.  More formally, two <code>Map</code> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * <code>t1</code> and <code>t2</code> represent the same mappings
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     * if <code>t1.keySet().equals(t2.keySet())</code> and for every
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * key <code>k</code> in <code>t1.keySet()</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
     * (t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
     * </pre>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     * This ensures that the <code>equals</code> method works properly across
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
     * different implementations of the <code>Map</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     * @param o <code>Object</code> to be compared for equality with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
     * this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     * @return <code>true</code> if the specified <code>Object</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     * is equal to this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
    public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        if (o instanceof RenderingHints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            return hintmap.equals(((RenderingHints) o).hintmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        } else if (o instanceof Map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            return hintmap.equals(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * Returns the hash code value for this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     * The hash code of a <code>RenderingHints</code> is defined to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     * the sum of the hashCodes of each <code>Entry</code> in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
     * <code>RenderingHints</code> object's entrySet view.  This ensures that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     * <code>t1.equals(t2)</code> implies that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     * <code>t1.hashCode()==t2.hashCode()</code> for any two <code>Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * objects <code>t1</code> and <code>t2</code>, as required by the general
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
     * contract of <code>Object.hashCode</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
     * @return the hash code value for this <code>RenderingHints</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * @see java.util.Map.Entry#hashCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * @see Object#hashCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
     * @see Object#equals(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * @see #equals(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        return hintmap.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * Creates a clone of this <code>RenderingHints</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * that has the same contents as this <code>RenderingHints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     * @return a clone of this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     */
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 10419
diff changeset
  1270
    @SuppressWarnings("unchecked")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        RenderingHints rh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            rh = (RenderingHints) super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            if (hintmap != null) {
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 10419
diff changeset
  1276
                rh.hintmap = (HashMap<Object,Object>) hintmap.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            // this shouldn't happen, since we are Cloneable
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
  1280
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        return rh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     * Returns a rather long string representation of the hashmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * which contains the mappings of keys to values for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     * <code>RenderingHints</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * @return  a string representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        if (hintmap == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
            return getClass().getName() + "@" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                Integer.toHexString(hashCode()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
                " (0 hints)";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
        return hintmap.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
}