| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/Java2D |
| Contents |
|---|
| Filling |
| Advanced objects |
| Transform |
| Stroke |
| Optimizations |
Java 2D is an API for drawing two-dimensional graphics using the Java programming language. Every Java 2D drawing operation can ultimately be treated as filling a shape using a paint and compositing the result onto the screen.The Java 2D is a set of classes for advanced 2D graphics and imaging. It encompasses line art, text, and images in a single comprehensive model. The API provides extensive support for image compositing and alpha channel images, a set of classes to provide accurate color space definition and conversion, and a rich set of display-oriented imaging operators.
java.awt.geom The Java standard library of two dimensional geometric shapes such as lines, ellipses, and quadrilaterals.To fill a shape, the first step is to identify which pixels fall inside the shape. These pixels will be affected by the fill operation. Pixels that are partially inside and partially outside the shape may be affected to a lesser degree if anti-aliasing is enabled.
The paint is then asked to generate a color for each of the pixels to be painted. In the common case of a solid-color fill, each pixel will be set to the same color.
The composite takes the pixels generated by the paint and combines them with the pixels already onscreen to produce the final result.
These objects can be viewed as performing their duties in terms of the simpler objects described above.
Every Java 2D operation is subject to a transform, so that shapes may be translated, rotated, sheared, and scaled as they are drawn. The active transform is most often the identity transform, which does nothing.
Filling using a transform can be viewed as simply creating a new, transformed shape and then filling that shape.
In addition to the fill operation, Java 2D provides a draw operation. While fill draws the interior of a shape, draw draws its outline. The outline can be as simple as a thin line, or as complicated as a dashed line with each dash having rounded edges.
The object responsible for generating the outline is the stroke. Given an input shape, the stroke produces a new shape representing its outline. For instance, an infinitely thin line segment (with no interior) might be stroked into a one-pixel-wide rectangle.
A draw operation can therefore be described as creating a new, stroked object and then filling that object.
Technically speaking, the stroke is only required to accept an input shape and produce a new shape. The stroke implementation provided with Java 2D implements the outline rules described above, but a custom-written stroke could produce any shape it wished.
Conceptually, drawing a straight black line in Java 2D can be thought of as creating a line segment, transforming it according to the current transform, stroking it to create a thin rectangle, querying this shape to compute the pixels being affected, generating the pixels using
| View original on Wikipedia | Back | FazBrowse Home |