0N/A/*
2362N/A * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.awt;
0N/A
0N/Aimport java.awt.RenderingHints;
0N/A
0N/A/**
0N/A * This class contains rendering hints that can be used by the
0N/A * {@link java.awt.Graphics2D} class, and classes that implement
0N/A * {@link java.awt.image.BufferedImageOp} and
0N/A * {@link java.awt.image.Raster}.
0N/A */
0N/Apublic class SunHints {
0N/A /**
0N/A * Defines the type of all keys used to control various
0N/A * aspects of the rendering and imaging pipelines. Instances
0N/A * of this class are immutable and unique which means that
0N/A * tests for matches can be made using the == operator instead
0N/A * of the more expensive equals() method.
0N/A */
0N/A public static class Key extends RenderingHints.Key {
0N/A String description;
0N/A
0N/A /**
0N/A * Construct a key using the indicated private key. Each
0N/A * subclass of Key maintains its own unique domain of integer
0N/A * keys. No two objects with the same integer key and of the
0N/A * same specific subclass can be constructed. An exception
0N/A * will be thrown if an attempt is made to construct another
0N/A * object of a given class with the same integer key as a
0N/A * pre-existing instance of that subclass of Key.
0N/A */
0N/A public Key(int privatekey, String description) {
0N/A super(privatekey);
0N/A this.description = description;
0N/A }
0N/A
0N/A /**
0N/A * Returns the numeric index associated with this Key. This
0N/A * is useful for use in switch statements and quick lookups
0N/A * of the setting of a particular key.
0N/A */
0N/A public final int getIndex() {
0N/A return intKey();
0N/A }
0N/A
0N/A /**
0N/A * Returns a string representation of the Key.
0N/A */
0N/A public final String toString() {
0N/A return description;
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the specified object is a valid value
0N/A * for this Key.
0N/A */
0N/A public boolean isCompatibleValue(Object val) {
0N/A if (val instanceof Value) {
0N/A return ((Value)val).isCompatibleKey(this);
0N/A }
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Defines the type of all "enumerative" values used to control
0N/A * various aspects of the rendering and imaging pipelines. Instances
0N/A * of this class are immutable and unique which means that
0N/A * tests for matches can be made using the == operator instead
0N/A * of the more expensive equals() method.
0N/A */
0N/A public static class Value {
0N/A private SunHints.Key myKey;
0N/A private int index;
0N/A private String description;
0N/A
0N/A private static Value[][] ValueObjects =
0N/A new Value[NUM_KEYS][VALS_PER_KEY];
0N/A
0N/A private synchronized static void register(SunHints.Key key,
0N/A Value value) {
0N/A int kindex = key.getIndex();
0N/A int vindex = value.getIndex();
0N/A if (ValueObjects[kindex][vindex] != null) {
0N/A throw new InternalError("duplicate index: "+vindex);
0N/A }
0N/A ValueObjects[kindex][vindex] = value;
0N/A }
0N/A
0N/A public static Value get(int keyindex, int valueindex) {
0N/A return ValueObjects[keyindex][valueindex];
0N/A }
0N/A
0N/A /**
0N/A * Construct a value using the indicated private index. Each
0N/A * subclass of Value maintains its own unique domain of integer
0N/A * indices. Enforcing the uniqueness of the integer indices
0N/A * is left to the subclass.
0N/A */
0N/A public Value(SunHints.Key key, int index, String description) {
0N/A this.myKey = key;
0N/A this.index = index;
0N/A this.description = description;
0N/A
0N/A register(key, this);
0N/A }
0N/A
0N/A /**
0N/A * Returns the numeric index associated with this Key. This
0N/A * is useful for use in switch statements and quick lookups
0N/A * of the setting of a particular key.
0N/A */
0N/A public final int getIndex() {
0N/A return index;
0N/A }
0N/A
0N/A /**
0N/A * Returns a string representation of this Value.
0N/A */
0N/A public final String toString() {
0N/A return description;
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the specified object is a valid Key
0N/A * for this Value.
0N/A */
0N/A public final boolean isCompatibleKey(Key k) {
0N/A return myKey == k;
0N/A }
0N/A
0N/A /**
0N/A * The hash code for all SunHints.Value objects will be the same
0N/A * as the system identity code of the object as defined by the
0N/A * System.identityHashCode() method.
0N/A */
0N/A public final int hashCode() {
0N/A return System.identityHashCode(this);
0N/A }
0N/A
0N/A /**
0N/A * The equals method for all SunHints.Value objects will return
0N/A * the same result as the equality operator '=='.
0N/A */
0N/A public final boolean equals(Object o) {
0N/A return this == o;
0N/A }
0N/A }
0N/A
0N/A private static final int NUM_KEYS = 9;
0N/A private static final int VALS_PER_KEY = 8;
0N/A
0N/A /**
0N/A * Rendering hint key and values
0N/A */
0N/A public static final int INTKEY_RENDERING = 0;
0N/A public static final int INTVAL_RENDER_DEFAULT = 0;
0N/A public static final int INTVAL_RENDER_SPEED = 1;
0N/A public static final int INTVAL_RENDER_QUALITY = 2;
0N/A
0N/A /**
0N/A * Antialiasing hint key and values
0N/A */
0N/A public static final int INTKEY_ANTIALIASING = 1;
0N/A public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
0N/A public static final int INTVAL_ANTIALIAS_OFF = 1;
0N/A public static final int INTVAL_ANTIALIAS_ON = 2;
0N/A
0N/A /**
0N/A * Text antialiasing hint key and values
0N/A */
0N/A public static final int INTKEY_TEXT_ANTIALIASING = 2;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
0N/A public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
0N/A
0N/A /**
0N/A * Font fractional metrics hint key and values
0N/A */
0N/A public static final int INTKEY_FRACTIONALMETRICS = 3;
0N/A public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
0N/A public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
0N/A public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
0N/A
0N/A /**
0N/A * Dithering hint key and values
0N/A */
0N/A public static final int INTKEY_DITHERING = 4;
0N/A public static final int INTVAL_DITHER_DEFAULT = 0;
0N/A public static final int INTVAL_DITHER_DISABLE = 1;
0N/A public static final int INTVAL_DITHER_ENABLE = 2;
0N/A
0N/A /**
0N/A * Interpolation hint key and values
0N/A */
0N/A public static final int INTKEY_INTERPOLATION = 5;
0N/A public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
0N/A public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
0N/A public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
0N/A
0N/A /**
0N/A * Alpha interpolation hint key and values
0N/A */
0N/A public static final int INTKEY_ALPHA_INTERPOLATION = 6;
0N/A public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
0N/A public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
0N/A public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
0N/A
0N/A /**
0N/A * Color rendering hint key and values
0N/A */
0N/A public static final int INTKEY_COLOR_RENDERING = 7;
0N/A public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
0N/A public static final int INTVAL_COLOR_RENDER_SPEED = 1;
0N/A public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
0N/A
0N/A /**
0N/A * Stroke normalization control hint key and values
0N/A */
0N/A public static final int INTKEY_STROKE_CONTROL = 8;
0N/A public static final int INTVAL_STROKE_DEFAULT = 0;
0N/A public static final int INTVAL_STROKE_NORMALIZE = 1;
0N/A public static final int INTVAL_STROKE_PURE = 2;
0N/A
0N/A /**
0N/A * LCD text contrast control hint key.
0N/A * Value is "100" to make discontiguous with the others which
0N/A * are all enumerative and are of a different class.
0N/A */
0N/A public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
0N/A
0N/A /**
0N/A * Rendering hint key and value objects
0N/A */
0N/A public static final Key KEY_RENDERING =
0N/A new SunHints.Key(SunHints.INTKEY_RENDERING,
0N/A "Global rendering quality key");
0N/A public static final Object VALUE_RENDER_SPEED =
0N/A new SunHints.Value(KEY_RENDERING,
0N/A SunHints.INTVAL_RENDER_SPEED,
0N/A "Fastest rendering methods");
0N/A public static final Object VALUE_RENDER_QUALITY =
0N/A new SunHints.Value(KEY_RENDERING,
0N/A SunHints.INTVAL_RENDER_QUALITY,
0N/A "Highest quality rendering methods");
0N/A public static final Object VALUE_RENDER_DEFAULT =
0N/A new SunHints.Value(KEY_RENDERING,
0N/A SunHints.INTVAL_RENDER_DEFAULT,
0N/A "Default rendering methods");
0N/A
0N/A /**
0N/A * Antialiasing hint key and value objects
0N/A */
0N/A public static final Key KEY_ANTIALIASING =
0N/A new SunHints.Key(SunHints.INTKEY_ANTIALIASING,
0N/A "Global antialiasing enable key");
0N/A public static final Object VALUE_ANTIALIAS_ON =
0N/A new SunHints.Value(KEY_ANTIALIASING,
0N/A SunHints.INTVAL_ANTIALIAS_ON,
0N/A "Antialiased rendering mode");
0N/A public static final Object VALUE_ANTIALIAS_OFF =
0N/A new SunHints.Value(KEY_ANTIALIASING,
0N/A SunHints.INTVAL_ANTIALIAS_OFF,
0N/A "Nonantialiased rendering mode");
0N/A public static final Object VALUE_ANTIALIAS_DEFAULT =
0N/A new SunHints.Value(KEY_ANTIALIASING,
0N/A SunHints.INTVAL_ANTIALIAS_DEFAULT,
0N/A "Default antialiasing rendering mode");
0N/A
0N/A /**
0N/A * Text antialiasing hint key and value objects
0N/A */
0N/A public static final Key KEY_TEXT_ANTIALIASING =
0N/A new SunHints.Key(SunHints.INTKEY_TEXT_ANTIALIASING,
0N/A "Text-specific antialiasing enable key");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_ON =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_ON,
0N/A "Antialiased text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_OFF =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_OFF,
0N/A "Nonantialiased text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT,
0N/A "Default antialiasing text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_GASP =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_GASP,
0N/A "gasp antialiasing text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_LCD_HRGB =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB,
0N/A "LCD HRGB antialiasing text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_LCD_HBGR =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HBGR,
0N/A "LCD HBGR antialiasing text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_LCD_VRGB =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB,
0N/A "LCD VRGB antialiasing text mode");
0N/A public static final Object VALUE_TEXT_ANTIALIAS_LCD_VBGR =
0N/A new SunHints.Value(KEY_TEXT_ANTIALIASING,
0N/A SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VBGR,
0N/A "LCD VBGR antialiasing text mode");
0N/A
0N/A /**
0N/A * Font fractional metrics hint key and value objects
0N/A */
0N/A public static final Key KEY_FRACTIONALMETRICS =
0N/A new SunHints.Key(SunHints.INTKEY_FRACTIONALMETRICS,
0N/A "Fractional metrics enable key");
0N/A public static final Object VALUE_FRACTIONALMETRICS_ON =
0N/A new SunHints.Value(KEY_FRACTIONALMETRICS,
0N/A SunHints.INTVAL_FRACTIONALMETRICS_ON,
0N/A "Fractional text metrics mode");
0N/A public static final Object VALUE_FRACTIONALMETRICS_OFF =
0N/A new SunHints.Value(KEY_FRACTIONALMETRICS,
0N/A SunHints.INTVAL_FRACTIONALMETRICS_OFF,
0N/A "Integer text metrics mode");
0N/A public static final Object VALUE_FRACTIONALMETRICS_DEFAULT =
0N/A new SunHints.Value(KEY_FRACTIONALMETRICS,
0N/A SunHints.INTVAL_FRACTIONALMETRICS_DEFAULT,
0N/A "Default fractional text metrics mode");
0N/A
0N/A /**
0N/A * Dithering hint key and value objects
0N/A */
0N/A public static final Key KEY_DITHERING =
0N/A new SunHints.Key(SunHints.INTKEY_DITHERING,
0N/A "Dithering quality key");
0N/A public static final Object VALUE_DITHER_ENABLE =
0N/A new SunHints.Value(KEY_DITHERING,
0N/A SunHints.INTVAL_DITHER_ENABLE,
0N/A "Dithered rendering mode");
0N/A public static final Object VALUE_DITHER_DISABLE =
0N/A new SunHints.Value(KEY_DITHERING,
0N/A SunHints.INTVAL_DITHER_DISABLE,
0N/A "Nondithered rendering mode");
0N/A public static final Object VALUE_DITHER_DEFAULT =
0N/A new SunHints.Value(KEY_DITHERING,
0N/A SunHints.INTVAL_DITHER_DEFAULT,
0N/A "Default dithering mode");
0N/A
0N/A /**
0N/A * Interpolation hint key and value objects
0N/A */
0N/A public static final Key KEY_INTERPOLATION =
0N/A new SunHints.Key(SunHints.INTKEY_INTERPOLATION,
0N/A "Image interpolation method key");
0N/A public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR =
0N/A new SunHints.Value(KEY_INTERPOLATION,
0N/A SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR,
0N/A "Nearest Neighbor image interpolation mode");
0N/A public static final Object VALUE_INTERPOLATION_BILINEAR =
0N/A new SunHints.Value(KEY_INTERPOLATION,
0N/A SunHints.INTVAL_INTERPOLATION_BILINEAR,
0N/A "Bilinear image interpolation mode");
0N/A public static final Object VALUE_INTERPOLATION_BICUBIC =
0N/A new SunHints.Value(KEY_INTERPOLATION,
0N/A SunHints.INTVAL_INTERPOLATION_BICUBIC,
0N/A "Bicubic image interpolation mode");
0N/A
0N/A /**
0N/A * Alpha interpolation hint key and value objects
0N/A */
0N/A public static final Key KEY_ALPHA_INTERPOLATION =
0N/A new SunHints.Key(SunHints.INTKEY_ALPHA_INTERPOLATION,
0N/A "Alpha blending interpolation method key");
0N/A public static final Object VALUE_ALPHA_INTERPOLATION_SPEED =
0N/A new SunHints.Value(KEY_ALPHA_INTERPOLATION,
0N/A SunHints.INTVAL_ALPHA_INTERPOLATION_SPEED,
0N/A "Fastest alpha blending methods");
0N/A public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY =
0N/A new SunHints.Value(KEY_ALPHA_INTERPOLATION,
0N/A SunHints.INTVAL_ALPHA_INTERPOLATION_QUALITY,
0N/A "Highest quality alpha blending methods");
0N/A public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT =
0N/A new SunHints.Value(KEY_ALPHA_INTERPOLATION,
0N/A SunHints.INTVAL_ALPHA_INTERPOLATION_DEFAULT,
0N/A "Default alpha blending methods");
0N/A
0N/A /**
0N/A * Color rendering hint key and value objects
0N/A */
0N/A public static final Key KEY_COLOR_RENDERING =
0N/A new SunHints.Key(SunHints.INTKEY_COLOR_RENDERING,
0N/A "Color rendering quality key");
0N/A public static final Object VALUE_COLOR_RENDER_SPEED =
0N/A new SunHints.Value(KEY_COLOR_RENDERING,
0N/A SunHints.INTVAL_COLOR_RENDER_SPEED,
0N/A "Fastest color rendering mode");
0N/A public static final Object VALUE_COLOR_RENDER_QUALITY =
0N/A new SunHints.Value(KEY_COLOR_RENDERING,
0N/A SunHints.INTVAL_COLOR_RENDER_QUALITY,
0N/A "Highest quality color rendering mode");
0N/A public static final Object VALUE_COLOR_RENDER_DEFAULT =
0N/A new SunHints.Value(KEY_COLOR_RENDERING,
0N/A SunHints.INTVAL_COLOR_RENDER_DEFAULT,
0N/A "Default color rendering mode");
0N/A
0N/A /**
0N/A * Stroke normalization control hint key and value objects
0N/A */
0N/A public static final Key KEY_STROKE_CONTROL =
0N/A new SunHints.Key(SunHints.INTKEY_STROKE_CONTROL,
0N/A "Stroke normalization control key");
0N/A public static final Object VALUE_STROKE_DEFAULT =
0N/A new SunHints.Value(KEY_STROKE_CONTROL,
0N/A SunHints.INTVAL_STROKE_DEFAULT,
0N/A "Default stroke normalization");
0N/A public static final Object VALUE_STROKE_NORMALIZE =
0N/A new SunHints.Value(KEY_STROKE_CONTROL,
0N/A SunHints.INTVAL_STROKE_NORMALIZE,
0N/A "Normalize strokes for consistent rendering");
0N/A public static final Object VALUE_STROKE_PURE =
0N/A new SunHints.Value(KEY_STROKE_CONTROL,
0N/A SunHints.INTVAL_STROKE_PURE,
0N/A "Pure stroke conversion for accurate paths");
0N/A
0N/A
0N/A public static class LCDContrastKey extends Key {
0N/A
0N/A public LCDContrastKey(int privatekey, String description) {
0N/A super(privatekey, description);
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the specified object is a valid value
0N/A * for this Key. The allowable range is 100 to 250.
0N/A */
0N/A public final boolean isCompatibleValue(Object val) {
0N/A if (val instanceof Integer) {
0N/A int ival = ((Integer)val).intValue();
0N/A return ival >= 100 && ival <= 250;
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A }
0N/A
0N/A /**
0N/A * LCD text contrast hint key
0N/A */
0N/A public static final RenderingHints.Key
0N/A KEY_TEXT_ANTIALIAS_LCD_CONTRAST =
0N/A new LCDContrastKey(SunHints.INTKEY_AATEXT_LCD_CONTRAST,
0N/A "Text-specific LCD contrast key");
0N/A}