<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
 * @(#)FontRenderContext.java	1.21 00/02/02
 *
 * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */

/*
 * @author Charlton Innovations, Inc.
 */

package java.awt.font;

import java.awt.geom.AffineTransform;

/**
*   The &lt;code&gt;FontRenderContext&lt;/code&gt; class is a container for the
*   information needed to correctly measure text.  The measurement of text
*   can vary because of rules that map outlines to pixels, and rendering
*   hints provided by an application.
*   &lt;p&gt;
*   One such piece of information is a transform that scales
*   typographical points to pixels. (A point is defined to be exactly 1/72
*   of an inch, which is slightly different than
*   the traditional mechanical measurement of a point.)  A character that 
*   is rendered at 12pt on a 600dpi device might have a different size
*   than the same character rendered at 12pt on a 72dpi device because of
*   such factors as rounding to pixel boundaries and hints that the font
*   designer may have specified.
*   &lt;p&gt;
*   Anti-aliasing and Fractional-metrics specified by an application can also
*   affect the size of a character because of rounding to pixel
*   boundaries.
*   &lt;p&gt;
*   Typically, instances of &lt;code&gt;FontRenderContext&lt;/code&gt; are obtained from
*   a {@link Graphics2D} object.  A &lt;code&gt;FontRenderContext&lt;/code&gt; 
*   which is directly constructed will most likely not represent any actual
*   graphics device, and may lead to unexpected or incorrect results.
*   &lt;p&gt;
*   @see java.awt.RenderingHints#KEY_TEXT_ANTIALIASING
*   @see java.awt.RenderingHints#KEY_FRACTIONALMETRICS
*   @see java.awt.Graphics2D#getFontRenderContext
*   @see java.awt.font.LineMetrics
*/

public class FontRenderContext {
    private transient AffineTransform tx;
    private transient boolean bIsAntiAliased;
    private transient boolean bUsesFractionalMetrics;

    /**
     * Constructs a new &lt;code&gt;FontRenderContext&lt;/code&gt;
     * object.
     *
     */
    protected FontRenderContext() {
        this.tx = new AffineTransform();
        this.bIsAntiAliased = false;
        this.bUsesFractionalMetrics = false;
    }

    /**
     * Constructs a &lt;code&gt;FontRenderContext&lt;/code&gt; object from an
     * optional {@link AffineTransform} and two &lt;code&gt;boolean&lt;/code&gt;
     * values that determine if the newly constructed object has
     * anti-aliasing or fractional metrics.
     * @param tx the transform which is used to scale typographical points
     *  to pixels in this &lt;code&gt;FontRenderContext&lt;/code&gt;.  If null, an
     *  identity tranform is used.
     * @param isAntiAliased determines if the newly contructed object has
     * anti-aliasing
     * @param usesFractionalMetrics determines if the newly constructed
     * object uses fractional metrics
     */
    public FontRenderContext(AffineTransform tx,
                            boolean isAntiAliased,
                            boolean usesFractionalMetrics) {
        if (tx == null) {
            this.tx = new AffineTransform();
        }
        else {
            this.tx = new AffineTransform(tx);
        }
        this.bIsAntiAliased = isAntiAliased;
        this.bUsesFractionalMetrics = usesFractionalMetrics;
    }


    /**
    *   Gets the transform that is used to scale typographical points
    *   to pixels in this &lt;code&gt;FontRenderContext&lt;/code&gt;.
    *   @returns the &lt;code&gt;AffineTransform&lt;/code&gt; of this
    *    &lt;code&gt;FontRenderContext&lt;/code&gt;.
    *   @see AffineTransform
    */
    public AffineTransform getTransform() {
        return new AffineTransform(tx);
    }

    /**
    *   Gets the text anti-aliasing mode used in this 
    *   &lt;code&gt;FontRenderContext&lt;/code&gt;.
    *   @returns    &lt;code&gt;true&lt;/code&gt;, if text is anti-aliased in this
    *   &lt;code&gt;FontRenderContext&lt;/code&gt;; &lt;code&gt;false&lt;/code&gt; otherwise.
    *   @see        java.awt.RenderingHints#KEY_TEXT_ANTIALIASING
    */
    public boolean isAntiAliased() {
        return this.bIsAntiAliased;
    }

    /**
    *   Gets the text fractional metrics mode requested by the application
    *   for use in this &lt;code&gt;FontRenderContext&lt;/code&gt;.
    *   @returns    &lt;code&gt;true&lt;/code&gt;, if layout should be performed with
    *   fractional metrics; &lt;code&gt;false&lt;/code&gt; otherwise.
    *               in this &lt;code&gt;FontRenderContext&lt;/code&gt;.
    *   @see java.awt.RenderingHints#KEY_FRACTIONALMETRICS
    */
    public boolean usesFractionalMetrics() {
        return this.bUsesFractionalMetrics;
    }
}
</pre></body></html>