The information on these pages may be out of date, or may refer to
resources that have moved or have been made read-only.
For more information please refer to the Apache Attic
|Initial version||Alexey Petrenko, Svetlana Konovalova: document created.||May 18, 2006|
|Formatting update||Nadya Morozova||September 21, 2006|
This document introduces the Java 2D*  implementation, supplied as part of the DRL (Dynamic Runtime Layer) initiative, and gives details on its design.
The target audience for the document includes a wide community of engineers interested in using Java 2D* and in further work with the product to contribute to its development. The document assumes that readers are familiar with the Java 2D* technology and the Java* programming language.
This document uses the unified conventions for the DRL documentation kit.
The Java 2D* implementation is the collection of classes for a high-performance two-dimensional (2D) graphics and image processing. The package includes line and shape drawing, text and image rendering.
DRL Java 2D* is a fast and easily portable implementation of the Java 2D* technology, consisting of a number of classes for advanced graphics and image processing.
DRL Java 2D* supports the Windows* and Linux* operating systems for the IA-32 architecture. The Windows* version mostly uses the GDI+ (Graphics Device Interface plus) library, but can also use the GDI library for better performance. For example, Java 2D* can use GDI instead of GDI+ to speed up image processing. The Linux* version uses Xlib and xft libraries.
DRL Java 2D* has portability in its design, so that you can easily port it to other operating systems and hardware architectures. For details and how to port Java 2D* on other platforms see Java 2D* Portability.
Figure 1 below shows the Java 2D* structure,
demonstrating the inheritance relationship of the
Figure 1: Inheritance Relationship of the
java.awt.Graphics2Ddefine the public interface for all
org.apache.harmony.awt.gl.linux.XGraphics2Dare the Windows* and Linux* versions respectively of the
org.apache.harmony.awt.gl.CommonGraphics2Dclass, which implements the abstract methods of the
org.apache.harmony.awt.gl.image.BufferedImageGraphics2Dclass deals with drawing on buffered images.
For more information on the classes see Platform Specifics in DRL Java 2D* Graphics.
The section specifies the
CommonGraphics2D class internal
areas and gives description on their tools.
CommonGraphics2D class splits all shapes into a set
of rectangles to unify the drawing process for different operating
systems and architectures. For this purpose Java 2D*
JavaShapeRasterizer and the
JavaLineRasterizer classes from the
org.apache.harmony.awt.gl.render package. The
JavaShapeRasterizer class splits an object implementing a
Shape interface into a set of rectangles and produces a MultiRectArea
JavaLineRasterizer class makes line drawing
more accurate and processes lines with strokes, which are instances of
the BasicStroke class.
To port the shape drawing to another platform you just need to
override rectangle-drawing methods. However, if your operating system
has functions to draw particular shapes, you can optimize your
subclass of the
CommonGraphics2D class by using this
functionality in overridden methods.
Blitter classes draw images on the display or buffered images. All
blitters inherit the
Blitters are divided into:
DRL Java 2D* also uses blitters to fill the shapes
and the user-defined subclasses of the
class with paints, which the system does not support.
Text renderers draw strings and glyph vectors. All text renderers are
subclasses of the
Java 2D* does not have its own font rendering engine
and uses native libraries instead: the GDI library on the Windows* OS and the Xft, FontConfig and FreeType libraries on
the Linux* OS. The
java.awt.font.NumericShaper class uses data from the
Unicode Character Database  for retrieving character
The Windows* implementation - the
WinGDIPGraphics2D class - for the most part is based on
the GDI+ library, which has the routines for drawing all types of
shapes filling them with a solid color brush and a linear gradient
brush, but it does not support an acyclic gradient brush. The Java
2D* package doesn't use the native library texture
paint option, resorting to Blitters instead.
However, the major part of the shape drawing and filling routines is
native in this class.
As for the Linux* implementation - the
XGraphics2D class - the Xlib library has no methods to
draw and fill free-form shapes. So, the corresponding
XGraphics2D methods use Rasterizers, inherited from the
The actions to port the DRL Java 2D* package to another architecture or operating system, or to use it with another library depend on the particular platform. The main steps are the following:
 Java 2D* Technology http://java.sun.com/j2se/1.5.0/docs/guide/2d/index.html
 Unicode Character Database http://www.unicode.org/ucd/
* Other brands and names are the property of their respective owners.