Apache Harmony is retired at the Apache Software Foundation since Nov 16, 2011.

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

DRL Java 2D*

DRL Java 2D*

  1. Revision History
  2. About This Document
    1. Purpose
    2. Intended Audience
    3. Documentation Conventions
  3. Introduction to Java 2D*
  4. Java 2D* in DRL
    1. About
    2. Architecture Overview
    3. Class Relationship
    4. CommonGraphics2D Class Internals
    5. Platform Specifics in DRL Java 2D* Graphics
    6. Java 2D* Portability
  5. References

Revision History

Version Version Information Date
Initial version Alexey Petrenko, Svetlana Konovalova: document created. May 18, 2006
Formatting update Nadya Morozova September 21, 2006

About This Document

Purpose

This document introduces the Java 2D* [1] implementation, supplied as part of the DRL (Dynamic Runtime Layer) initiative, and gives details on its design.

Intended Audience

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.

Documentation Conventions

This document uses the unified conventions for the DRL documentation kit.

Back to Top

Introduction to Java 2D*

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.

Back to Top

Java 2D* in DRL

About

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.

Back to Top

Architecture Overview

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.

Back to Top

Class Relationship

Figure 1 below shows the Java 2D* structure, demonstrating the inheritance relationship of the Graphics2D classes:

Class Hierarchy diagram

Figure 1: Inheritance Relationship of the Graphics2D Classes

For more information on the classes see Platform Specifics in DRL Java 2D* Graphics.

Back to Top

CommonGraphics2D Class Internals

The section specifies the CommonGraphics2D class internal areas and gives description on their tools.

Line and Shape Rasterizers

The 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* uses the 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 object. The 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.

Blitters

Blitter classes draw images on the display or buffered images. All blitters inherit the org.apache.harmony.awt.gl.render.Blitter interface.

Blitters are divided into:

DRL Java 2D* also uses blitters to fill the shapes and the user-defined subclasses of the java.awt.Paint class with paints, which the system does not support.

Text Renderers

Text renderers draw strings and glyph vectors. All text renderers are subclasses of the org.apache.harmony.awt.gl.TextRenderer class.

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 [2] for retrieving character properties.

Back to Top

Platform Specifics in DRL Java 2D* Graphics

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 CommonGraphics2D class.

Back to Top

Java 2D* Portability

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:

Back to Top

References

[1] Java 2D* Technology http://java.sun.com/j2se/1.5.0/docs/guide/2d/index.html

[2] Unicode Character Database http://www.unicode.org/ucd/

Back to Top

* Other brands and names are the property of their respective owners.