|
TinyLine v2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tinyline.tiny2d.Tiny2D
The Tiny2D defines a graphics context that allows
an application to draw shapes, images and texts onto a
target surface TinyBuffer using the current graphics
state TinyState.
| Method | Description |
drawPath(com.tinyline.tiny2d.TinyPath, com.tinyline.tiny2d.TinyRect, com.tinyline.tiny2d.TinyMatrix) |
Draws the outline of the specified TinyPath. |
drawLine(int, int, int, int) |
Draws a line between the points (x1, y1) and (x2, y2) |
drawRect(int, int, int, int) |
Draws the outline of the specified rectangle. |
drawRoundRect(int, int, int, int, int, int) |
Draws an outlined round-cornered rectangle. |
drawOval(int, int, int, int) |
Draws the outline of an oval. |
drawPolyline(com.tinyline.tiny2d.TinyVector) |
Draws a sequence of connected lines defined by a vector of points. |
drawPolygon(com.tinyline.tiny2d.TinyVector) |
Draws a closed polygon defined by vector of points. |
drawChars(com.tinyline.tiny2d.TinyFont, int, char[], int, int, int, int, int) |
Draws the outline of a character array. |
TinyLine supports 3 coordinate spaces: CHARACTER SPACE, USER SPACE and DEVICE SPACE.
Characters in a TinyFont are defined in CHARACTER SPACE.
The transformation from character space to user space is defined by a matrix (cmat)
charToUserTransform(com.tinyline.tiny2d.TinyPath, com.tinyline.tiny2d.TinyFont, int, int, int, int). In TinyLine character space coordinates are EM units.
USER SPACE is the logical coordinate system. It allows to be independent of the resolution of the output device. In TinyLine user space coordinates are fixed point numbers.
Coordinates in DEVICE SPACE specify a particular pixel. Device space is a device-dependent coordinate system and it varies according to the target device. In TinyLine device space coordinates are integers. The origin of device space coordinate system is at the upper left corner with the positive direction of the y-axis pointing downward, and the positive direction of the x-axis to the right.
In TinyLine all coordinate transformations, including transformations from character, user
to device space, are represented by TinyMatrix objects.
The Tiny2D class contains methods for performing basic
numeric operations with fixed point precision numbers:
| Name | Description |
abs(int) |
Returns the absolute value of a fixed point value. |
max(int, int) |
Returns the greater of two fixed point values. |
min(int, int) |
Returns the smaller of two fixed point values. |
mul(int, int) |
Returns a fixed point number whose value is (a * b). |
fastDistance(int, int) |
Returns the fast approximation for the Euclidean distance between two points, in 2D it is
d = sqrt(x^2 + y^2). |
div(int, int) |
Returns a fixed point number whose value is (a / b). |
round(int) |
Returns the closest int to the argument. |
sin(int) |
Returns the trigonometric sine of an angle. |
cos(int) |
Returns the trigonometric cosine of an angle. |
tan(int) |
Returns the trigonometric tangent of an angle. |
atan2(int, int) |
Converts rectangular coordinates (dx, dy)
to polar (r, theta). |
TinyLine supports fixed point and double fixed point numbers. It corresponds to FIX_BITS and DFIX_BITS binary points. In other words, fixed point numbers have FIX_BITS bits fraction length and double fixed point numbers have DFIX_BITS bits fraction length. Thus all numbers must be limited in range between -32,767.9999 to +32,767.9999
| Field Summary | |
static int |
CAP_BUTT
Ends unclosed subpaths and dash segments with no added decoration. |
static int |
CAP_ROUND
Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen. |
static int |
CAP_SQUARE
Ends unclosed subpaths and dash segments with a square projection that extends beyond the end of the segment to a distance equal to half of the line width. |
static int |
DFIX
2 raised to the power of DFIX_BITS |
static int |
DFIX_BITS
The number of fractional bits for double fixed point numbers |
static int |
FILL_STYLE_EO
An even-odd winding rule. |
static int |
FILL_STYLE_WIND
A non-zero winding rule. |
static int |
FIX
2 raised to the power of FIX_BITS |
static int |
FIX_BITS
The number of fractional bits for fixed point numbers |
static int |
JOIN_BEVEL
Joins path segments by connecting the outer corners of their wide outlines with a straight segment. |
static int |
JOIN_MITER
Joins path segments by extending their outside edges until they meet. |
static int |
JOIN_ROUND
Joins path segments by rounding off the corner at a radius of half the line width. |
static int |
MAX_VALUE
A constant holding the maximum value |
static int |
MIN_VALUE
A constant holding the minimum value |
static java.lang.String |
name
The License structure |
static int |
TEXT_ANCHOR_END
The rendered characters are aligned such that the end of the text string is at the initial current text position. |
static int |
TEXT_ANCHOR_MIDDLE
The rendered characters are aligned such that the middle of the text string is at the current text position. |
static int |
TEXT_ANCHOR_START
The rendered characters are aligned such that the start of the text string is at the initial current text position. |
static int |
TEXT_DIR_LR
Sets the text direction to left-to-right, as is common in most Latin-based documents. |
static int |
TEXT_DIR_RL
Sets the text direction to right-to-left, as is common in Arabic or Hebrew scripts. |
static int |
TEXT_DIR_TB
Sets the text direction to top-to-bottom, as is common in some Asian scripts, such as Chinese and Japanese. |
| Constructor Summary | |
Tiny2D()
Constructs a new Tiny2D object. |
|
| Method Summary | |
static int |
abs(int a)
Returns the absolute value of a fixed point value. |
static int |
atan2(int dy,
int dx)
Converts rectangular coordinates ( dx, dy)
to polar (r, theta). |
static TinyRect |
charsBounds(TinyFont font,
int fontSize,
char[] ac,
int off,
int len,
int tdir)
Returns outlined bounds of the character array. |
static TinyPath |
charsToPath(TinyFont font,
char[] ac,
int off,
int len,
int tdir)
Returns an outlined path of the character array. |
static TinyMatrix |
charToUserTransform(TinyPath path,
TinyFont font,
int fontSize,
int x,
int y,
int anchor)
Returns the transformation matrix from character space to user space. |
void |
clearRect(TinyRect r)
Clears the specified rectangle. |
static int |
cos(int ang)
Returns the trigonometric cosine of an angle. |
static int |
div(int a,
int b)
Returns a fixed point number whose value is (a / b). |
void |
drawChars(TinyFont font,
int fontSize,
char[] ac,
int off,
int len,
int x,
int y,
int anchor)
Draws the outlined of the character array using this Tiny2D current state. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line, using the current Tiny2D state, between the points (x1, y1) and (x2, y2). |
void |
drawOval(int x,
int y,
int width,
int height)
Draws the outline of an oval using this Tiny2D current state. |
void |
drawPath(TinyPath path)
Draws the outline of the specified path. |
void |
drawPath(TinyPath path,
TinyRect bbox,
TinyMatrix cmat)
Draws the outline of the specified path. |
void |
drawPolygon(TinyVector points)
Draws a closed polygon defined by vector of points using this Tiny2D current state. |
void |
drawPolyline(TinyVector points)
Draws a sequence of connected lines defined by a vector of points using this Tiny2D current state. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws the outline of the specified rectangle. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int rx,
int ry)
Draws an outlined round-cornered rectangle using this Tiny2D current state. |
static int |
fastDistance(int x,
int y)
Returns the fast approximation for the Euclidean distance between two points, in 2D it is d = sqrt(x^2 + y^2). |
void |
flush()
Flushs the Tiny2D resources. |
TinyRect |
getDevBounds(TinyMatrix matrix,
int strokeWidth,
TinyRect bounds)
Returns the device bounds. |
TinyProducer |
getProducer()
Returns the current TinyProducer. |
TinyState |
getState()
Returns the current graphics state for this Tiny2D object. |
TinyBuffer |
getTarget()
Returns the pixel buffer (target surface) for this Tiny2D object. |
static TinyMatrix |
getTinyMatrix(TinyVector xform)
Returns the TinyMatrix that represents the given transforms list. |
boolean |
hitPath(int x,
int y,
TinyPath path,
TinyMatrix cmat)
Checks whether or not the specified point (x, y)
intersects (hits) the given path. |
static void |
init(int[] lickey)
Registers Tiny2D with the Developer's License Key. |
void |
invalidate()
Invalidates this Tiny2D. |
static TinyPath |
lineToPath(int x0,
int y0,
int x1,
int y1)
Returns the outline path of a line. |
static int |
max(int a,
int b)
Returns the greater of two fixed point values. |
static int |
min(int a,
int b)
Returns the smaller of two fixed point values. |
static int |
mul(int a,
int b)
Returns a fixed point number whose value is (a * b). |
static TinyPath |
ovalToPath(int x,
int y,
int width,
int height)
Returns the outline path of an oval. |
static TinyVector |
pathToPoints(TinyPath path)
Constructs a TinyVector of TinyPoint's
that flattens a TinyPath as it iterates over it. |
static TinyPath |
pointsToPath(TinyVector points)
Returns an outlined path as a sequence of connected lines defined by a vector of points. |
static TinyPath |
rectToPath(int x0,
int y0,
int x1,
int y1)
Returns the outline path of a rectangle. |
static int |
round(int a)
Returns the closest int to the argument. |
static TinyPath |
roundRectToPath(int xmin,
int ymin,
int width,
int height,
int rx,
int ry)
Returns an outlined path of round-cornered rectangle. |
void |
sendPixels()
Sends new pixels under the device clip rectangle to the registered TinyProducer. |
void |
setClip(TinyRect rect)
Sets the current clip of this Tiny2D. |
void |
setProducer(TinyProducer imageProducer)
Sets the current TinyProducer. |
void |
setState(TinyState ts)
Sets the current graphics state for this Tiny2D object. |
void |
setTarget(TinyBuffer pixbuf)
Sets the pixel buffer (target surface) for this Tiny2D object. |
static int |
sin(int ang)
Returns the trigonometric sine of an angle. |
static int |
tan(int ang)
Returns the trigonometric tangent of an angle. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MIN_VALUE
public static final int MAX_VALUE
public static final int FIX_BITS
public static final int FIX
public static final int DFIX_BITS
public static final int DFIX
public static final int FILL_STYLE_WIND
public static final int FILL_STYLE_EO
public static final int JOIN_MITER
public static final int JOIN_ROUND
public static final int JOIN_BEVEL
public static final int CAP_BUTT
public static final int CAP_ROUND
public static final int CAP_SQUARE
public static final int TEXT_ANCHOR_START
public static final int TEXT_ANCHOR_MIDDLE
public static final int TEXT_ANCHOR_END
public static final int TEXT_DIR_LR
public static final int TEXT_DIR_RL
public static final int TEXT_DIR_TB
public static java.lang.String name
| Constructor Detail |
public Tiny2D()
| Method Detail |
public void setState(TinyState ts)
ts - graphics state.public TinyState getState()
public void setTarget(TinyBuffer pixbuf)
pixbuf - the pixel buffer.public final void flush()
public final TinyBuffer getTarget()
public final void setProducer(TinyProducer imageProducer)
public final TinyProducer getProducer()
public final void sendPixels()
public final void invalidate()
public final void setClip(TinyRect rect)
COORDINATES ARE IN DEVICE SPACE.
The real clip will be a little enlarged and checked against the pixel buffer dimensions.
rect - The new device clip.public final void clearRect(TinyRect r)
public final TinyRect getDevBounds(TinyMatrix matrix,
int strokeWidth,
TinyRect bounds)
matrix - the transformation matrix.strokeWidth - the stroke width of the shape in USER SPACE.bounds - the bounds in USER SPACE.
public final void drawPath(TinyPath path,
TinyRect bbox,
TinyMatrix cmat)
path - the path object.bbox - the path bounding box in USER SPACE.cmat - the transformation matrix from CHARACTER SPACE to USER SPACE.public final void drawPath(TinyPath path)
path - the path object.
public final boolean hitPath(int x,
int y,
TinyPath path,
TinyMatrix cmat)
(x, y)
intersects (hits) the given path.
(COORDINATES ARE IN DEVICE SPACE).
x - the point's x coordinate.y - the point's y coordinate.path - the path object.cmat - the transformation matrix from CHARACTER SPACE to USER SPACE.
public final void drawLine(int x1,
int y1,
int x2,
int y2)
(x1, y1) and (x2, y2).
(COORDINATES ARE IN DEVICE SPACE).
x1 - the first point's x coordinate.y1 - the first point's y coordinate.x2 - the second point's x coordinate.y2 - the second point's y coordinate.
Does nothing if the target pixbuf is null.
public final void drawRect(int x,
int y,
int width,
int height)
x and x + width.
The top and bottom edges are at
y and y + height.
The rectangle is drawn using the graphics context's current color.
(COORDINATES ARE IN DEVICE SPACE).
x - the x coordinate
of the rectangle to be drawn.y - the y coordinate
of the rectangle to be drawn.width - the width of the rectangle to be drawn.height - the height of the rectangle to be drawn.
Does nothing if the function is not supported.
public final void drawRoundRect(int x,
int y,
int width,
int height,
int rx,
int ry)
x and x + width,
respectively. The top and bottom edges of the rectangle are at
y and y + height.
x - the x coordinate of the rectangle to be drawn.y - the y coordinate of the rectangle to be drawn.width - the width of the rectangle to be drawn.height - the height of the rectangle to be drawn.rx - the horizontal diameter of the arc
at the four corners.ry - the vertical diameter of the arc
at the four corners.
Does nothing if the function is not supported.
public final void drawOval(int x,
int y,
int width,
int height)
x, y,
width, and height arguments.
x - the x coordinate of the upper left
corner of the oval to be drawn.y - the y coordinate of the upper left
corner of the oval to be drawn.width - the width of the oval to be drawn.height - the height of the oval to be drawn.
Does nothing if the function is not supported.
public final void drawPolyline(TinyVector points)
points - a vector of points
Does nothing if the function is not supported.public final void drawPolygon(TinyVector points)
points - a vector of points
Does nothing if the function is not supported.
public final void drawChars(TinyFont font,
int fontSize,
char[] ac,
int off,
int len,
int x,
int y,
int anchor)
font
and fontSize. The baseline of the first
character is defined by position (x, y) and
alignment anchor.
font - the font object.fontSize - the size of the font.ac - array of characters.off - the initial array offset.len - the length of array.x - the x-axis coordinate of the current text positiony - the y-axis coordinate of the current text positionanchor - the text alignement.
Does nothing if the target pixbuf is null.
public static final TinyRect charsBounds(TinyFont font,
int fontSize,
char[] ac,
int off,
int len,
int tdir)
font - the font object.fontSize - the size of the font.ac - array of characters.off - the initial array offset.len - the length of array.tdir - the text direction.
Throws a RuntimeException if the function is not supported.
public static final TinyMatrix charToUserTransform(TinyPath path,
TinyFont font,
int fontSize,
int x,
int y,
int anchor)
path - the outlined path of the character array.font - the font object.fontSize - the size of the font.x - the x-axis coordinate of the current text positiony - the y-axis coordinate of the current text positionanchor - the text alignement.
public static final TinyPath lineToPath(int x0,
int y0,
int x1,
int y1)
x0 - the start point X coord.y0 - the start point Y coord.x1 - the end point X coord.y1 - the end point Y coord.
public static final TinyPath rectToPath(int x0,
int y0,
int x1,
int y1)
x0 - the top-left corner X coord.y0 - the top-left corner Y coord.x1 - the down-right corner X coord.y1 - the down-right corner Y coord.
public static final TinyPath ovalToPath(int x,
int y,
int width,
int height)
x, y,
width, and height arguments.
x - the x coordinate of the upper left
corner of the oval to be drawn.y - the y coordinate of the upper left
corner of the oval to be drawn.width - the width of the oval to be drawn.height - the height of the oval to be drawn.
public static final TinyPath roundRectToPath(int xmin,
int ymin,
int width,
int height,
int rx,
int ry)
x and
x + width, respectively. The top and bottom edges
of the rectangle are at y and
y + height.
xmin - the x coordinate of the rectangle to be drawn.ymin - the y coordinate of the rectangle to be drawn.width - the width of the rectangle to be drawn.height - the height of the rectangle to be drawn.rx - the horizontal diameter of the arc
at the four corners.ry - the vertical diameter of the arc
at the four corners.
public static final TinyPath charsToPath(TinyFont font,
char[] ac,
int off,
int len,
int tdir)
font.
The baseline of the first character is defined by position
(x, y).
font - the font object.ac - array of characters.off - the initial array offset.len - the length of array.
Throws a RuntimeException if the function is not supported.
public static final TinyPath pointsToPath(TinyVector points)
points - a vector pointspublic static final TinyVector pathToPoints(TinyPath path)
TinyVector of TinyPoint's
that flattens a TinyPath as it iterates over it.
path - the original unflattened path being iterated over.
public static TinyMatrix getTinyMatrix(TinyVector xform)
xform - The list of TinyMatrix objects.
public static final int abs(int a)
fixed point value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a - a fixed point value.
public static final int max(int a,
int b)
fixed point values.
a - a fixed point value.b - a fixed point value.
a and b.
public static final int min(int a,
int b)
fixed point values.
a - a fixed point value.b - a fixed point value.
a and b.
public static final int mul(int a,
int b)
a - a fixed point value.b - a fixed point value.
public static final int fastDistance(int x,
int y)
d = sqrt(x^2 + y^2).
x - a fixed point value.y - a fixed point value.
sqrt(x^2 + y^2).
public static final int div(int a,
int b)
a - a fixed point value.b - a fixed point value.
public static final int round(int a)
int to the argument.
a - a fixed point value to be rounded to an integer.
int value.public static int sin(int ang)
ang - an angle is a fixed point number, in degrees.
public static int cos(int ang)
ang - an angle is a fixed point number, in degrees.
public static int tan(int ang)
ang - an angle is a fixed point number, in degrees.
public static int atan2(int dy,
int dx)
dx, dy)
to polar (r, theta).
This method computes the phase theta by computing an arc tangent
of dy/dx in the range of -pi to pi.
dy - the ordinate coordinatedx - the abscissa coordinate
public static final void init(int[] lickey)
Here the License Key - registration id provided when the TinyLine 2D license is purchased. This will identify which version of TinyLine 2D is licensed and permit all licensed functions to work.
IMPORTANT: YOU MUST CALL IT WITH YOUR LICENSE KEY PROVIDED WHEN THE TINYLINE 2D LICENSE IS PURCHASED!
lickey - The Developer's License Key
|
TinyLine v2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||