- java.lang.Object
-
- java.awt.font.FontRenderContext
-
public class FontRenderContext extends Object
TheFontRenderContext
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 aGraphics2D
object. AFontRenderContext
which is directly constructed will most likely not represent any actual graphics device, and may lead to unexpected or incorrect results.
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
FontRenderContext()
Constructs a newFontRenderContext
object.FontRenderContext(AffineTransform tx, boolean isAntiAliased, boolean usesFractionalMetrics)
Constructs aFontRenderContext
object from an optionalAffineTransform
and twoboolean
values that determine if the newly constructed object has anti-aliasing or fractional metrics.FontRenderContext(AffineTransform tx, Object aaHint, Object fmHint)
Constructs aFontRenderContext
object from an optionalAffineTransform
and twoObject
values that determine if the newly constructed object has anti-aliasing or fractional metrics.
-
Method Summary
Methods Modifier and Type Method and Description boolean
equals(FontRenderContext rhs)
Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.boolean
equals(Object obj)
Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.Object
getAntiAliasingHint()
Return the text anti-aliasing rendering mode hint used in thisFontRenderContext
.Object
getFractionalMetricsHint()
Return the text fractional metrics rendering mode hint used in thisFontRenderContext
.AffineTransform
getTransform()
Gets the transform that is used to scale typographical points to pixels in thisFontRenderContext
.int
getTransformType()
Returns the integer type of the affine transform for thisFontRenderContext
as specified byAffineTransform.getType()
int
hashCode()
Return a hashcode for this FontRenderContext.boolean
isAntiAliased()
Returns a boolean which indicates whether or not some form of antialiasing is specified by thisFontRenderContext
.boolean
isTransformed()
Indicates whether or not thisFontRenderContext
object measures text in a transformed render context.boolean
usesFractionalMetrics()
Returns a boolean which whether text fractional metrics mode is used in thisFontRenderContext
.
-
-
-
Constructor Detail
-
FontRenderContext
protected FontRenderContext()
Constructs a newFontRenderContext
object.
-
FontRenderContext
public FontRenderContext(AffineTransform tx, boolean isAntiAliased, boolean usesFractionalMetrics)
Constructs aFontRenderContext
object from an optionalAffineTransform
and twoboolean
values that determine if the newly constructed object has anti-aliasing or fractional metrics. In each case the boolean valuestrue
andfalse
correspond to the rendering hint valuesON
andOFF
respectively.To specify other hint values, use the constructor which specifies the rendering hint values as parameters :
FontRenderContext(AffineTransform, Object, Object)
.- Parameters:
tx
- the transform which is used to scale typographical points to pixels in thisFontRenderContext
. If null, an identity transform is used.isAntiAliased
- determines if the newly constructed object has anti-aliasing.usesFractionalMetrics
- determines if the newly constructed object has fractional metrics.
-
FontRenderContext
public FontRenderContext(AffineTransform tx, Object aaHint, Object fmHint)
Constructs aFontRenderContext
object from an optionalAffineTransform
and twoObject
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 thisFontRenderContext
. If null, an identity tranform is used.aaHint
- - one of the text antialiasing rendering hint values defined injava.awt.RenderingHints
. Any other value will throwIllegalArgumentException
.VALUE_TEXT_ANTIALIAS_DEFAULT
may be specified, in which case the mode used is implementation dependent.fmHint
- - one of the text fractional rendering hint values defined injava.awt.RenderingHints
.VALUE_FRACTIONALMETRICS_DEFAULT
may be specified, in which case the mode used is implementation dependent. Any other value will throwIllegalArgumentException
- Throws:
IllegalArgumentException
- if the hints are not one of the legal values.- Since:
- 1.6
-
-
Method Detail
-
isTransformed
public boolean isTransformed()
Indicates whether or not thisFontRenderContext
object measures text in a transformed render context.- Returns:
true
if thisFontRenderContext
object has a non-identity AffineTransform attribute.false
otherwise.- Since:
- 1.6
- See Also:
getTransform()
-
getTransformType
public int getTransformType()
Returns the integer type of the affine transform for thisFontRenderContext
as specified byAffineTransform.getType()
- Returns:
- the type of the transform.
- Since:
- 1.6
- See Also:
AffineTransform
-
getTransform
public AffineTransform getTransform()
Gets the transform that is used to scale typographical points to pixels in thisFontRenderContext
.- Returns:
- the
AffineTransform
of thisFontRenderContext
. - See Also:
AffineTransform
-
isAntiAliased
public boolean isAntiAliased()
Returns a boolean which indicates whether or not some form of antialiasing is specified by thisFontRenderContext
. CallgetAntiAliasingHint()
for the specific rendering hint value.- Returns:
true
, if text is anti-aliased in thisFontRenderContext
;false
otherwise.- See Also:
RenderingHints.KEY_TEXT_ANTIALIASING
,FontRenderContext(AffineTransform,boolean,boolean)
,FontRenderContext(AffineTransform,Object,Object)
-
usesFractionalMetrics
public boolean usesFractionalMetrics()
Returns a boolean which whether text fractional metrics mode is used in thisFontRenderContext
. CallgetFractionalMetricsHint()
to obtain the corresponding rendering hint value.- Returns:
true
, if layout should be performed with fractional metrics;false
otherwise. in thisFontRenderContext
.- See Also:
RenderingHints.KEY_FRACTIONALMETRICS
,FontRenderContext(AffineTransform,boolean,boolean)
,FontRenderContext(AffineTransform,Object,Object)
-
getAntiAliasingHint
public Object getAntiAliasingHint()
Return the text anti-aliasing rendering mode hint used in thisFontRenderContext
. This will be one of the text antialiasing rendering hint values defined injava.awt.RenderingHints
.- Returns:
- text anti-aliasing rendering mode hint used in this
FontRenderContext
. - Since:
- 1.6
-
getFractionalMetricsHint
public Object getFractionalMetricsHint()
Return the text fractional metrics rendering mode hint used in thisFontRenderContext
. This will be one of the text fractional metrics rendering hint values defined injava.awt.RenderingHints
.- Returns:
- the text fractional metrics rendering mode hint used in this
FontRenderContext
. - Since:
- 1.6
-
equals
public boolean equals(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
in classObject
- Parameters:
obj
- the object to test for equality- Returns:
true
if the specified object is equal to thisFontRenderContext
;false
otherwise.- See Also:
Object.hashCode()
,HashMap
-
equals
public boolean equals(FontRenderContext rhs)
Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.- Parameters:
rhs
- theFontRenderContext
to test for equality- Returns:
true
ifrhs
is equal to thisFontRenderContext
;false
otherwise.- Since:
- 1.4
-
hashCode
public int hashCode()
Return a hashcode for this FontRenderContext.- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/12/2024 10:22:42 Cette version de la page est en cache (à la date du 22/12/2024 10:22:42) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 25/07/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/awt/font/FontRenderContext.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.