★ wanayoo — archive 1999 http://developer.java.sun.com/developer/technicalArticles/Media/2DGraphics/index.htmlNouvelle recherche | Portail wanayoo
Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Technical Articles

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 
Articles Index

Java 2D Graphics: A First Look

Lisa Stapleton, JavaSoft

The way people work with 2D images will soon change dramatically. The product isn't yet released, but according to Jim Graham, the architect of the new 2D API, the changes will include the following features:

  • The new standard color space is SRGB, which is an emerging Web-based standard that replaces the old RGB standard. "If you have an ICC profile, we have an object that turns it into a color space," says Graham.

  • Fonts now consist of font objects, which in turn consist of an actual system font plus attributes.

  • Now, most extended capabilities are done through objects. For example, to install a gradient fill, an object implements providing a color source in a gradient pattern, and you install that object in a graphics class. "Everything is provided through graphics subclassing, and you can customize it at will," says Graham.

  • For rendering, you'll be able to use extensible paths. These paths can include any kind of primitive you want because the path is an interface. Extensible coordinate transformations are also provided, including a Bezier path. JavaSoft is now working with Taligent to provide a way to do path logic, which would mean that you could better deal with objects in front of other objects, or objects intersecting with other objects.

  • Extensible stroke shape and fill patterns will let you achieve the look of the "paint" you want. The new screen compositing rules control how colors get merged onto the display.

  • You'll also now have direct access to pixels. Gone is the old image producer/consumer interface and the awkward utility classes to work around the difficulties of the old interface.

  • You can access many features of TrueType and TypeOne fonts. More filters are provided, and storage layouts are more flexible. You can now use a Unicode bi-directional layout bundle within a string. You can also refer directly to glyphs through the interface. Color space and color management are also supported.

  • There's also a new subclass of the graphics object called graphics2D, which adds new methods to control 2D attributes. For instance, using drawPath and fillPath, have access to many more primitives than just the old rectangles and ellipses.

  • Pipeline objects. The new API also has a number of new objects and features. For instance, if you draw a path, the 2D API uses strokeobject to convert the trajectory of a path into a fillable outline. Another object controls how to take that user space outline and transform it into device space. Then paintObject controls what colors are placed in that outline. Finally, a composite object controls how colors merge onto the screen. Programmers can, however, replace any part of that pipeline.

  • For rendering paths, there is now an interface called path, and there's a common-denominator called bezierPath, which implements a path and consists of lines and beziers. "The path can be anything you want," says Graham, "it just has to convert itself down into a Bezier path, and then the rest of the system can deal with it."

  • For 2D-to-2D coordinate transforms, you can translate scale, rotate, and skew.

  • The paint interface lets you define an arbitrary complex fill pattern. Then, there are classes that implement this gradient, and support tiling over an image of the area to be filled. The colorObject is now simply an object that implements paint.

  • By using a buffered image object, you can now get directly at pixels. There are also classes for the control of data layout. You can lay out an image packed in bits, and you can use multiple pixels per byte, int, or short. You can use up to eight 16-bit components, or 32-bits-per-component image layout.

  • There are now discrete channels, which represent storage of the data for the image and refer to different color components. These channels are combined into tiles. You can then combine a tile with a color model that says how to convert those color components into a recognizable color. When you've finished these things, you have a buffered image. (There will be filters to operate on tiles or buffered images. If your work involves manipulating color, you have to use buffered images; if you're doing some other kind of transformation, such as a look-up table, you can also operate on the tiles themselves. There's a buffered-image filter adapter that gives you compatibility with the older consumer/producer model.) A buffered image extends the existing java.awt.image, and when you do getGraphics on a buffered image, you get a 2D image. "A lot of people wonder whether two calls to getGraphics will cause them to run into thread problems," says Graham. "But it's always been multitasking, and it returns a new object every time. It really is more of a creation operation, rather than a get," he says.

The 2D Graphics API is expected this summer.


[ This page was updated: 31-Jan-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.