1 TinyLine 2D Overview
1.1 Introduction
TinyLine 2D implements a mobile 2D graphics engine for J2ME
platform (CLDC and CDC). TinyLine 2D handles basic shapes, paths,
texts, outlined fonts and images in a uniform way. The TinyLine 2D
provides access to powerful features such as transparency, path-based
drawing, offscreen rendering, advanced color management, antialiased
rendering.
Being pure CLDC 1.0 based, TinyLine 2D provides the unified 2D graphics
engine for a vast variety of Java platforms and profiles.
As a result, developers are easily able to incorporate high quality,
scalable and platform-independent graphics into their Java applications
across Java profiles from CLDC /MIDP2.0, CDC/Personal Java to J2SE.
1.2 Key features
-
Small footprint
-
Fast fixed-point numbers mathematics
-
Paths, basic shapes and texts drawings
-
Hit tests for paths and texts
-
Solid color, bitmap, pattern, gradient (radial and linear) paints
-
Fill, stroke and dash
-
Affine transformations
-
Outline fonts
-
Left-to-right, right-to-left and vertical text layouts
-
Antialiasing
-
Opacity
1.3 The TinyLine 2D API
These classes define basic 2D graphics concepts like color, transformation, point, path, etc.
Package com.tinyline.tiny2d
| Tiny2D |
The Tiny2D defines a graphics context that allows an application to draw shapes, images and texts onto a TinyBuffer object. |
| TinyBuffer |
The TinyBuffer class represents a rectangular array of pixels. |
| TinyColor |
The TinyColor class defines colors in the ARGB color space. |
| TinyPaint |
The TinyPaint class defines paint servers in the ARGB color space. |
| TinyFont |
The TinyFont class defines a collection of glyphs together with the information necessary to use those glyphs. |
| TinyMatrix |
The TinyMatrix class represents a 2D affine transformation matrix. |
| TinyPath |
The TinyPath class represents a geometric path constructed from straight lines, and quadratic and cubic (Bezier) curves. |
| TinyPoint |
The TinyPoint class specifies a point representing a location in (x, y) coordinate space specified in fixed point precision. |
| TinyProducer |
The TinyProducer interface provides an interface for objects which can produce the image data from the TinyBuffer object (pixels buffer). |
| TinyRect |
The TinyRect class specifies an area in a coordinate space that is enclosed by the TinyRect object's top-left point (xmin, ymin ) and down-right point (xmax, ymax ) in the coordinate space. |
| TinyState |
A TinyState object encapsulates state information needed for the basic rendering operations. |
These convenience classes define basic data types, data structures and utilities.
| TinyHash |
The TinyHash class implements a hashtable, which maps keys to values. |
| TinyNumber |
The TinyNumber class wraps a value of the (double) fixed point type in an object. |
| TinyString |
The TinyString class represents character strings. |
| TinyVector |
The TinyVector class implements a growable array of objects. |
Package com.tinyline.util
| TinyInputStream |
A data input stream lets an application read primitive TinyLine 2D data types from an input stream. |
1.4 Drawing pipeline
The TinyLine 2D drawing pipeline has four components:
Tiny2D,
TinyState ,
TinyBuffer and
TinyProducer.
The TinyLine 2D rendering process is controlled through the
Tiny2D object and its state attributes.
The Tiny2D state attributes, such as line styles and transformations
are applied to graphic objects when they are rendered.
The collection of state attributes associated with
a Tiny2D is referred to as the graphics state
TinyState .
The basic drawing process is the same for any graphics element:
1. Specify the target surface TinyBuffer.
2. Specify the appropriate attributes for the graphics by setting the graphics
state attributes in the TinyState object.
3. Define the shape or text you want to draw.
3. Use the Tiny2D object to
render the shape, paths or text, by calling one of
the Tiny2D rendering methods.
During the rasterization, the Tiny2D object reads
the graphics state attributes TinyState and
applies them to the drawing process of the graphics primitives.
The rasterization target is
the TinyBuffer object (also named as "canvas")
where all is drawn. When the drawing process has completed
the TinyProducer is notified that new pixels
on the TinyBuffer "canvas" are ready to be send
onto a device screen.
1.5 The painters model
TinyLine 2D uses the painter's model for its imaging.
In the painter's model, each successive drawing operation
applies a layer of "paint" to an output
"canvas" - TinyBuffer object.
The paint on the pixels buffer (TinyBuffer object)
can be modified by overlaying more paint through additional
drawing operations. This model allows you to construct
sophisticated images from a small number of primitives.
When the paint is not completely opaque the result on the pixels
buffer is defined by the (mathematical) rules of the simple alpha blending.
1.6 Coordinate spaces
TinyLine 2D supports three coordinate spaces: character space,
user space and device space. Transformations between coordinate spaces
are defined by transformation matrices, which can specify any linear
mapping of two-dimensional coordinates.
1.7 Graphics elements
TinyLine 2D supports two basic types of graphics elements that can be
rendered onto the TinyBuffer object:
- Shapes, which represent some combination of straight line and curves
- Text, which represents some combination of character glyphs
As about raster images, a raster image is presented via
the TinyColor class as array of values
that specify the paint color and opacity (alpha).
Shapes and text can be filled and stroked. Each fill and stroke operation
has its own opacity settings; thus, you can fill and/or stroke a shape with a
semi-transparently drawn solid color, with different opacity values for
the fill and stroke operations.
1.8 Text and fonts
In TinyLine 2D texts are rendered just like shapes. Therefore, coordinate
system transformations, painting - all TinyState graphics
state attributes apply to text in the same way as they apply to shapes or paths.
Additional text attributes include such things like the writing direction
(text layout), font specification (TinyFont) and
painting attributes which describe how exactly to render the characters.
The TinyFont class includes the information
necessary to map characters to glyphs, to determine the size of glyph areas and
to position the glyph area.
1.9 Colors
TinyLine 2D supports the following built-in types of paint that can be used in
fill and stroke operations using the ARGB color space:
- Single color
- Gradients (linear and radial)
- Patterns (raster images)
1.10 TinyLine 2D Examples
TinyLine 2D comes with the following examples:
| Name |
Description |
| Alias.java |
The Alias shows how to draw an oval with anti-aliasing and without it. |
| Beziers.java |
The Beziers is an animated bezier curve. It shows how to change
the TinyPath geometry and update only part of the screen. |
| Colors.java |
The Colors shows how to draw with a single ARGB color. |
| Dash.java |
The Dash shows how to draw lines with different line dash patterns. |
| FillAlpha.java |
The FillAlpha shows how to set the opacity of the fill drawing operation. |
| FillRule.java |
The FillRule draws paths with different fillRule values. |
| GAlpha.java |
The GAlpha shows how to set the opacity of all painting operations. |
| Gradients.java |
The Gradients shows how to draw with gradients colors. |
| HitPath.java |
The HitPath shows how to use hitPath function of the Tiny2D. It allows the user to move the path around. |
| HitText.java |
The HitText shows how to use hitPath function of the Tiny2D. It allows the user to move the text around. |
| LineCap.java |
The LineCap shows how to draw lines with different line cap styles. |
| LineJoin.java |
The LineJoin shows how to specify line join styles. |
| Lines.java |
The Lines shows how to draw lines. |
| Ovals.java |
The Ovals shows how to draw ovals. |
| Paths.java |
The Paths draws paths. |
| Patterns.java |
The Patterns shows how to draw with patterns (bitmaps) colors. Also, it shows how to draw on different targets and store and restore the graphics state object. |
| Polys.java |
The Polys draws polygons and polylines. |
| TextLines.java |
The TextLines shows how to draw text in different directions.
Also, it demonstrates how to line-break and draw a paragraph of text. |
| Transform.java |
The Transform shows how to change the current transformation matrix. |
|