Font
class
were introduced for canonical family names of the logical fonts:
DIALOG
DIALOG_INPUT
SANS_SERIF
SERIF
MONOSPACED
getFontRenderContext()
method added to the FontMetrics
class to create a FontRenderContext
object according
to the current hints and to measure text through the
application.registerFont(Font font)
method of the
GraphicsEnvironment
class that enables you to register
a font created by using the Font.createFont(int,
java.io.InputStream)
method, or derived from a created font
by using the Font.deriveFont(int,
float)
method. If registration is successful, the
registerFont
method returns true
. The
false value
returned by the method means that the font
you are trying to register is not a created font, or conflicts with
a non-registered font already registered in this
GraphicsEnvironment
object.java.awt.font.FontRenderContext
class was
introduced to create a FontRenderContext
object with a
specific antialiasing rendering hint or fractional rendering hint.
The following methods were added to reflect the new functionality
in Java SE 6.0:
isTransformed()
— To indicate that the
FontRenderContext
object measures text in a
transformed render context.getTransformType()
— To get the integer type
of the affine transform.getAntiAliasingHint()
— To obtain the text
anti-aliasing rendering mode hint that can be applied to the
FontRenderContext
object.getFractionalMetricsHint()
— To obtain the
text fractional metrics rendering mode hint that can be applied to
the FontRenderContext
object.getPixelBounds()
— To get the pixel bounds
of a TextLayout
object. This method returns a
Rectangle
object defining the pixel bounds that are
affected.Graphics
object.
New text antialiasing methods optimized for LCD displays were
added. They are enabled by default on some systems and can be
controlled using corresponding keys and values defined in the
RenderingHints
class.getOutline(AffineTransform)
method of
the TextLayout
class from earlier versions of JDK, the
new
getOutline
method of the
GraphicAttribute
class enables you to get a Shape
object
representing the region that the GraphicAttribute
object renders. The
getOutline
method of the
ShapeGraphicAttribute
class overrides its counterpart
method in the GraphicsAttribute
class to get the
outline for the region that the ShapeGraphicAttribute
object renders.LayoutPath
class provides mapping between Point2D
locations
relative to the baseline and points in user space. Two methods of
this class enable bidirectional mapping: a location to a point in
the user coordinates and, conversely, a point in the user
coordinates to a location. The getLayoutPath()
method was added to the TextLayout
class to obtain the
layout path of the TextLayout
object.TextAttribute
class to enhance font visualization. The KERNING
attribute enables you to request the integer kerning value to make
the visual appearance of characters more pleasing. The
KERNING_ON
constant requests that the text be rendered
such that spacing between glyphs is adjusted according to kerning
pairs specified by fonts. Using the constant
LIGATURES_ON
value of the LIGATURES
attribute requests that optional ligatures specified by the font
should be applied. The TRACKING
attribute is used to
control how closely or loosely the glyphs are spaced. For example,
the TRACKING_LOOSE
constant allocates and distributes
extra space between each glyph.BufferStrategy
classdispose()
method was added to the java.awt.image.BufferStrategy
class to improve system resources management. The new method
releases system resources consumed by the
BufferStrategy
object. Additionally, the method
removes this BufferStrategy
object from the associated
Component
instance.AlphaComposite
class to obtain an AlphaComposite
object that uses the
specified compositing rule or the alpha
value:
public AlphaComposite derive(int rule)
public AlphaComposite derive(float alpha)
The two methods enable developers to code various compositing
effects and avoid more complex usage of the
getInstance
method.
Composite alpha0 = null, alpha1 = null; alpha0 = AlphaComposite.SrcOver.derive(alpha); alpha1 = AlphaComposite.SrcOver.derive(1-alpha)
LinearGradientPaint
and RadialGradientPaint
classes that extend the MultipleGradientPaint
class
fill a Shape
object with the particular color gradient
pattern. The
MultipleGradientPaint.CycleMethod
enum is used to handle
painting outside gradient bounds by disabling
(CycleMethod.NO_CYCLE
), reflecting
(CycleMethod.REFLECT
), or repeating
(CycleMethod.REPEAT
) painting.Point2D start = new Point2D.Float(0, 0); Point2D end = new Point2D.Float(100, 100); float[] dist = {0.0f, 0.2f, 1.0f}; Color[] colors = {Color.BLACK, Color.WHITE, Color.GRAY}; LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors, CycleMethod.REFLECT);
AffineTransform
class to support the new functionality:public static AffineTransform
getRotateInstance(double vecx, double vecy)
public static AffineTransform
getRotateInstance(double vecx, double vecy,
double anchorx, double anchory)
public static AffineTransform
getQuadrantRotateInstance(int numquadrants)
public static AffineTransform
getQuadrantRotateInstance(int numquadrants,
double anchorx, double anchory)
public void rotate(double vecx,
double vecy)
public void rotate(double vecx, double vecy,
double anchorx, double anchory)
public void
quadrantRotate(int numquadrants)
public void quadrantRotate(int numquadrants,
double anchorx, double anchory)
public void setToRotation(double vecx,
double vecy)
public void setToRotation(double vecx,
double vecy, double anchorx,
double anchory
setToQuadrantRotation(int numquadrants)
method enables rotation by the specified number of quadrants. Its
counterpart rotates coordinates by the specified number of
quadrants around the specified anchor point.AffineTransform
class improves
inverse transformation capabilities. While the
createInverse
method appeared in Java SE 1.2 and
transformed a shape's coordinates back to their original locations,
the new invert()
method enables setting the current transform to the inverse state
of itself.GeneralPath
classGeneralPath
class. The Path2D
class represents a path that can be iterated by the PathIterator
interface and has two subclasses: Path2D.Float
and Path2D.Double
.
In the changed hierarchy, the GeneralPath
class became
a subclass of the Path2D.Float
class. They both can be
used for single point precision, while the
Path2D.Double
class can be applied for double point
precision. One reason to use the Path2D.Float
class
over the GeneralPath
class is to make your code more
consistence and explicit if both single and double precision types
are employed in the application.hashCode()
and equals()
methods in shape classesRectangle2D
class has contained the
hashCode()
and equals()
methods, while
the other subclasses of the RectangularShape
class
lacked the same functionality. JDK 6.0 fills this gap by adding the
hashCode()
and equals()
method to the
Arc2D
,
Ellipse2D
,
and RoundRectangle2D
classes.PrinterJob
classgetPageFormat
method was added to the JDK 6.0 as a
convenience method to more easily convert from a description of a
page using attributes to a PageFormat
object.A separate pipeline was developed for drawing cubic and quad Bezier curves, where an adaptive forward differencing was applied. This approach noticeably improves quality and speeds up Bezier curve drawing.
The Microsoft Sans serif font glyph looked broken due to the current implementation of scan conversion algorithms. The smart dropout mechanism is added as part of the fix for the 6282527 bug.
The VM crash appeared as a stomp over memory in the Java heap as if code had gone off the end of an array. The fix checks the dimensions in the image representation code when the first portion of image is gotten. If the dimensions do not match, the internal buffered image is recreated.
ColorSpace
supplied to a ColorConvertOp
instance are the same:If the source and destination ColorSpace
objects
supplied to a ColorConvertOp
instance were the same,
pixel values were different between the color converted destination
and the original source. This bug is fixed by updating the sRGB
profile and creating fast track (without any color transforms).
Truetype hinting was designed with the assumption that the orientation of glyphs regarding pixel grids would be fixed. That is why truetype hinting did not support complex affine transforms such as rotation, or shear, and scale transforms. As a fix the following approaches are implemented:
PrintService
object without a
name crashes the JVM:PrintService
object was set without a name (the
getName()
methods return null
) then the
JVM crashed. The problem was caused by the specific user's
implementation: the PrintService
interface had the
getName()
function that returned null and this null
value was passed to the native function
setNativePrintService
.
IndexColorModel
images with a
transparent pixel may fail on Windows:Printing an image with bitmask transparency was sometimes incorrect on the Windows platform. A problem existed with the bitmask transparency case. Printing code handled the bitmask transparency as multiple smaller sub images of the original image. The fix includes the simplest and least risky solution: always creating a copy of an image.
Type1
hinting support is missed :Before JDK 6 the java font rasterizer only supported hinting for Truetype fonts. However, Type1 fonts were commonplace on Solaris and Linux platforms and they often did not look very customary without hinting. To support the type1 hints the functionality is implemented:
Truetype hinting was designed without support for arbitrary transforms. To overcome this limitation, hints are applied with a "safe" identity matrix and then with a transform hinted outline when non-trival transform is requested. The problem was resolved as a part of the fix for 4654540.
The code to transform images used an image processing library to perform the operation. This approach required at least one intermediate buffer to be created for each transform operation. The new code enables you to transform any of the internally handled formats and composite to any of the internally handled formats in one operation with only a minimal stack-allocated one-line pixel buffer.
On Windows Vista, the use of DirectDraw
for
hardware acceleration is currently disabled by default because of
incompatibilities with Vista's Desktop Window Manager.
The -Dsun.java2d.noddraw=false
property can be used
to re-enable the use of the DirectDraw
pipeline.
However, this is not recommended due to rendering artifacts and
performance problems. To also enable the Direct3D
pipeline, a combination of the aforementioned flag and
-Dsun.java2d.d3d=true
should be used.