RenderingHints.java revision 0
0N/A * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 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 * 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * The {@code RenderingHints} class defines and manages collections of 0N/A * keys and associated values which allow an application to provide input 0N/A * into the choice of algorithms used by other classes which perform 0N/A * rendering and image manipulation services. 0N/A * The {@link java.awt.Graphics2D} class, and classes that implement 0N/A * {@link java.awt.image.BufferedImageOp} and 0N/A * {@link java.awt.image.RasterOp} all provide methods to get and 0N/A * possibly to set individual or groups of {@code RenderingHints} 0N/A * keys and their associated values. 0N/A * When those implementations perform any rendering or image manipulation 0N/A * operations they should examine the values of any {@code RenderingHints} 0N/A * that were requested by the caller and tailor the algorithms used 0N/A * accordingly and to the best of their ability. 0N/A * Note that since these keys and values are <i>hints</i>, there is 0N/A * no requirement that a given implementation supports all possible 0N/A * choices indicated below or that it can respond to requests to 0N/A * modify its choice of algorithm. 0N/A * The values of the various hint keys may also interact such that 0N/A * while all variants of a given key are supported in one situation, 0N/A * the implementation may be more restricted when the values associated 0N/A * with other keys are modified. 0N/A * For example, some implementations may be able to provide several 0N/A * types of dithering when the antialiasing hint is turned off, but 0N/A * have little control over dithering when antialiasing is on. 0N/A * The full set of supported keys and hints may also vary by destination 0N/A * since runtimes may use different underlying modules to render to 0N/A * the screen, or to {@link java.awt.image.BufferedImage} objects, 0N/A * or while printing. 0N/A * Implementations are free to ignore the hints completely, but should 0N/A * try to use an implementation algorithm that is as close as possible 0N/A * If an implementation supports a given algorithm when any value is used 0N/A * for an associated hint key, then minimally it must do so when the 0N/A * value for that key is the exact value that specifies the algorithm. 0N/A * The keys used to control the hints are all special values that 0N/A * subclass the associated {@link RenderingHints.Key} class. 0N/A * Many common hints are expressed below as static constants in this 0N/A * class, but the list is not meant to be exhaustive. 0N/A * Other hints may be created by other packages by defining new objects 0N/A * which subclass the {@code Key} class and defining the associated values. 0N/A * Defines the base type of all keys used along with the 0N/A * {@link RenderingHints} class to control various 0N/A * algorithm choices in the rendering and imaging pipelines. 0N/A * Instances of this class are immutable and unique which 0N/A * means that tests for matches can be made using the 0N/A * {@code ==} operator instead of the more expensive 0N/A * {@code equals()} method. 0N/A public abstract static class Key {
0N/A // Note that the identity string is dependent on 3 variables: 0N/A // - the name of the subclass of Key 0N/A // - the identityHashCode of the subclass of Key 0N/A // - the integer key of the Key 0N/A // It is theoretically possible for 2 distinct keys to collide 0N/A // along all 3 of those attributes in the context of multiple 0N/A // class loaders, but that occurence will be extremely rare and 0N/A // we account for that possibility below in the recordIdentity 0N/A // method by slightly relaxing our uniqueness guarantees if we 0N/A // end up in that situation. 0N/A " already registered");
0N/A // Note that this system can fail in a mostly harmless 0N/A // way. If we end up generating the same identity 0N/A // String for 2 different classes (a very rare case) 0N/A // then we correctly avoid throwing the exception above, 0N/A // but we are about to drop through to a statement that 0N/A // will replace the entry for the old Key subclass with 0N/A // an entry for the new Key subclass. At that time the 0N/A // old subclass will be vulnerable to someone generating 0N/A // a duplicate Key instance for it. We could bail out 0N/A // of the method here and let the old identity keep its 0N/A // record in the map, but we are more likely to see a 0N/A // duplicate key go by for the new class than the old 0N/A // one since the new one is probably still in the 0N/A // initialization stage. In either case, the probability 0N/A // of loading 2 classes in the same VM with the same name 0N/A // and identityHashCode should be nearly impossible. 0N/A // Note: Use a weak reference to avoid holding on to extra 0N/A // objects and classes after they should be unloaded. 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 * @param privatekey the specified key 0N/A * Returns true if the specified object is a valid value 0N/A * @param val the <code>Object</code> to test for validity 0N/A * @return <code>true</code> if <code>val</code> is valid; 0N/A * <code>false</code> otherwise. 0N/A * Returns the private integer key that the subclass 0N/A * instantiated this Key with. 0N/A * @return the private integer key that the subclass 0N/A * instantiated this Key with. 0N/A * The hash code for all Key objects will be the same as the 0N/A * system identity code of the object as defined by the 0N/A * System.identityHashCode() method. 0N/A * The equals method for all Key objects will return the same 0N/A * result as the equality operator '=='. 0N/A * Antialiasing hint key. 0N/A * The {@code ANTIALIASING} hint controls whether or not the 0N/A * geometry rendering methods of a {@link Graphics2D} object 0N/A * will attempt to reduce aliasing artifacts along the edges 0N/A * A typical antialiasing algorithm works by blending the existing 0N/A * colors of the pixels along the boundary of a shape with the 0N/A * requested fill paint according to the estimated partial pixel 0N/A * coverage of the shape. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_ANTIALIAS_ON} 0N/A * <li>{@link #VALUE_ANTIALIAS_OFF} 0N/A * <li>{@link #VALUE_ANTIALIAS_DEFAULT} 0N/A * Antialiasing hint value -- rendering is done with antialiasing. 0N/A * @see #KEY_ANTIALIASING 0N/A * Antialiasing hint value -- rendering is done without antialiasing. 0N/A * @see #KEY_ANTIALIASING 0N/A * Antialiasing hint value -- rendering is done with a default 0N/A * antialiasing mode chosen by the implementation. 0N/A * @see #KEY_ANTIALIASING 0N/A * Rendering hint key. 0N/A * The {@code RENDERING} hint is a general hint that provides 0N/A * a high level recommendation as to whether to bias algorithm 0N/A * choices more for speed or quality when evaluating tradeoffs. 0N/A * This hint could be consulted for any rendering or image 0N/A * manipulation operation, but decisions will usually honor 0N/A * other, more specific hints in preference to this hint. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_RENDER_SPEED} 0N/A * <li>{@link #VALUE_RENDER_QUALITY} 0N/A * <li>{@link #VALUE_RENDER_DEFAULT} 0N/A * Rendering hint value -- rendering algorithms are chosen 0N/A * with a preference for output speed. 0N/A * @see #KEY_RENDERING 0N/A * Rendering hint value -- rendering algorithms are chosen 0N/A * with a preference for output quality. 0N/A * @see #KEY_RENDERING 0N/A * Rendering hint value -- rendering algorithms are chosen 0N/A * by the implementation for a good tradeoff of performance 0N/A * @see #KEY_RENDERING 0N/A * Dithering hint key. 0N/A * The {@code DITHERING} hint controls how closely to approximate 0N/A * a color when storing into a destination with limited color 0N/A * Some rendering destinations may support a limited number of 0N/A * color choices which may not be able to accurately represent 0N/A * the full spectrum of colors that can result during rendering 0N/A * For such a destination the {@code DITHERING} hint controls 0N/A * whether rendering is done with a flat solid fill of a single 0N/A * pixel value which is the closest supported color to what was 0N/A * requested, or whether shapes will be filled with a pattern of 0N/A * colors which combine to better approximate that color. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_DITHER_DISABLE} 0N/A * <li>{@link #VALUE_DITHER_ENABLE} 0N/A * <li>{@link #VALUE_DITHER_DEFAULT} 0N/A * Dithering hint value -- do not dither when rendering geometry. 0N/A * @see #KEY_DITHERING 0N/A * Dithering hint value -- dither when rendering geometry, if needed. 0N/A * @see #KEY_DITHERING 0N/A * Dithering hint value -- use a default for dithering chosen by 0N/A * the implementation. 0N/A * @see #KEY_DITHERING 0N/A * Text antialiasing hint key. 0N/A * The {@code TEXT_ANTIALIASING} hint can control the use of 0N/A * antialiasing algorithms for text independently of the 0N/A * choice used for shape rendering. 0N/A * Often an application may want to use antialiasing for text 0N/A * only and not for other shapes. 0N/A * Additionally, the algorithms for reducing the aliasing 0N/A * artifacts for text are often more sophisticated than those 0N/A * that have been developed for general rendering so this 0N/A * hint key provides additional values which can control 0N/A * the choices of some of those text-specific algorithms. 0N/A * If left in the {@code DEFAULT} state, this hint will 0N/A * generally defer to the value of the regular 0N/A * {@link #KEY_ANTIALIASING} hint key. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_ON} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_OFF} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_DEFAULT} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_GASP} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_HBGR} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_VRGB} 0N/A * <li>{@link #VALUE_TEXT_ANTIALIAS_LCD_VBGR} 0N/A * Text antialiasing hint value -- text rendering is done with 0N/A * some form of antialiasing. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- text rendering is done without 0N/A * any form of antialiasing. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- text rendering is done according 0N/A * to the {@link #KEY_ANTIALIASING} hint or a default chosen by the 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- text rendering is requested to 0N/A * use information in the font resource which specifies for each point 0N/A * size whether to apply {@link #VALUE_TEXT_ANTIALIAS_ON} or 0N/A * {@link #VALUE_TEXT_ANTIALIAS_OFF}. 0N/A * TrueType fonts typically provide this information in the 'gasp' table. 0N/A * In the absence of this information, the behaviour for a particular 0N/A * font and size is determined by implementation defaults. 0N/A * <i>Note:</i>A font designer will typically carefully hint a font for 0N/A * the most common user interface point sizes. Consequently the 'gasp' 0N/A * table will likely specify to use only hinting at those sizes and not 0N/A * "smoothing". So in many cases the resulting text display is 0N/A * equivalent to {@code VALUE_TEXT_ANTIALIAS_OFF}. 0N/A * This may be unexpected but is correct. 0N/A * Logical fonts which are composed of multiple physical fonts will for 0N/A * consistency will use the setting most appropriate for the overall 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- request that text be displayed 0N/A * optimised for an LCD display with subpixels in order from display 0N/A * left to right of R,G,B such that the horizontal subpixel resolution 0N/A * is three times that of the full pixel horizontal resolution (HRGB). 0N/A * This is the most common configuration. 0N/A * Selecting this hint for displays with one of the other LCD subpixel 0N/A * configurations will likely result in unfocused text. 0N/A * An implementation when choosing whether to apply any of the 0N/A * LCD text hint values may take into account factors including requiring 0N/A * color depth of the destination to be at least 15 bits per pixel 0N/A * (ie 5 bits per color component), 0N/A * characteristics of a font such as whether embedded bitmaps may 0N/A * produce better results, or when displaying to a non-local networked 0N/A * display device enabling it only if suitable protocols are available, 0N/A * or ignoring the hint if performing very high resolution rendering 0N/A * or the target device is not appropriate: eg when printing. 0N/A * These hints can equally be applied when rendering to software images, 0N/A * but these images may not then be suitable for general export, as the 0N/A * text will have been rendered appropriately for a specific subpixel 0N/A * organisation. Also lossy images are not a good choice, nor image 0N/A * formats such as GIF which have limited colors. 0N/A * So unless the image is destined solely for rendering on a 0N/A * display device with the same configuration, some other text 0N/A * anti-aliasing hint such as 0N/A * {@link #VALUE_TEXT_ANTIALIAS_ON} 0N/A * may be a better choice. 0N/A * <p>Selecting a value which does not match the LCD display in use 0N/A * will likely lead to a degradation in text quality. 0N/A * On display devices (ie CRTs) which do not have the same characteristics 0N/A * as LCD displays, the overall effect may appear similar to standard text 0N/A * anti-aliasing, but the quality may be degraded by color distortion. 0N/A * Analog connected LCD displays may also show little advantage over 0N/A * standard text-antialiasing and be similar to CRTs. 0N/A * In other words for the best results use an LCD display with a digital 0N/A * display connector and specify the appropriate sub-pixel configuration. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- request that text be displayed 0N/A * optimised for an LCD display with subpixels in order from display 0N/A * left to right of B,G,R such that the horizontal subpixel resolution 0N/A * is three times that of the full pixel horizontal resolution (HBGR). 0N/A * This is a much less common configuration than HRGB. 0N/A * Selecting this hint for displays with one of the other LCD subpixel 0N/A * configurations will likely result in unfocused text. 0N/A * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}, 0N/A * for more information on when this hint is applied. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- request that text be displayed 0N/A * optimised for an LCD display with subpixel organisation from display 0N/A * top to bottom of R,G,B such that the vertical subpixel resolution is 0N/A * three times that of the full pixel vertical resolution (VRGB). 0N/A * Vertical orientation is very uncommon and probably mainly useful 0N/A * for a physically rotated display. 0N/A * Selecting this hint for displays with one of the other LCD subpixel 0N/A * configurations will likely result in unfocused text. 0N/A * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}, 0N/A * for more information on when this hint is applied. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Text antialiasing hint value -- request that text be displayed 0N/A * optimised for an LCD display with subpixel organisation from display 0N/A * top to bottom of B,G,R such that the vertical subpixel resolution is 0N/A * three times that of the full pixel vertical resolution (VBGR). 0N/A * Vertical orientation is very uncommon and probably mainly useful 0N/A * for a physically rotated display. 0N/A * Selecting this hint for displays with one of the other LCD subpixel 0N/A * configurations will likely result in unfocused text. 0N/A * See {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}, 0N/A * for more information on when this hint is applied. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * LCD text contrast rendering hint key. 0N/A * The value is an <code>Integer</code> object which is used as a text 0N/A * contrast adjustment when used in conjunction with an LCD text 0N/A * anti-aliasing hint such as 0N/A * {@link #VALUE_TEXT_ANTIALIAS_LCD_HRGB}. 0N/A * <li>Values should be a positive integer in the range 100 to 250. 0N/A * <li>A lower value (eg 100) corresponds to higher contrast text when 0N/A * displaying dark text on a light background. 0N/A * <li>A higher value (eg 200) corresponds to lower contrast text when 0N/A * displaying dark text on a light background. 0N/A * <li>A typical useful value is in the narrow range 140-180. 0N/A * <li>If no value is specified, a system or implementation default value 0N/A * The default value can be expected to be adequate for most purposes, 0N/A * so clients should rarely need to specify a value for this hint unless 0N/A * they have concrete information as to an appropriate value. 0N/A * A higher value does not mean a higher contrast, in fact the opposite 0N/A * The correction is applied in a similar manner to a gamma adjustment 0N/A * for non-linear perceptual luminance response of display systems, but 0N/A * does not indicate a full correction for this. 0N/A * @see #KEY_TEXT_ANTIALIASING 0N/A * Font fractional metrics hint key. 0N/A * The {@code FRACTIONALMETRICS} hint controls whether the positioning 0N/A * of individual character glyphs takes into account the sub-pixel 0N/A * accuracy of the scaled character advances of the font or whether 0N/A * such advance vectors are rounded to an integer number of whole 0N/A * This hint only recommends how much accuracy should be used to 0N/A * position the glyphs and does not specify or recommend whether or 0N/A * not the actual rasterization or pixel bounds of the glyph should 0N/A * be modified to match. 0N/A * Rendering text to a low resolution device like a screen will 0N/A * necessarily involve a number of rounding operations as the 0N/A * high quality and very precise definition of the shape and 0N/A * metrics of the character glyphs must be matched to discrete 0N/A * Ideally the positioning of glyphs during text layout would be 0N/A * calculated by scaling the design metrics in the font according 0N/A * to the point size, but then the scaled advance width will not 0N/A * necessarily be an integer number of pixels. 0N/A * If the glyphs are positioned with sub-pixel accuracy according 0N/A * to these scaled design metrics then the rasterization would 0N/A * ideally need to be adjusted for each possible sub-pixel origin. 0N/A * Unfortunately, scaling each glyph customized to its exact 0N/A * subpixel origin during text layout would be prohibitively 0N/A * expensive so a simplified system based on integer device 0N/A * positions is typically used to lay out the text. 0N/A * The rasterization of the glyph and the scaled advance width 0N/A * are both adjusted together to yield text that looks good at 0N/A * device resolution and has consistent integer pixel distances 0N/A * between glyphs that help the glyphs look uniformly and 0N/A * consistently spaced and readable. 0N/A * This process of rounding advance widths for rasterized glyphs 0N/A * to integer distances means that the character density and the 0N/A * overall length of a string of text will be different from the 0N/A * theoretical design measurements due to the accumulation of 0N/A * a series of small differences in the adjusted widths of 0N/A * The specific differences will be different for each glyph, 0N/A * some being wider and some being narrower than their theoretical 0N/A * design measurements. 0N/A * Thus the overall difference in character density and length 0N/A * will vary by a number of factors including the font, the 0N/A * specific device resolution being targeted, and the glyphs 0N/A * chosen to represent the string being rendered. 0N/A * As a result, rendering the same string at multiple device 0N/A * resolutions can yield widely varying metrics for whole strings. 0N/A * When {@code FRACTIONALMETRICS} are enabled, the true font design 0N/A * metrics are scaled by the point size and used for layout with 0N/A * sub-pixel accuracy. 0N/A * The average density of glyphs and total length of a long 0N/A * string of characters will therefore more closely match the 0N/A * theoretical design of the font, but readability may be affected 0N/A * since individual pairs of characters may not always appear to 0N/A * be consistent distances apart depending on how the sub-pixel 0N/A * accumulation of the glyph origins meshes with the device pixel 0N/A * Enabling this hint may be desirable when text layout is being 0N/A * performed that must be consistent across a wide variety of 0N/A * output resolutions. 0N/A * Specifically, this hint may be desirable in situations where 0N/A * the layout of text is being previewed on a low resolution 0N/A * device like a screen for output that will eventually be 0N/A * rendered on a high resolution printer or typesetting device. 0N/A * When disabled, the scaled design metrics are rounded or adjusted 0N/A * to integer distances for layout. 0N/A * The distances between any specific pair of glyphs will be more 0N/A * uniform on the device, but the density and total length of long 0N/A * strings may no longer match the theoretical intentions of the 0N/A * Disabling this hint will typically produce more readable results 0N/A * on low resolution devices like computer monitors. 0N/A * The allowable values for this key are 0N/A * <li>{@link #VALUE_FRACTIONALMETRICS_OFF} 0N/A * <li>{@link #VALUE_FRACTIONALMETRICS_ON} 0N/A * <li>{@link #VALUE_FRACTIONALMETRICS_DEFAULT} 0N/A * Font fractional metrics hint value -- character glyphs are 0N/A * positioned with advance widths rounded to pixel boundaries. 0N/A * @see #KEY_FRACTIONALMETRICS 0N/A * Font fractional metrics hint value -- character glyphs are 0N/A * positioned with sub-pixel accuracy. 0N/A * @see #KEY_FRACTIONALMETRICS 0N/A * Font fractional metrics hint value -- character glyphs are 0N/A * positioned with accuracy chosen by the implementation. 0N/A * @see #KEY_FRACTIONALMETRICS 0N/A * Interpolation hint key. 0N/A * The {@code INTERPOLATION} hint controls how image pixels are 0N/A * filtered or resampled during an image rendering operation. 0N/A * Implicitly images are defined to provide color samples at 0N/A * integer coordinate locations. 0N/A * When images are rendered upright with no scaling onto a 0N/A * destination, the choice of which image pixels map to which 0N/A * device pixels is obvious and the samples at the integer 0N/A * coordinate locations in the image are transfered to the 0N/A * pixels at the corresponding integer locations on the device 0N/A * pixel grid one for one. 0N/A * When images are rendered in a scaled, rotated, or otherwise 0N/A * transformed coordinate system, then the mapping of device 0N/A * pixel coordinates back to the image can raise the question 0N/A * of what color sample to use for the continuous coordinates 0N/A * that lie between the integer locations of the provided image 0N/A * Interpolation algorithms define functions which provide a 0N/A * color sample for any continuous coordinate in an image based 0N/A * on the color samples at the surrounding integer coordinates. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR} 0N/A * <li>{@link #VALUE_INTERPOLATION_BILINEAR} 0N/A * <li>{@link #VALUE_INTERPOLATION_BICUBIC} 0N/A * Interpolation hint value -- the color sample of the nearest 0N/A * neighboring integer coordinate sample in the image is used. 0N/A * Conceptually the image is viewed as a grid of unit-sized 0N/A * square regions of color centered around the center of each 0N/A * As the image is scaled up, it will look correspondingly blocky. 0N/A * As the image is scaled down, the colors for source pixels will 0N/A * be either used unmodified, or skipped entirely in the output 0N/A * @see #KEY_INTERPOLATION 0N/A * Interpolation hint value -- the color samples of the 4 nearest 0N/A * neighboring integer coordinate samples in the image are 0N/A * interpolated linearly to produce a color sample. 0N/A * Conceptually the image is viewed as a set of infinitely small 0N/A * point color samples which have value only at the centers of 0N/A * integer coordinate pixels and the space between those pixel 0N/A * centers is filled with linear ramps of colors that connect 0N/A * adjacent discrete samples in a straight line. 0N/A * As the image is scaled up, there are no blocky edges between 0N/A * the colors in the image as there are with 0N/A * {@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR NEAREST_NEIGHBOR}, 0N/A * but the blending may show some subtle discontinuities along the 0N/A * horizontal and vertical edges that line up with the samples 0N/A * caused by a sudden change in the slope of the interpolation 0N/A * from one side of a sample to the other. 0N/A * As the image is scaled down, more image pixels have their 0N/A * color samples represented in the resulting output since each 0N/A * output pixel recieves color information from up to 4 image 0N/A * @see #KEY_INTERPOLATION 0N/A * Interpolation hint value -- the color samples of 9 nearby 0N/A * integer coordinate samples in the image are interpolated using 0N/A * a cubic function in both {@code X} and {@code Y} to produce 0N/A * Conceptually the view of the image is very similar to the view 0N/A * used in the {@link #VALUE_INTERPOLATION_BILINEAR BILINEAR} 0N/A * algorithm except that the ramps of colors that connect between 0N/A * the samples are curved and have better continuity of slope 0N/A * as they cross over between sample boundaries. 0N/A * As the image is scaled up, there are no blocky edges and the 0N/A * interpolation should appear smoother and with better depictions 0N/A * of any edges in the original image than with {@code BILINEAR}. 0N/A * As the image is scaled down, even more of the original color 0N/A * samples from the original image will have their color information 0N/A * carried through and represented. 0N/A * @see #KEY_INTERPOLATION 0N/A * Alpha interpolation hint key. 0N/A * The {@code ALPHA_INTERPOLATION} hint is a general hint that 0N/A * provides a high level recommendation as to whether to bias 0N/A * alpha blending algorithm choices more for speed or quality 0N/A * when evaluating tradeoffs. 0N/A * This hint could control the choice of alpha blending 0N/A * calculations that sacrifice some precision to use fast 0N/A * lookup tables or lower precision SIMD instructions. 0N/A * This hint could also control whether or not the color 0N/A * and alpha values are converted into a linear color space 0N/A * during the calculations for a more linear visual effect 0N/A * at the expense of additional per-pixel calculations. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_ALPHA_INTERPOLATION_SPEED} 0N/A * <li>{@link #VALUE_ALPHA_INTERPOLATION_QUALITY} 0N/A * <li>{@link #VALUE_ALPHA_INTERPOLATION_DEFAULT} 0N/A * Alpha interpolation hint value -- alpha blending algorithms 0N/A * are chosen with a preference for calculation speed. 0N/A * @see #KEY_ALPHA_INTERPOLATION 0N/A * Alpha interpolation hint value -- alpha blending algorithms 0N/A * are chosen with a preference for precision and visual quality. 0N/A * @see #KEY_ALPHA_INTERPOLATION 0N/A * Alpha interpolation hint value -- alpha blending algorithms 0N/A * are chosen by the implementation for a good tradeoff of 0N/A * performance vs. quality. 0N/A * @see #KEY_ALPHA_INTERPOLATION 0N/A * Color rendering hint key. 0N/A * The {@code COLOR_RENDERING} hint controls the accuracy of 0N/A * approximation and conversion when storing colors into a 0N/A * destination image or surface. 0N/A * When a rendering or image manipulation operation produces 0N/A * a color value that must be stored into a destination, it 0N/A * must first convert that color into a form suitable for 0N/A * storing into the destination image or surface. 0N/A * Minimally, the color components must be converted to bit 0N/A * representations and ordered in the correct order or an 0N/A * index into a color lookup table must be chosen before 0N/A * the data can be stored into the destination memory. 0N/A * Without this minimal conversion, the data in the destination 0N/A * would likely represent random, incorrect or possibly even 0N/A * unsupported values. 0N/A * Algorithms to quickly convert the results of rendering 0N/A * operations into the color format of most common destinations 0N/A * are well known and fairly optimal to execute. 0N/A * Simply performing the most basic color format conversion to 0N/A * store colors into a destination can potentially ignore a 0N/A * difference in the calibration of the 0N/A * {@link java.awt.color.ColorSpace} 0N/A * of the source and destination or other factors such as the 0N/A * linearity of the gamma correction. 0N/A * Unless the source and destination {@code ColorSpace} are 0N/A * identical, to correctly perform a rendering operation with 0N/A * the most care taken for the accuracy of the colors being 0N/A * represented, the source colors should be converted to a 0N/A * device independent {@code ColorSpace} and the results then 0N/A * converted back to the destination {@code ColorSpace}. 0N/A * Furthermore, if calculations such as the blending of multiple 0N/A * source colors are to be performed during the rendering 0N/A * operation, greater visual clarity can be achieved if the 0N/A * intermediate device independent {@code ColorSpace} is 0N/A * chosen to have a linear relationship between the values 0N/A * being calculated and the perception of the human eye to 0N/A * the response curves of the output device. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_COLOR_RENDER_SPEED} 0N/A * <li>{@link #VALUE_COLOR_RENDER_QUALITY} 0N/A * <li>{@link #VALUE_COLOR_RENDER_DEFAULT} 0N/A * Color rendering hint value -- perform the fastest color 0N/A * conversion to the format of the output device. 0N/A * @see #KEY_COLOR_RENDERING 0N/A * Color rendering hint value -- perform the color conversion 0N/A * calculations with the highest accuracy and visual quality. 0N/A * @see #KEY_COLOR_RENDERING 0N/A * Color rendering hint value -- perform color conversion 0N/A * calculations as chosen by the implementation to represent 0N/A * the best available tradeoff between performance and 0N/A * @see #KEY_COLOR_RENDERING 0N/A * Stroke normalization control hint key. 0N/A * The {@code STROKE_CONTROL} hint controls whether a rendering 0N/A * implementation should or is allowed to modify the geometry 0N/A * of rendered shapes for various purposes. 0N/A * Some implementations may be able to use an optimized platform 0N/A * rendering library which may be faster than traditional software 0N/A * rendering algorithms on a given platform, but which may also 0N/A * not support floating point coordinates. 0N/A * Some implementations may also have sophisticated algorithms 0N/A * which perturb the coordinates of a path so that wide lines 0N/A * appear more uniform in width and spacing. 0N/A * If an implementation performs any type of modification or 0N/A * "normalization" of a path, it should never move the coordinates 0N/A * by more than half a pixel in any direction. 0N/A * The allowable values for this hint are 0N/A * <li>{@link #VALUE_STROKE_NORMALIZE} 0N/A * <li>{@link #VALUE_STROKE_PURE} 0N/A * <li>{@link #VALUE_STROKE_DEFAULT} 0N/A * Stroke normalization control hint value -- geometry may be 0N/A * modified or left pure depending on the tradeoffs in a given 0N/A * Typically this setting allows an implementation to use a fast 0N/A * integer coordinate based platform rendering library, but does 0N/A * not specifically request normalization for uniformity or 0N/A * @see #KEY_STROKE_CONTROL 0N/A * Stroke normalization control hint value -- geometry should 0N/A * be normalized to improve uniformity or spacing of lines and 0N/A * overall aesthetics. 0N/A * Note that different normalization algorithms may be more 0N/A * successful than others for given input paths. 0N/A * @see #KEY_STROKE_CONTROL 0N/A * Stroke normalization control hint value -- geometry should 0N/A * be left unmodified and rendered with sub-pixel accuracy. 0N/A * @see #KEY_STROKE_CONTROL 0N/A * Constructs a new object with keys and values initialized 0N/A * from the specified Map object which may be null. 0N/A * @param init a map of key/value pairs to initialize the hints 0N/A * or null if the object should be empty 0N/A * Constructs a new object with the specified key/value pair. 0N/A * @param key the key of the particular hint property 0N/A * @param value the value of the hint property specified with 0N/A * Returns the number of key-value mappings in this 0N/A * <code>RenderingHints</code>. 0N/A * @return the number of key-value mappings in this 0N/A * <code>RenderingHints</code>. 0N/A * Returns <code>true</code> if this 0N/A * <code>RenderingHints</code> contains no key-value mappings. 0N/A * @return <code>true</code> if this 0N/A * <code>RenderingHints</code> contains no key-value mappings. 0N/A * Returns <code>true</code> if this <code>RenderingHints</code> 0N/A * contains a mapping for the specified key. 0N/A * @param key key whose presence in this 0N/A * <code>RenderingHints</code> is to be tested. 0N/A * @return <code>true</code> if this <code>RenderingHints</code> 0N/A * contains a mapping for the specified key. 0N/A * @exception <code>ClassCastException</code> if the key can not 0N/A * be cast to <code>RenderingHints.Key</code> 0N/A * Returns true if this RenderingHints maps one or more keys to the 0N/A * More formally, returns <code>true</code> if and only 0N/A * if this <code>RenderingHints</code> 0N/A * contains at least one mapping to a value <code>v</code> such that 0N/A * (value==null ? v==null : value.equals(v)) 0N/A * This operation will probably require time linear in the 0N/A * <code>RenderingHints</code> size for most implementations 0N/A * of <code>RenderingHints</code>. 0N/A * @param value value whose presence in this 0N/A * <code>RenderingHints</code> is to be tested. 0N/A * @return <code>true</code> if this <code>RenderingHints</code> 0N/A * maps one or more keys to the specified value. 0N/A * Returns the value to which the specified key is mapped. 0N/A * @param key a rendering hint key 0N/A * @return the value to which the key is mapped in this object or 0N/A * <code>null</code> if the key is not mapped to any value in 0N/A * @exception <code>ClassCastException</code> if the key can not 0N/A * be cast to <code>RenderingHints.Key</code> 0N/A * @see #put(Object, Object) 0N/A * Maps the specified <code>key</code> to the specified 0N/A * <code>value</code> in this <code>RenderingHints</code> object. 0N/A * Neither the key nor the value can be <code>null</code>. 0N/A * The value can be retrieved by calling the <code>get</code> method 0N/A * with a key that is equal to the original key. 0N/A * @param key the rendering hint key. 0N/A * @param value the rendering hint value. 0N/A * @return the previous value of the specified key in this object 0N/A * or <code>null</code> if it did not have one. 0N/A * @exception <code>NullPointerException</code> if the key is 0N/A * <code>null</code>. 0N/A * @exception <code>ClassCastException</code> if the key can not 0N/A * be cast to <code>RenderingHints.Key</code> 0N/A * @exception <code>IllegalArgumentException</code> if the 0N/A * {@link Key#isCompatibleValue(java.lang.Object) 0N/A * Key.isCompatibleValue()} 0N/A * method of the specified key returns false for the 0N/A " incompatible with "+
0N/A * Adds all of the keys and corresponding values from the specified 0N/A * <code>RenderingHints</code> object to this 0N/A * <code>RenderingHints</code> object. Keys that are present in 0N/A * this <code>RenderingHints</code> object, but not in the specified 0N/A * <code>RenderingHints</code> object are not affected. 0N/A * @param hints the set of key/value pairs to be added to this 0N/A * <code>RenderingHints</code> object 0N/A * Clears this <code>RenderingHints</code> object of all key/value 0N/A * Removes the key and its corresponding value from this 0N/A * <code>RenderingHints</code> object. This method does nothing if the 0N/A * key is not in this <code>RenderingHints</code> object. 0N/A * @param key the rendering hints key that needs to be removed 0N/A * @exception <code>ClassCastException</code> if the key can not 0N/A * be cast to <code>RenderingHints.Key</code> 0N/A * @return the value to which the key had previously been mapped in this 0N/A * <code>RenderingHints</code> object, or <code>null</code> 0N/A * if the key did not have a mapping. 0N/A * Copies all of the mappings from the specified <code>Map</code> 0N/A * to this <code>RenderingHints</code>. These mappings replace 0N/A * any mappings that this <code>RenderingHints</code> had for any 0N/A * of the keys currently in the specified <code>Map</code>. 0N/A * @param m the specified <code>Map</code> 0N/A * @exception <code>ClassCastException</code> class of a key or value 0N/A * in the specified <code>Map</code> prevents it from being 0N/A * stored in this <code>RenderingHints</code>. 0N/A * @exception <code>IllegalArgumentException</code> some aspect 0N/A * of a key or value in the specified <code>Map</code> 0N/A * prevents it from being stored in 0N/A * this <code>RenderingHints</code>. 0N/A //if (m instanceof RenderingHints) { 0N/A //hintmap.putAll(((RenderingHints) m).hintmap); 0N/A // Funnel each key/value pair through our protected put method 0N/A * Returns a <code>Set</code> view of the Keys contained in this 0N/A * <code>RenderingHints</code>. The Set is backed by the 0N/A * <code>RenderingHints</code>, so changes to the 0N/A * <code>RenderingHints</code> are reflected in the <code>Set</code>, 0N/A * and vice-versa. If the <code>RenderingHints</code> is modified 0N/A * while an iteration over the <code>Set</code> is in progress, 0N/A * the results of the iteration are undefined. The <code>Set</code> 0N/A * supports element removal, which removes the corresponding 0N/A * mapping from the <code>RenderingHints</code>, via the 0N/A * <code>Iterator.remove</code>, <code>Set.remove</code>, 0N/A * <code>removeAll</code> <code>retainAll</code>, and 0N/A * <code>clear</code> operations. It does not support 0N/A * the <code>add</code> or <code>addAll</code> operations. 0N/A * @return a <code>Set</code> view of the keys contained 0N/A * in this <code>RenderingHints</code>. 0N/A * Returns a <code>Collection</code> view of the values 0N/A * contained in this <code>RenderinHints</code>. 0N/A * The <code>Collection</code> is backed by the 0N/A * <code>RenderingHints</code>, so changes to 0N/A * the <code>RenderingHints</code> are reflected in 0N/A * the <code>Collection</code>, and vice-versa. 0N/A * If the <code>RenderingHints</code> is modified while 0N/A * an iteration over the <code>Collection</code> is 0N/A * in progress, the results of the iteration are undefined. 0N/A * The <code>Collection</code> supports element removal, 0N/A * which removes the corresponding mapping from the 0N/A * <code>RenderingHints</code>, via the 0N/A * <code>Iterator.remove</code>, 0N/A * <code>Collection.remove</code>, <code>removeAll</code>, 0N/A * <code>retainAll</code> and <code>clear</code> operations. 0N/A * It does not support the <code>add</code> or 0N/A * <code>addAll</code> operations. 0N/A * @return a <code>Collection</code> view of the values 0N/A * contained in this <code>RenderingHints</code>. 0N/A * Returns a <code>Set</code> view of the mappings contained 0N/A * in this <code>RenderingHints</code>. Each element in the 0N/A * returned <code>Set</code> is a <code>Map.Entry</code>. 0N/A * The <code>Set</code> is backed by the <code>RenderingHints</code>, 0N/A * so changes to the <code>RenderingHints</code> are reflected 0N/A * in the <code>Set</code>, and vice-versa. If the 0N/A * <code>RenderingHints</code> is modified while 0N/A * while an iteration over the <code>Set</code> is in progress, 0N/A * the results of the iteration are undefined. 0N/A * The entrySet returned from a <code>RenderingHints</code> object 0N/A * is not modifiable. 0N/A * @return a <code>Set</code> view of the mappings contained in 0N/A * this <code>RenderingHints</code>. 0N/A * Compares the specified <code>Object</code> with this 0N/A * <code>RenderingHints</code> for equality. 0N/A * Returns <code>true</code> if the specified object is also a 0N/A * <code>Map</code> and the two <code>Map</code> objects represent 0N/A * the same mappings. More formally, two <code>Map</code> objects 0N/A * <code>t1</code> and <code>t2</code> represent the same mappings 0N/A * if <code>t1.keySet().equals(t2.keySet())</code> and for every 0N/A * key <code>k</code> in <code>t1.keySet()</code>, 0N/A * (t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k))) 0N/A * This ensures that the <code>equals</code> method works properly across 0N/A * different implementations of the <code>Map</code> interface. 0N/A * @param o <code>Object</code> to be compared for equality with 0N/A * this <code>RenderingHints</code>. 0N/A * @return <code>true</code> if the specified <code>Object</code> 0N/A * is equal to this <code>RenderingHints</code>. 0N/A }
else if (o
instanceof Map) {
0N/A * Returns the hash code value for this <code>RenderingHints</code>. 0N/A * The hash code of a <code>RenderingHints</code> is defined to be 0N/A * the sum of the hashCodes of each <code>Entry</code> in the 0N/A * <code>RenderingHints</code> object's entrySet view. This ensures that 0N/A * <code>t1.equals(t2)</code> implies that 0N/A * <code>t1.hashCode()==t2.hashCode()</code> for any two <code>Map</code> 0N/A * objects <code>t1</code> and <code>t2</code>, as required by the general 0N/A * contract of <code>Object.hashCode</code>. 0N/A * @return the hash code value for this <code>RenderingHints</code>. 0N/A * @see java.util.Map.Entry#hashCode() 0N/A * @see Object#hashCode() 0N/A * @see Object#equals(Object) 0N/A * @see #equals(Object) 0N/A * Creates a clone of this <code>RenderingHints</code> object 0N/A * that has the same contents as this <code>RenderingHints</code> 0N/A * @return a clone of this instance. 0N/A // this shouldn't happen, since we are Cloneable 0N/A * Returns a rather long string representation of the hashmap 0N/A * which contains the mappings of keys to values for this 0N/A * <code>RenderingHints</code> object. 0N/A * @return a string representation of this object.