java.awt.font
Class FontRenderContext

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.font.FontRenderContext

public class FontRenderContext
extends Object sample code for java.lang.Object definition code for java.lang.Object

The FontRenderContext 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.

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.

Anti-aliasing and Fractional-metrics specified by an application can also affect the size of a character because of rounding to pixel boundaries.

Typically, instances of FontRenderContext are obtained from a Graphics2D sample code for java.awt.Graphics2D definition code for java.awt.Graphics2D object. A FontRenderContext which is directly constructed will most likely not represent any actual graphics device, and may lead to unexpected or incorrect results.

See Also:
RenderingHints.KEY_TEXT_ANTIALIASING sample code for java.awt.RenderingHints.KEY_TEXT_ANTIALIASING definition code for java.awt.RenderingHints.KEY_TEXT_ANTIALIASING , RenderingHints.KEY_FRACTIONALMETRICS sample code for java.awt.RenderingHints.KEY_FRACTIONALMETRICS definition code for java.awt.RenderingHints.KEY_FRACTIONALMETRICS , Graphics2D.getFontRenderContext() sample code for java.awt.Graphics2D.getFontRenderContext() definition code for java.awt.Graphics2D.getFontRenderContext() , LineMetrics sample code for java.awt.font.LineMetrics definition code for java.awt.font.LineMetrics

Constructor Summary
protected FontRenderContext sample code for java.awt.font.FontRenderContext.FontRenderContext() definition code for java.awt.font.FontRenderContext.FontRenderContext() ()
          Constructs a new FontRenderContext object.
  FontRenderContext sample code for java.awt.font.FontRenderContext.FontRenderContext(java.awt.geom.AffineTransform, boolean, boolean) definition code for java.awt.font.FontRenderContext.FontRenderContext(java.awt.geom.AffineTransform, boolean, boolean) (AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform  tx, boolean isAntiAliased, boolean usesFractionalMetrics)
          Constructs a FontRenderContext object from an optional AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform and two boolean values that determine if the newly constructed object has anti-aliasing or fractional metrics.
 
Method Summary
 boolean equals sample code for java.awt.font.FontRenderContext.equals(java.awt.font.FontRenderContext) definition code for java.awt.font.FontRenderContext.equals(java.awt.font.FontRenderContext) (FontRenderContext sample code for java.awt.font.FontRenderContext definition code for java.awt.font.FontRenderContext  rhs)
          Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.
 boolean equals sample code for java.awt.font.FontRenderContext.equals(java.lang.Object) definition code for java.awt.font.FontRenderContext.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.
 AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform getTransform sample code for java.awt.font.FontRenderContext.getTransform() definition code for java.awt.font.FontRenderContext.getTransform() ()
          Gets the transform that is used to scale typographical points to pixels in this FontRenderContext.
 int hashCode sample code for java.awt.font.FontRenderContext.hashCode() definition code for java.awt.font.FontRenderContext.hashCode() ()
          Return a hashcode for this FontRenderContext.
 boolean isAntiAliased sample code for java.awt.font.FontRenderContext.isAntiAliased() definition code for java.awt.font.FontRenderContext.isAntiAliased() ()
          Gets the text anti-aliasing mode used in this FontRenderContext.
 boolean usesFractionalMetrics sample code for java.awt.font.FontRenderContext.usesFractionalMetrics() definition code for java.awt.font.FontRenderContext.usesFractionalMetrics() ()
          Gets the text fractional metrics mode requested by the application for use in this FontRenderContext.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

FontRenderContext sample code for java.awt.font.FontRenderContext() definition code for java.awt.font.FontRenderContext()

protected FontRenderContext()
Constructs a new FontRenderContext object.


FontRenderContext sample code for java.awt.font.FontRenderContext(java.awt.geom.AffineTransform, boolean, boolean) definition code for java.awt.font.FontRenderContext(java.awt.geom.AffineTransform, boolean, boolean)

public FontRenderContext(AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform  tx,
                         boolean isAntiAliased,
                         boolean usesFractionalMetrics)
Constructs a FontRenderContext object from an optional AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform and two boolean values that determine if the newly constructed object has anti-aliasing or fractional metrics.

Parameters:
tx - the transform which is used to scale typographical points to pixels in this FontRenderContext. If null, an identity tranform is used.
isAntiAliased - determines if the newly contructed object has anti-aliasing
usesFractionalMetrics - determines if the newly constructed object uses fractional metrics
Method Detail

getTransform sample code for java.awt.font.FontRenderContext.getTransform() definition code for java.awt.font.FontRenderContext.getTransform()

public AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform  getTransform()
Gets the transform that is used to scale typographical points to pixels in this FontRenderContext.

Returns:
the AffineTransform of this FontRenderContext.
See Also:
AffineTransform sample code for java.awt.geom.AffineTransform definition code for java.awt.geom.AffineTransform

isAntiAliased sample code for java.awt.font.FontRenderContext.isAntiAliased() definition code for java.awt.font.FontRenderContext.isAntiAliased()

public boolean isAntiAliased()
Gets the text anti-aliasing mode used in this FontRenderContext.

Returns:
true, if text is anti-aliased in this FontRenderContext; false otherwise.
See Also:
RenderingHints.KEY_TEXT_ANTIALIASING sample code for java.awt.RenderingHints.KEY_TEXT_ANTIALIASING definition code for java.awt.RenderingHints.KEY_TEXT_ANTIALIASING

usesFractionalMetrics sample code for java.awt.font.FontRenderContext.usesFractionalMetrics() definition code for java.awt.font.FontRenderContext.usesFractionalMetrics()

public boolean usesFractionalMetrics()
Gets the text fractional metrics mode requested by the application for use in this FontRenderContext.

Returns:
true, if layout should be performed with fractional metrics; false otherwise. in this FontRenderContext.
See Also:
RenderingHints.KEY_FRACTIONALMETRICS sample code for java.awt.RenderingHints.KEY_FRACTIONALMETRICS definition code for java.awt.RenderingHints.KEY_FRACTIONALMETRICS

equals sample code for java.awt.font.FontRenderContext.equals(java.lang.Object) definition code for java.awt.font.FontRenderContext.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the object to test for equality
Returns:
true if the specified object is equal to this FontRenderContext; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

equals sample code for java.awt.font.FontRenderContext.equals(java.awt.font.FontRenderContext) definition code for java.awt.font.FontRenderContext.equals(java.awt.font.FontRenderContext)

public boolean equals(FontRenderContext sample code for java.awt.font.FontRenderContext definition code for java.awt.font.FontRenderContext  rhs)
Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.

Parameters:
rhs - the FontRenderContext to test for equality
Returns:
true if rhs is equal to this FontRenderContext; false otherwise.

hashCode sample code for java.awt.font.FontRenderContext.hashCode() definition code for java.awt.font.FontRenderContext.hashCode()

public int hashCode()
Return a hashcode for this FontRenderContext.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable