net.rim.device.api.openvg
Class VGUtils

java.lang.Object
  extended by net.rim.device.api.openvg.VGUtils

public final class VGUtils
extends Object

Provides a set of utility methods for OpenVG applications.

This class has BlackBerry extension to help use OpenVG and also contains OpenVG VGU functions that allow applications to specify a number of higher-level geometric primitives to be appended to a path. Each primitive is immediately reduced to a series of line segments, Bézier curves, and arcs. Coordinates may overflow silently if they fall outside the range defined by the path datatype, scale, and bias.

VGU provides three utility functions to compute 3x3 projective transform matrices. The first two compute the transformation from an arbitrary quadrilateral onto the unit square, and vice versa. The third computes the transformation from an arbitrary quadrilateral to an arbitrary quadrilateral. The output transformation is stored into matrix as 9 elements in the order { sx, shy, w0, shx, sy, w1, tx, ty, w2 }. In all cases, if there is no projective mapping that satisfies the given constraints, or the mapping would be degenerate (i.e., non-invertible), VGU_BAD_WARP_ERROR is returned and matrix is unchanged. Formulas for computing projective warps may be found in [HECK89] and [WOLB90].

Since:
BlackBerry API 6.0.0

Field Summary
static int VGU_ARC_CHORD
          OpenVG VGU 1.0 constant.
static int VGU_ARC_OPEN
          OpenVG VGU 1.0 constant.
static int VGU_ARC_PIE
          OpenVG VGU 1.0 constant.
static int VGU_BAD_HANDLE_ERROR
          OpenVG VGU 1.0 constant.
static int VGU_BAD_WARP_ERROR
          OpenVG VGU 1.0 constant.
static int VGU_ILLEGAL_ARGUMENT_ERROR
          OpenVG VGU 1.0 constant.
static int VGU_NO_ERROR
          OpenVG VGU 1.0 constant.
static int VGU_OUT_OF_MEMORY_ERROR
          OpenVG VGU 1.0 constant.
static int VGU_PATH_CAPABILITY_ERROR
          OpenVG VGU 1.0 constant.
static int VG_DRAW_AS_IMAGE_HINT
          OpenVG VGU 1.0 constant.
static int VG_DRAW_AS_PATH_HINT
          OpenVG Utils BlackBerry Extension constant.
 
Method Summary
static VG getVG(EGLContext context)
          Returns a VG object associated with this EGL context.
static boolean isSupported()
          Determines whether or not the device supports OpenVG.
static void vgClosePath(VG vg, int path)
          Appends a VG_CLOSE_PATH path segment to the given path.
static int vgCreateColorPaint(VG vg, int argb)
          Creates a VGPaint and sets it to the color specified by the integer argb.
static int vgCreateColorPaint(VG vg, String argb)
          Creates a VGPaint and sets it to the color specified by the hexadecimal string argb.
static int vgCreateImage(VG vg, Bitmap bitmap, boolean flipY, int allowedQuality)
          Creates a VGImage from the specified bitmap.
static int vgCreateImage(VG vg, Bitmap bitmap, boolean flipY, int allowedQuality, XYRect region)
          Creates a VGImage from the specified bitmap.
static int vgCreateImage(VG vg, EncodedImage encodedImage, boolean flipY, int allowedQuality, XYRect region)
          Creates a VGImage from the specified EncodedImage.
static int vgCreateLinearGradientPaint(VG vg, float x0, float y0, float x1, float y1, float[] stops)
          Creates a VGPaint with the paint type set to VG_PAINT_TYPE_LINEAR_GRADIENT.
static int vgCreatePath(VG vg, String pathData)
          Creates a VGPath from an SVG path data string.
static int vgCreateRadialGradientPaint(VG vg, float cx, float cy, float fx, float fy, float r, float[] stops)
          Creates a VGPaint with the paint type set to VG_PAINT_TYPE_RADIAL_GRADIENT.
static int vgCreateTextAsImage(VG vg, FontSpec font, String str, DrawTextParam params, TextMetrics metrics)
          Creates a VGImage from the given text string.
static int vgCreateTextAsImage(VG vg, FontSpec font, StringBuffer sb, DrawTextParam params, TextMetrics metrics)
          StringBuffer version of vgCreateTextAsImage.
static int vgCreateTextAsPath(VG vg, FontSpec font, String str, DrawTextParam params, TextMetrics metrics)
          Creates a VGPath from the given text string.
static int vgCreateTextAsPath(VG vg, FontSpec font, StringBuffer sb, DrawTextParam params, TextMetrics metrics)
          StringBuffer version of vgCreateTextAsPath.
static void vgCubicTo(VG vg, int path, float x0, float y0, float x1, float y1, float x2, float y2, boolean relative)
          Appends a VG_CUBIC_TO (cubic Bézier curve) path segment and path data to the given path.
static float vgDrawText(VG vg, Font font, String str, int strOffset, int strLength, DrawTextParam params, TextMetrics metrics)
          Deprecated. Use other vgDrawText methods.
static float vgDrawText(VG vg, FontSpec font, String str, DrawTextParam params, TextMetrics metrics, int drawHint, int paintModes)
          Draws the specified string using the font and text rendering parameters.
static float vgDrawText(VG vg, FontSpec font, StringBuffer sb, DrawTextParam params, TextMetrics metrics, int drawHint, int paintModes)
          StringBuffer version of vgDrawText.
static void vgHLineTo(VG vg, int path, float x, boolean relative)
          Appends a VG_HLINE_TO (horizontal line) path segment and path data to the given path.
static void vgImageSubData(VG vg, Bitmap bitmap, boolean flipY, int image)
          Loads the sub data from a bitmap into an destination VGImage.
static void vgImageSubData(VG vg, Bitmap bitmap, int offsetX, int offsetY, boolean flipY, int image, int x, int y, int width, int height)
          Loads the sub data from a bitmap, performs format conversion if necessary, and stores the resulting pixels into a rectangular portion of a VGImage.
static void vgImageSubData(VG vg, EncodedImage encodedImage, int offsetX, int offsetY, boolean flipY, int image, int x, int y, int width, int height)
          Loads the sub data from a encodedImage, performs format conversion if necessary, and stores the resulting pixels into a rectangular portion of a VGImage.
static void vgLargeCCWArcTo(VG vg, int path, float rh, float rv, float rot, float x0, float y0, boolean relative)
          Appends a VG_LCCWARC_TO (large counter-clockwise elliptical arc) path segment and path data to the given path.
static void vgLargeCWArcTo(VG vg, int path, float rh, float rv, float rot, float x0, float y0, boolean relative)
          Appends a VG_LCWARC_TO (large clockwise elliptical arc) path segment and path data to the given path.
static void vgLineTo(VG vg, int path, float x, float y, boolean relative)
          Appends a VG_LINE_TO path segment and path data to the given path.
static float vgMeasureText(VG vg, FontSpec font, String str, DrawTextParam params, TextMetrics metrics)
          Measures the text and returns the advance width of the specified string using the font and text rendering parameters.
static float vgMeasureText(VG vg, FontSpec font, StringBuffer sb, DrawTextParam params, TextMetrics metrics)
          StringBuffer version of vgMeasureText.
static void vgMoveTo(VG vg, int path, float x, float y, boolean relative)
          Appends a VG_MOVE_TO path segment and path data to the given path.
static void vgQuadTo(VG vg, int path, float x0, float y0, float x1, float y1, boolean relative)
          Appends a VG_QUAD_TO (quadratic Bézier curve) path segment and path data to the given path.
static void vgSmallCCWArcTo(VG vg, int path, float rh, float rv, float rot, float x0, float y0, boolean relative)
          Appends a VG_SCCWARC_TO (small counter-clockwise elliptical arc) path segment and path data to the given path.
static void vgSmallCWArcTo(VG vg, int path, float rh, float rv, float rot, float x0, float y0, boolean relative)
          Appends a VG_SCWARC_TO (small clockwise elliptical arc) path segment and path data to the given path.
static void vgSmoothCubicTo(VG vg, int path, float x1, float y1, float x2, float y2, boolean relative)
          Appends a VG_SCUBIC_TO (smooth cubic Bézier curve) path segment and path data to the given path.
static void vgSmoothQuadTo(VG vg, int path, float x1, float y1, boolean relative)
          Appends a VG_SQUAD_TO (smooth quadratic Bézier) path segment and path data to the given path.
static void vgVLineTo(VG vg, int path, float y, boolean relative)
          Appends a VG_VLINE_TO (vertical line) path segment and path data to the given path.
static int vguArc(VG vg, int path, float x, float y, float width, float height, float startAngle, float angleExtent, int arcType)
          Appends an elliptical arc to a path, possibly along with one or two line segments, according to the arcType parameter.
static int vguComputeWarpQuadToQuad(VG vg, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3, float sx0, float sy0, float sx1, float sy1, float sx2, float sy2, float sx3, float sy3, float[] matrix, int offset)
          Sets the entries of matrix to a projective transformation that maps the point: (sx0, sy0) to (dx0, dy0); (sx1, sy1) to (dx1, dy1); (sx2, sy2) to (dx2, dy2); and (sx3, sy3) to (dx3, dy3).
static int vguComputeWarpQuadToQuad(VG vg, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3, float sx0, float sy0, float sx1, float sy1, float sx2, float sy2, float sx3, float sy3, FloatBuffer buffer)
          The floating-point Buffer version of vguComputeWarpQuadToQuad.
static int vguComputeWarpQuadToSquare(VG vg, float sx0, float sy0, float sx1, float sy1, float sx2, float sy2, float sx3, float sy3, float[] matrix, int offset)
          Sets the entries of matrix to a projective transformation that maps the point: (sx0, sy0) to (0, 0); (sx1, sy1) to (1, 0); (sx2, sy2) to (0, 1); and (sx3, sy3) to (1, 1).
static int vguComputeWarpQuadToSquare(VG vg, float sx0, float sy0, float sx1, float sy1, float sx2, float sy2, float sx3, float sy3, FloatBuffer buffer)
          The floating-point Buffer version of vguComputeWarpQuadToSquare.
static int vguComputeWarpSquareToQuad(VG vg, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3, float[] matrix, int offset)
          Sets the entries of matrix to a projective transformation that maps the point: (0, 0) to (dx0, dy0); (1, 0) to (dx1, dy1); (0, 1) to (dx2, dy2); and (1, 1) to (dx3, dy3).
static int vguComputeWarpSquareToQuad(VG vg, float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3, FloatBuffer buffer)
          The floating-point Buffer version of vguComputeWarpSquareToQuad.
static int vguEllipse(VG vg, int path, float cx, float cy, float width, float height)
          Appends an axis-aligned ellipse to a path.
static int vguLine(VG vg, int path, float x0, float y0, float x1, float y1)
          Appends a line segment to a path.
static int vguPolygon(VG vg, int path, float[] points, int offset, int count, boolean closed)
          Appends a polyline or polygon to a path.
static int vguPolygon(VG vg, int path, FloatBuffer points, boolean closed)
          The floating-point Buffer version of vguPolygon.
static int vguRect(VG vg, int path, float x, float y, float width, float height)
          Appends an axis-aligned rectangle with its lower-left corner at (x, y) and a given width and height to a path.
static int vguRoundRect(VG vg, int path, float x, float y, float width, float height, float arcWidth, float arcHeight)
          Appends an axis-aligned round-cornered rectangle with the lower-left corner of its rectangular bounding box at (x, y) and a given width, height, arcWidth, and arcHeight to a path.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

VGU_NO_ERROR

public static final int VGU_NO_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_BAD_HANDLE_ERROR

public static final int VGU_BAD_HANDLE_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_ILLEGAL_ARGUMENT_ERROR

public static final int VGU_ILLEGAL_ARGUMENT_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_OUT_OF_MEMORY_ERROR

public static final int VGU_OUT_OF_MEMORY_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_PATH_CAPABILITY_ERROR

public static final int VGU_PATH_CAPABILITY_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_BAD_WARP_ERROR

public static final int VGU_BAD_WARP_ERROR
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_ARC_OPEN

public static final int VGU_ARC_OPEN
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_ARC_CHORD

public static final int VGU_ARC_CHORD
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VGU_ARC_PIE

public static final int VGU_ARC_PIE
OpenVG VGU 1.0 constant.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

VG_DRAW_AS_PATH_HINT

public static final int VG_DRAW_AS_PATH_HINT
OpenVG Utils BlackBerry Extension constant. Draw text glyphs as paths hint.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

VG_DRAW_AS_IMAGE_HINT

public static final int VG_DRAW_AS_IMAGE_HINT
OpenVG VGU 1.0 constant. OpenVG Utils BlackBerry Extension constant.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0


Method Detail

getVG

public static VG getVG(EGLContext context)
Returns a VG object associated with this EGL context.

To call extension methods, cast the returned object to the interface type that contains the methods of the extension.

Parameters:
context - The EGL context.
Returns:
a VG instance that implements all available extension interfaces.
Throws:
UnsupportedOperationException - if the device does not support OpenVG
IllegalArgumentException - if this context is not an OpenVG context.
Since:
BlackBerry API 6.0.0

isSupported

public static boolean isSupported()
Determines whether or not the device supports OpenVG.

To query the actual version of OpenVG supported for the device, use vgGetString(int).

Returns:
true if the device supports some version of OpenVG, false otherwise.
Since:
BlackBerry API 6.0.0

vgCreateImage

public static int vgCreateImage(VG vg,
                                Bitmap bitmap,
                                boolean flipY,
                                int allowedQuality)
Creates a VGImage from the specified bitmap.

Errors

VG_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
bitmap - The source bitmap to create the image from.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the bitmap.
allowedQuality - The allowed image quality.
Returns:
The created VGImage or VG_INVALID_HANDLE if an error occurred.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if bitmap is null.
Since:
BlackBerry API 6.0.0

vgCreateImage

public static int vgCreateImage(VG vg,
                                Bitmap bitmap,
                                boolean flipY,
                                int allowedQuality,
                                XYRect region)
Creates a VGImage from the specified bitmap.

Errors

VG_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
bitmap - The source bitmap to create the image from.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the bitmap.
allowedQuality - The allowed image quality.
region - An XYRect that defines an area within the bitmap. If region is null then the entire bitmap is used.
Returns:
The created VGImage or VG_INVALID_HANDLE if an error occurred.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if bitmap is null.
IllegalArgumentException - if region is not entirely contained in the bitmap.
IllegalArgumentException - if region.width or region.height are less than or equal to zero.
Since:
BlackBerry API 7.0.0

vgCreateImage

public static int vgCreateImage(VG vg,
                                EncodedImage encodedImage,
                                boolean flipY,
                                int allowedQuality,
                                XYRect region)
Creates a VGImage from the specified EncodedImage.

Parameters:
vg - The OpenVG renderer.
encodedImage - The source EncodedImage to create the image from.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the EncodedImage.
allowedQuality - The allowed image quality.
region - An XYRect that defines an area within the EncodedImage. If region is null then the entire EncodedImage is used.
Returns:
The created VGImage or VG_INVALID_HANDLE if an error occurred.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if encodedImage is null.
IllegalArgumentException - if region is not entirely contained in the bitmap.
IllegalArgumentException - if region.width or region.height are less than or equal to zero.
Since:
BlackBerry API 7.0.0

vgImageSubData

public static void vgImageSubData(VG vg,
                                  Bitmap bitmap,
                                  boolean flipY,
                                  int image)
Loads the sub data from a bitmap into an destination VGImage.

Errors

VG_BAD_HANDLE_ERROR VG_IMAGE_IN_USE_ERROR

Parameters:
vg - The OpenVG renderer.
bitmap - The source bitmap to create the image from.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the bitmap.
image - The destination VGImage.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if bitmap is null.
Since:
BlackBerry API 6.0.0

vgImageSubData

public static void vgImageSubData(VG vg,
                                  Bitmap bitmap,
                                  int offsetX,
                                  int offsetY,
                                  boolean flipY,
                                  int image,
                                  int x,
                                  int y,
                                  int width,
                                  int height)
Loads the sub data from a bitmap, performs format conversion if necessary, and stores the resulting pixels into a rectangular portion of a VGImage.

The region to be written is given by x, y, width, and height, which must define a positive region. Pixels that fall outside the bounds of the image are ignored.

Errors

VG_BAD_HANDLE_ERROR VG_IMAGE_IN_USE_ERROR VG_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
bitmap - The source bitmap to be loaded into the image.
offsetX - The x offset position in the bitmap.
offsetY - The y offset position in the bitmap.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the bitmap.
image - The destination VGImage.
x - The x position of the region to be written in the VGImage.
y - The y position of the region to be written in the VGImage.
width - The width of the region to be written in the VGImage.
height - The height of the region to be written in the VGImage.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if bitmap is null.
IllegalArgumentException - if offsetX or offsetY is negative.
IllegalArgumentException - if offsetX is greater than or equal to bitmap.getWidth().
IllegalArgumentException - if offsetY is greater than or equal to bitmap.getHeight().
IllegalArgumentException - if width is greater than bitmap.getWidth() - offsetX.
IllegalArgumentException - if height is greater than bitmap.getHeight() - offsetY.
Since:
BlackBerry API 7.0.0

vgImageSubData

public static void vgImageSubData(VG vg,
                                  EncodedImage encodedImage,
                                  int offsetX,
                                  int offsetY,
                                  boolean flipY,
                                  int image,
                                  int x,
                                  int y,
                                  int width,
                                  int height)
Loads the sub data from a encodedImage, performs format conversion if necessary, and stores the resulting pixels into a rectangular portion of a VGImage.

The region to be written is given by x, y, width, and height, which must define a positive region. Pixels that fall outside the bounds of the image are ignored.

Errors

VG_BAD_HANDLE_ERROR VG_IMAGE_IN_USE_ERROR VG_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
encodedImage - The source encodedImage to be loaded into the image.
offsetX - The x offset position in the encodedImage.
offsetY - The y offset position in the encodedImage.
flipY - If true the image is flipped on the y axis so that image coordinate are top-left which is same as the image data in the encodedImage.
image - The destination VGImage.
x - The x position of the region to be written in the VGImage.
y - The y position of the region to be written in the VGImage.
width - The width of the region to be written in the VGImage.
height - The height of the region to be written in the VGImage.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if encodedImage is null.
IllegalArgumentException - if offsetX or offsetY is negative.
IllegalArgumentException - if offsetX is greater than or equal to encodedImage.getWidth().
IllegalArgumentException - if offsetY is greater than or equal to encodedImage.getHeight().
IllegalArgumentException - if width is greater than encodedImage.getWidth() - offsetX.
IllegalArgumentException - if height is greater than encodedImage.getHeight() - offsetY.
Since:
BlackBerry API 7.0.0

vgDrawText

public static float vgDrawText(VG vg,
                               FontSpec font,
                               String str,
                               DrawTextParam params,
                               TextMetrics metrics,
                               int drawHint,
                               int paintModes)
Draws the specified string using the font and text rendering parameters.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
str - The string to be drawn.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
drawHint - A flag to control drawing. Must be either VG_DRAW_AS_PATH_HINT or VG_DRAW_AS_IMAGE_HINT. NOTE: Some fonts do not support VG_DRAW_AS_PATH_HINT flag; if this is the case, the method will ignore the hint flag and draw the text as an image.
paintModes - The drawing paint modes to be applied. Must be a bitwise OR of values from VG_FILL_PATH or VG_STROKE_PATH. NOTE: If paintModes is set to 0, then no text will be drawn.
Returns:
The linear advance width in pixels of the text substring drawn.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if str is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than str.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
IllegalArgumentException - if drawHint is not VG_DRAW_AS_PATH_HINT or VG_DRAW_AS_IMAGE_HINT.
IllegalArgumentException - if paintModes is not a valid bitwise OR of VG_FILL_PATH or VG_STROKE_PATH.
Since:
BlackBerry API 7.0.0

vgDrawText

public static float vgDrawText(VG vg,
                               FontSpec font,
                               StringBuffer sb,
                               DrawTextParam params,
                               TextMetrics metrics,
                               int drawHint,
                               int paintModes)
StringBuffer version of vgDrawText.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
sb - The string to be drawn.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
drawHint - A flag to control drawing. Must be either VG_DRAW_AS_PATH_HINT or VG_DRAW_AS_IMAGE_HINT. NOTE 1: Some fonts do not support VG_DRAW_AS_PATH_HINT flag; if this is the case, the method will ignore the hint flag and draw the text as an image. NOTE 2: A call to this method will modify the state of the text rendering engine. For example, if the value of the drawHint parameter is VG_DRAW_AS_PATH_HINT but the text rendering engine state is set to VG_DRAW_AS_IMAGE_HINT then this state will change to VG_DRAW_AS_PATH_HINT as a side effect. Frequent switching between VG_DRAW_AS_PATH_HINT and VG_DRAW_AS_IMAGE_HINT states has a negative impact on vgDrawText performance and should be avoided.
paintModes - The drawing paint modes to be applied. Must be a bitwise OR of values from VG_FILL_PATH or VG_STROKE_PATH. NOTE: If paintModes is set to 0, then no text will be drawn.
Returns:
The linear advance width in pixels of the text substring drawn.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if sb is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than sb.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
IllegalArgumentException - if drawHint is not VG_DRAW_AS_PATH_HINT or VG_DRAW_AS_IMAGE_HINT.
IllegalArgumentException - if paintModes is not a valid bitwise OR of VG_FILL_PATH or VG_STROKE_PATH.
Since:
BlackBerry API 7.0.0

vgDrawText

public static float vgDrawText(VG vg,
                               Font font,
                               String str,
                               int strOffset,
                               int strLength,
                               DrawTextParam params,
                               TextMetrics metrics)
Deprecated. Use other vgDrawText methods.

Draws the specified string using the font and text rendering parameters.

Note: This method will draw text using the font-family, style, and height specified in the font. Other font settings - antialias mode, effect flags, and affine transform - will be overridden by OpenVG context values.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
str - The string or substring to be drawn.
strOffset - The start offset of the substring.
strLength - The length of substring.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
Returns:
The linear advance width in pixels of the text substring drawn.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if str is null.
IllegalArgumentException - if strOffset and endOffset substring indexes not legal.
Since:
BlackBerry API 6.0.0

vgMeasureText

public static float vgMeasureText(VG vg,
                                  FontSpec font,
                                  String str,
                                  DrawTextParam params,
                                  TextMetrics metrics)
Measures the text and returns the advance width of the specified string using the font and text rendering parameters.

Parameters:
vg - The OpenVG renderer.
font - The font to use.
str - The string to be measured.
params - The text parameters to control measuring. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the measuring call. If null then no metrics are computed/updated.
Returns:
The linear advance width in pixels of the text substring.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if str is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than str.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgMeasureText

public static float vgMeasureText(VG vg,
                                  FontSpec font,
                                  StringBuffer sb,
                                  DrawTextParam params,
                                  TextMetrics metrics)
StringBuffer version of vgMeasureText.

Parameters:
vg - The OpenVG renderer.
font - The font to use.
sb - The string to be measured.
params - The text parameters to control measuring. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the measuring call. If null then no metrics are computed/updated.
Returns:
The linear advance width in pixels of the text substring.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if sb is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than sb.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgCreateTextAsPath

public static int vgCreateTextAsPath(VG vg,
                                     FontSpec font,
                                     String str,
                                     DrawTextParam params,
                                     TextMetrics metrics)
Creates a VGPath from the given text string.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
str - The string to be created.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
Returns:
A VGPath handle. For some fonts/strings a VGPath cannot be created; in that case VG_INVALID_HANDLE is returned.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if str is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than str.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgCreateTextAsPath

public static int vgCreateTextAsPath(VG vg,
                                     FontSpec font,
                                     StringBuffer sb,
                                     DrawTextParam params,
                                     TextMetrics metrics)
StringBuffer version of vgCreateTextAsPath.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
sb - The string to be created.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
Returns:
A VGPath handle. For some fonts/strings a VGPath cannot be created; in that case VG_INVALID_HANDLE is returned.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if sb is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than sb.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgCreateTextAsImage

public static int vgCreateTextAsImage(VG vg,
                                      FontSpec font,
                                      String str,
                                      DrawTextParam params,
                                      TextMetrics metrics)
Creates a VGImage from the given text string.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
str - The string to be created.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
Returns:
A VGImage handle or VG_INVALID_HANDLE if an error occured.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if str is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than str.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgCreateTextAsImage

public static int vgCreateTextAsImage(VG vg,
                                      FontSpec font,
                                      StringBuffer sb,
                                      DrawTextParam params,
                                      TextMetrics metrics)
StringBuffer version of vgCreateTextAsImage.

Parameters:
vg - The OpenVG renderer.
font - The font to draw with.
sb - The string to be created.
params - The text parameters to control drawing. If null then the default drawing parameters are used.
metrics - The text metrics gathered for the drawing call. If null then no metrics are computed/updated.
Returns:
A VGImage handle or VG_INVALID_HANDLE if an error occured.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if font is null.
IllegalArgumentException - if sb is null.
IllegalArgumentException - if params.iStartOffset is less than zero, equal to or greater than sb.length().
IllegalArgumentException - if params.iEndOffset is less than zero or less than params.iStartOffset.
Since:
BlackBerry API 7.0.0

vgCreatePath

public static int vgCreatePath(VG vg,
                               String pathData)
Creates a VGPath from an SVG path data string.

The path data string is the same as the 'd' attribute in the SVG Tiny 1.2 'path' element. See SVG Path Data in the SVG Tiny 1.2 spec. Note that SVG is top left aligned while OpenVG is bottom left aligned.

The VGPath will be created with VG_PATH_CAPABILITY_ALL. It is recommended that you remove the path capabilities that you don't need.

Example

 int tri  = VGUtils.vgCreatePath(vg, "M250 150 150 350 350 350 Z");
 vg.vgRemovePathCapabilities(tri, VG11.VG_PATH_CAPABILITY_ALL);
 int rect = VGUtils.vgCreatePath(vg, "M 100,100 h200v100h-200z");
 vg.vgRemovePathCapabilities(rect, VG11.VG_PATH_CAPABILITY_ALL);

Parameters:
vg - The OpenVG renderer.
pathData - The SVG path data string.
Returns:
A VGPath handle or VG_INVALID_HANDLE if an error occured.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if pathData is null or contains a syntax error.
Since:
BlackBerry API 7.0.0

vgClosePath

public static void vgClosePath(VG vg,
                               int path)
Appends a VG_CLOSE_PATH path segment to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgMoveTo

public static void vgMoveTo(VG vg,
                            int path,
                            float x,
                            float y,
                            boolean relative)
Appends a VG_MOVE_TO path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x - X-coordinate.
y - Y-coordinate.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgLineTo

public static void vgLineTo(VG vg,
                            int path,
                            float x,
                            float y,
                            boolean relative)
Appends a VG_LINE_TO path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x - X-coordinate.
y - Y-coordinate.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgHLineTo

public static void vgHLineTo(VG vg,
                             int path,
                             float x,
                             boolean relative)
Appends a VG_HLINE_TO (horizontal line) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x - X-coordinate.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgVLineTo

public static void vgVLineTo(VG vg,
                             int path,
                             float y,
                             boolean relative)
Appends a VG_VLINE_TO (vertical line) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
y - Y-coordinate.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgQuadTo

public static void vgQuadTo(VG vg,
                            int path,
                            float x0,
                            float y0,
                            float x1,
                            float y1,
                            boolean relative)
Appends a VG_QUAD_TO (quadratic Bézier curve) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x0 - X-coordinate of the control point.
y0 - Y-coordinate of the control point.
x1 - X-coordinate of the end point.
y1 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgCubicTo

public static void vgCubicTo(VG vg,
                             int path,
                             float x0,
                             float y0,
                             float x1,
                             float y1,
                             float x2,
                             float y2,
                             boolean relative)
Appends a VG_CUBIC_TO (cubic Bézier curve) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x0 - X-coordinate of the control point at the beginning of the curve.
y0 - Y-coordinate of the control point at the beginning of the curve.
x1 - X-coordinate of the control point at the end of the curve.
y1 - Y-coordinate of the control point at the end of the curve.
x2 - X-coordinate of the end point.
y2 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgSmoothQuadTo

public static void vgSmoothQuadTo(VG vg,
                                  int path,
                                  float x1,
                                  float y1,
                                  boolean relative)
Appends a VG_SQUAD_TO (smooth quadratic Bézier) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x1 - X-coordinate of the end point.
y1 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgSmoothCubicTo

public static void vgSmoothCubicTo(VG vg,
                                   int path,
                                   float x1,
                                   float y1,
                                   float x2,
                                   float y2,
                                   boolean relative)
Appends a VG_SCUBIC_TO (smooth cubic Bézier curve) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
x1 - X-coordinate of the control point at the end of the curve.
y1 - Y-coordinate of the control point at the end of the curve.
x2 - X-coordinate of the end point.
y2 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgSmallCCWArcTo

public static void vgSmallCCWArcTo(VG vg,
                                   int path,
                                   float rh,
                                   float rv,
                                   float rot,
                                   float x0,
                                   float y0,
                                   boolean relative)
Appends a VG_SCCWARC_TO (small counter-clockwise elliptical arc) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
rh - Horizontal axis.
rv - Vertical axis.
rot - Rotation angle in degrees.
x0 - X-coordinate of the end point.
y0 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgSmallCWArcTo

public static void vgSmallCWArcTo(VG vg,
                                  int path,
                                  float rh,
                                  float rv,
                                  float rot,
                                  float x0,
                                  float y0,
                                  boolean relative)
Appends a VG_SCWARC_TO (small clockwise elliptical arc) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
rh - Horizontal axis.
rv - Vertical axis.
rot - Rotation angle in degrees.
x0 - X-coordinate of the end point.
y0 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgLargeCCWArcTo

public static void vgLargeCCWArcTo(VG vg,
                                   int path,
                                   float rh,
                                   float rv,
                                   float rot,
                                   float x0,
                                   float y0,
                                   boolean relative)
Appends a VG_LCCWARC_TO (large counter-clockwise elliptical arc) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
rh - Horizontal axis.
rv - Vertical axis.
rot - Rotation angle in degrees.
x0 - X-coordinate of the end point.
y0 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgLargeCWArcTo

public static void vgLargeCWArcTo(VG vg,
                                  int path,
                                  float rh,
                                  float rv,
                                  float rot,
                                  float x0,
                                  float y0,
                                  boolean relative)
Appends a VG_LCWARC_TO (large clockwise elliptical arc) path segment and path data to the given path.

Errors

VG_BAD_HANDLE_ERROR VG_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The VGPath to append to.
rh - Horizontal axis.
rv - Vertical axis.
rot - Rotation angle in degrees.
x0 - X-coordinate of the end point.
y0 - Y-coordinate of the end point.
relative - If true, the segment will be relative. If false, the segment will be absolute.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgCreateColorPaint

public static int vgCreateColorPaint(VG vg,
                                     int argb)
Creates a VGPaint and sets it to the color specified by the integer argb.

Example

 int paint = vgCreateColorPaint(vg, 0xFF01796F); // opaque pine green

Parameters:
vg - The OpenVG renderer.
argb - Color in the format 0xAARRGGBB.
Returns:
The VGPaint object created or VG_INVALID_HANDLE if insufficient memory is available to allocate a new object.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgCreateColorPaint

public static int vgCreateColorPaint(VG vg,
                                     String argb)
Creates a VGPaint and sets it to the color specified by the hexadecimal string argb.

The hexadecimal string may be of the format "#AARRGGBB", "#RRGGBB", "AARRGGBB" or "RRGGBB". The hex string is case-insensitive and may start with the character '#'. Strings that don't specify an alpha value will be opaque.

Example

 int pine = VGUtils.vgCreateColorPaint(vg, "#01796F");  // opaque pine green
 int sky  = VGUtils.vgCreateColorPaint(vg, "1E90FF");   // opaque sky blue
 int jade = VGUtils.vgCreateColorPaint(vg, "7FB22222"); // 50% opacity jade green

Parameters:
vg - The OpenVG renderer.
argb - Hexadecimal color string of format "#AARRGGBB", "#RRGGBB", "AARRGGBB" or "RRGGBB".
Returns:
The VGPaint object created or VG_INVALID_HANDLE if insufficient memory is available to allocate a new object.
Throws:
IllegalArgumentException - if vg is null.
NumberFormatException - If argb is null or it contains non-hexadecimal characters besides the initial '#' or the string is too long.
Since:
BlackBerry API 7.0.0

vgCreateLinearGradientPaint

public static int vgCreateLinearGradientPaint(VG vg,
                                              float x0,
                                              float y0,
                                              float x1,
                                              float y1,
                                              float[] stops)
Creates a VGPaint with the paint type set to VG_PAINT_TYPE_LINEAR_GRADIENT.

Linear gradients define a scalar-valued gradient function based on two points (x0, y0) and (x1, y1) (in the paint coordinate system) with the following properties:

Color Stops

A stop is defined by an offset between 0 and 1, inclusive, and a color value. Each stop is defined by 4 float values in the order [Stop, Red, Green, Blue, Alpha]. Stops must be specified in increasing order; if they are not, the entire sequence is ignored. Stops with offsets less than 0 or greater than 1 are ignored.

If a color or alpha value of a given stop falls outside of the range [0, 1], the closest endpoint of the range is used instead.

Example

 float[] stops = {0.0f, 0.0f, 1.0f, 1.0f, 1.0f,   // stop 0, cyan, opaque
                  0.5f, 1.0f, 1.0f, 0.0f, 0.5f,   // stop 0.5, yellow, 50% opacity
                  1.0f, 1.0f, 0.4f, 0.0f, 0.75f}; // stop 1.0, orange, 75% opacity
 int paint = VGUtils.vgCreateLinearGradientPaint(vg, 100, 100, 300, 200, stops);

Additional Gradient Parameters

Parameters:
vg - The OpenVG renderer.
x0 - X-coordinate of start point.
y0 - Y-coordinate of start point.
x1 - X-coordinate of end point.
y1 - Y-coordinate of end point.
stops - Array of color stops. If null or no valid stops are specified, a stop at 0 with color opaque black and a stop at 1 with color opaque white is implicitly defined.
Returns:
The VGPaint object created or VG_INVALID_HANDLE if insufficient memory is available to allocate a new object.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vgCreateRadialGradientPaint

public static int vgCreateRadialGradientPaint(VG vg,
                                              float cx,
                                              float cy,
                                              float fx,
                                              float fy,
                                              float r,
                                              float[] stops)
Creates a VGPaint with the paint type set to VG_PAINT_TYPE_RADIAL_GRADIENT.

Radial gradients define a scalar-valued gradient function based on a gradient circle defined by a center point (cx, cy), a radius r, and a focal point (fx, fy) that is forced to lie within the circle. All parameters are given in the paint coordinate system.

If (fx, fy) lies outside the circumference of the circle, the intersection of the line from the center to the focal point with the circumference of the circle is used as the focal point in place of the specified point.

Color Stops

A stop is defined by an offset between 0 and 1, inclusive, and a color value. Each stop is defined by 4 float values in the order [Stop, Red, Green, Blue, Alpha]. Stops must be specified in increasing order; if they are not, the entire sequence is ignored. Stops with offsets less than 0 or greater than 1 are ignored.

If a color or alpha value of a given stop falls outside of the range [0, 1], the closest endpoint of the range is used instead.

Example

 float[] stops = {0.0f, 0.0f, 1.0f, 1.0f, 1.0f,   // stop 0, cyan, opaque
                  0.5f, 1.0f, 1.0f, 0.0f, 0.5f,   // stop 0.5, yellow, 50% opacity
                  1.0f, 1.0f, 0.4f, 0.0f, 0.75f}; // stop 1.0, orange, 75% opacity
 int paint = VGUtils.vgCreateRadialGradientPaint(vg, 200.0f, 200.0f, 250.0f, 250.0f, 100.0f, stops);

Additional Gradient Parameters

Parameters:
vg - The OpenVG renderer.
cx - X-coordinate of center point.
cy - Y-coordinate of center point.
fx - X-coordinate of focal point.
fy - Y-coordinate of focal point.
r - Radius of the circle.
stops - Array of color stops. If null or no valid stops are specified, a stop at 0 with color opaque black and a stop at 1 with color opaque white is implicitly defined.
Returns:
The VGPaint object created or VG_INVALID_HANDLE if insufficient memory is available to allocate a new object.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 7.0.0

vguLine

public static int vguLine(VG vg,
                          int path,
                          float x0,
                          float y0,
                          float x1,
                          float y1)
Appends a line segment to a path.

Equivalent to the following pseudo-code:

  LINE(x0, y0, x1, y1):
 
  MOVE_TO_ABS x0, y0
  LINE_TO_ABS x1, y1

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
x0 - The line starting x coordinate.
y0 - The line starting y coordinate.
x1 - The line ending x coordinate.
y1 - The line ending y coordinate.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguPolygon

public static int vguPolygon(VG vg,
                             int path,
                             float[] points,
                             int offset,
                             int count,
                             boolean closed)
Appends a polyline or polygon to a path.

Equivalent to the following pseudo-code:

  POLYGON(points, count):
  
  MOVE_TO_ABS points[0], points[1]
  for (i = 1; i < count; i++) 
  { 
      LINE_TO_ABS points[2*i], points[2*i + 1]
  }
  if (closed) 
      CLOSE_PATH

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR VGU_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
points - There are 2 * count coordinates in points.
offset - The offset into the points array.
count - The number of coordinte pairs in the polygon.
closed - true if the polygon should be closed.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if points.length - offset is less than count * 2.
Since:
BlackBerry API 6.0.0

vguPolygon

public static int vguPolygon(VG vg,
                             int path,
                             FloatBuffer points,
                             boolean closed)
The floating-point Buffer version of vguPolygon.

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
points - The points data.
closed - true if the polygon should be closed.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguRect

public static int vguRect(VG vg,
                          int path,
                          float x,
                          float y,
                          float width,
                          float height)
Appends an axis-aligned rectangle with its lower-left corner at (x, y) and a given width and height to a path.

Equivalent to the following pseudo-code:

 RECT(x, y, width, height):
 
 MOVE_TO_ABS x, y
 HLINE_TO_REL width
 VLINE_TO_REL height
 HLINE_TO_REL -width
 CLOSE_PATH

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR VGU_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
x - The rectangle starting x coordinate.
y - The rectangle starting y coordinate.
width - The rectangle width.
height - The rectangle height.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguRoundRect

public static int vguRoundRect(VG vg,
                               int path,
                               float x,
                               float y,
                               float width,
                               float height,
                               float arcWidth,
                               float arcHeight)
Appends an axis-aligned round-cornered rectangle with the lower-left corner of its rectangular bounding box at (x, y) and a given width, height, arcWidth, and arcHeight to a path. The arcs are included even when arcWidth and/or arcHeight is 0.

Equivalent to the following pseudo-code:

 ROUNDRECT(x, y, w, h, arcWidth, arcHeight):
 
 MOVE_TO_ABS (x + arcWidth/2), y
 HLINE_TO_REL width – arcWidth
 SCCWARC_TO_REL arcWidth/2, arcHeight/2, 0, arcWidth/2, arcHeight/2
 VLINE_TO_REL height – arcHeight
 SCCWARC_TO_REL arcWidth/2, arcHeight/2, 0, -arcWidth/2, arcHeight/2
 HLINE_TO_REL -(width – arcWidth)
 SCCWARC_TO_REL arcWidth/2, arcHeight/2, 0, -arcWidth/2, -arcHeight/2
 VLINE_TO_REL -(height – arcHeight)
 SCCWARC_TO_REL arcWidth/2, arcHeight/2, 0, arcWidth/2, -arcHeight/2
 CLOSE_PATH

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR VGU_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
x - The rectangle starting x coordinate.
y - The rectangle starting y coordinate.
width - The rectangle width.
height - The rectangle height.
arcWidth - The rectangle arc width. If arcWidth is less than 0, it is clamped to 0. If arcWidth is greater than width, its value is clamped to that of width.
arcHeight - The rectangle arc height. If arcHeight is less than 0, it is clamped to 0. If arcHeight is greater than height, its value is clamped to that of height.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguEllipse

public static int vguEllipse(VG vg,
                             int path,
                             float cx,
                             float cy,
                             float width,
                             float height)
Appends an axis-aligned ellipse to a path. The center of the ellipse is given by (cx, cy) and the dimensions of the axis-aligned rectangle enclosing the ellipse are given by width and height. The ellipse begins at (cx + width/2, cy) and is stroked as two equal counter-clockwise arcs.

Equivalent to the following pseudo-code:

 ELLIPSE(cx, cy, width, height):
 
 MOVE_TO_ABS cx + width/2, cy
 SCCWARC_TO_REL width/2, height/2, 0, -width, 0
 SCCWARC_TO_REL width/2, height/2, 0, width, 0
 CLOSE_PATH

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR VGU_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
cx - The ellipse starting center x coordinate.
cy - The ellipse starting center y coordinate.
width - The rectangle width.
height - The rectangle height.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguArc

public static int vguArc(VG vg,
                         int path,
                         float x,
                         float y,
                         float width,
                         float height,
                         float startAngle,
                         float angleExtent,
                         int arcType)
Appends an elliptical arc to a path, possibly along with one or two line segments, according to the arcType parameter. The startAngle and angleExtent parameters are given in degrees, proceeding counter-clockwise from the positive X axis. The arc is defined on the unit circle, then scaled by the width and height of the ellipse; thus, the starting point of the arc has coordinates (x + cos(startAngle)*w/2, y + sin(startAngle)*h/2) and the ending point has coordinates (x + cos(startAngle + angleExtent)*w/2, y + sin(startAngle + angleExtent)*h/2). If angleExtent is negative, the arc will proceed clockwise; if it is larger than 360 or smaller than -360, the arc will wrap around itself.

Defines three values to control the style of arcs drawn by the vguArc function:

  VGU_ARC_OPEN – arc segment only
  VGU_ARC_CHORD – arc, plus line between arc endpoints
  VGU_ARC_PIE – arc, plus lines from each endpoint to the ellipse center.

Equivalent to the following pseudo-code:

 ARC(x, y, w, h, startAngle, angleExtent, arcType):
 
 last = startAngle + angleExtent
 MOVE_TO_ABS x+cos(startAngle)*w/2, y+sin(startAngle)*h/2
 if (angleExtent > 0) 
 {     
  angle = startAngle + 180 
  while (angle < last) 
  { 
      SCCWARC_TO_ABS w/2, h/2, 0, x+cos(angle)*w/2, y+sin(angle)*h/2 
      angle += 180 
  } 
  SCCWARC_TO_ABS w/2, h/2, 0, x+cos(last)*w/2, y+sin(last)*h/2} 
  else 
  { 
      angle = startAngle – 180 
      while (angle > last) 
      { 
          SCWARC_TO_ABS w/2, h/2, 0, x+cos(angle)*w/2, y+sin(angle)*h/2 
          angle -= 180 
      } 
      SCWARC_TO_ABS w/2, h/2, 0, x+cos(last)*w/2, y+sin(last)*h/2
  }
  if arcType == VGU_ARC_PIE 
      LINE_TO_ABS x, y
  if arcType == VGU_ARC_PIE || arcType == VGU_ARC_CHORD 
      CLOSE_PATH

Errors

VGU_BAD_HANDLE_ERROR VGU_PATH_CAPABILITY_ERROR VGU_ILLEGAL_ARGUMENT_ERROR

Parameters:
vg - The OpenVG renderer.
path - The path to be appended to.
x - The starting x coordinate.
y - The starting y coordinate.
width - The rectangle width.
height - The rectangle height.
startAngle - The starting angle in degrees.
angleExtent - The angle extent in degrees.
arcType - The type of arc.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
Since:
BlackBerry API 6.0.0

vguComputeWarpQuadToSquare

public static int vguComputeWarpQuadToSquare(VG vg,
                                             float sx0,
                                             float sy0,
                                             float sx1,
                                             float sy1,
                                             float sx2,
                                             float sy2,
                                             float sx3,
                                             float sy3,
                                             float[] matrix,
                                             int offset)
Sets the entries of matrix to a projective transformation that maps the point: (sx0, sy0) to (0, 0); (sx1, sy1) to (1, 0); (sx2, sy2) to (0, 1); and (sx3, sy3) to (1, 1).

Errors

VGU_ILLEGAL_ARGUMENT_ERROR VGU_BAD_WARP_ERROR

Parameters:
vg - The OpenVG renderer.
sx0 - Warp point (0,0), x coordinate.
sy0 - Warp point (0,0), y coordinate.
sx1 - Warp point (1,0), x coordinate.
sy1 - Warp point (1,0), y coordinate.
sx2 - Warp point (0,1), x coordinate.
sy2 - Warp point (0,1), y coordinate.
sx3 - Warp point (1,1), x coordinate.
sy3 - Warp point (1,1), y coordinate.
matrix - The matrix to be projected onto.
offset - The matrix array offset.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if matrix.length - offset is less than 9.
Since:
BlackBerry API 6.0.0

vguComputeWarpQuadToSquare

public static int vguComputeWarpQuadToSquare(VG vg,
                                             float sx0,
                                             float sy0,
                                             float sx1,
                                             float sy1,
                                             float sx2,
                                             float sy2,
                                             float sx3,
                                             float sy3,
                                             FloatBuffer buffer)
The floating-point Buffer version of vguComputeWarpQuadToSquare.

Parameters:
vg - The OpenVG renderer.
sx0 - Warp point (0,0), x coordinate.
sy0 - Warp point (0,0), y coordinate.
sx1 - Warp point (1,0), x coordinate.
sy1 - Warp point (1,0), y coordinate.
sx2 - Warp point (0,1), x coordinate.
sy2 - Warp point (0,1), y coordinate.
sx3 - Warp point (1,1), x coordinate.
sy3 - Warp point (1,1), y coordinate.
buffer - The matrix to be projected onto.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if buffer.GetRemaining() is less than 9.
Since:
BlackBerry API 6.0.0

vguComputeWarpSquareToQuad

public static int vguComputeWarpSquareToQuad(VG vg,
                                             float dx0,
                                             float dy0,
                                             float dx1,
                                             float dy1,
                                             float dx2,
                                             float dy2,
                                             float dx3,
                                             float dy3,
                                             float[] matrix,
                                             int offset)
Sets the entries of matrix to a projective transformation that maps the point: (0, 0) to (dx0, dy0); (1, 0) to (dx1, dy1); (0, 1) to (dx2, dy2); and (1, 1) to (dx3, dy3).

If no non-degenerate matrix satisfies the constraints, VGU_BAD_WARP_ERROR is returned and matrix is unchanged.

Errors

VGU_ILLEGAL_ARGUMENT_ERROR VGU_BAD_WARP_ERROR

Parameters:
vg - The OpenVG renderer.
dx0 - Warp point (0,0), x coordinate.
dy0 - Warp point (0,0), y coordinate.
dx1 - Warp point (1,0), x coordinate.
dy1 - Warp point (1,0), y coordinate.
dx2 - Warp point (0,1), x coordinate.
dy2 - Warp point (0,1), y coordinate.
dx3 - Warp point (1,1), x coordinate.
dy3 - Warp point (1,1), y coordinate.
matrix - The matrix to be projected onto.
offset - The matrix array offset.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if matrix.length - offset is less than 9.
Since:
BlackBerry API 6.0.0

vguComputeWarpSquareToQuad

public static int vguComputeWarpSquareToQuad(VG vg,
                                             float dx0,
                                             float dy0,
                                             float dx1,
                                             float dy1,
                                             float dx2,
                                             float dy2,
                                             float dx3,
                                             float dy3,
                                             FloatBuffer buffer)
The floating-point Buffer version of vguComputeWarpSquareToQuad.

Parameters:
vg - The OpenVG renderer.
dx0 - Warp point (0,0), x coordinate.
dy0 - Warp point (0,0), y coordinate.
dx1 - Warp point (1,0), x coordinate.
dy1 - Warp point (1,0), y coordinate.
dx2 - Warp point (0,1), x coordinate.
dy2 - Warp point (0,1), y coordinate.
dx3 - Warp point (1,1), x coordinate.
dy3 - Warp point (1,1), y coordinate.
buffer - The matrix to be projected onto.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if buffer.GetRemaining() is less than 9.
Since:
BlackBerry API 6.0.0

vguComputeWarpQuadToQuad

public static int vguComputeWarpQuadToQuad(VG vg,
                                           float dx0,
                                           float dy0,
                                           float dx1,
                                           float dy1,
                                           float dx2,
                                           float dy2,
                                           float dx3,
                                           float dy3,
                                           float sx0,
                                           float sy0,
                                           float sx1,
                                           float sy1,
                                           float sx2,
                                           float sy2,
                                           float sx3,
                                           float sy3,
                                           float[] matrix,
                                           int offset)
Sets the entries of matrix to a projective transformation that maps the point: (sx0, sy0) to (dx0, dy0); (sx1, sy1) to (dx1, dy1); (sx2, sy2) to (dx2, dy2); and (sx3, sy3) to (dx3, dy3).

Errors

VGU_ILLEGAL_ARGUMENT_ERROR VGU_BAD_WARP_ERROR

Parameters:
vg - The OpenVG renderer.
dx0 - Destination quad, warp point (0,0), x coordinate.
dy0 - Destination quad, warp point (0,0), y coordinate.
dx1 - Destination quad, warp point (1,0), x coordinate.
dy1 - Destination quad, warp point (1,0), y coordinate.
dx2 - Destination quad, warp point (0,1), x coordinate.
dy2 - Destination quad, warp point (0,1), y coordinate.
dx3 - Destination quad, warp point (1,1), x coordinate.
dy3 - Source quad, warp point (1,1), y coordinate.
sx0 - Source quad, warp point (0,0), x coordinate.
sy0 - Source quad, warp point (0,0), y coordinate.
sx1 - Source quad, warp point (1,0), x coordinate.
sy1 - Source quad, warp point (1,0), y coordinate.
sx2 - Source quad, warp point (0,1), x coordinate.
sy2 - Source quad, warp point (0,1), y coordinate.
sx3 - Source quad, warp point (1,1), x coordinate.
sy3 - Source quad, warp point (1,1), y coordinate.
matrix - The matrix to be projected onto.
offset - The matrix array offset.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if matrix.length - offset is less than 9.
Since:
BlackBerry API 6.0.0

vguComputeWarpQuadToQuad

public static int vguComputeWarpQuadToQuad(VG vg,
                                           float dx0,
                                           float dy0,
                                           float dx1,
                                           float dy1,
                                           float dx2,
                                           float dy2,
                                           float dx3,
                                           float dy3,
                                           float sx0,
                                           float sy0,
                                           float sx1,
                                           float sy1,
                                           float sx2,
                                           float sy2,
                                           float sx3,
                                           float sy3,
                                           FloatBuffer buffer)
The floating-point Buffer version of vguComputeWarpQuadToQuad.

Parameters:
vg - The OpenVG renderer.
dx0 - Destination quad, warp point (0,0), x coordinate.
dy0 - Destination quad, warp point (0,0), y coordinate.
dx1 - Destination quad, warp point (1,0), x coordinate.
dy1 - Destination quad, warp point (1,0), y coordinate.
dx2 - Destination quad, warp point (0,1), x coordinate.
dy2 - Destination quad, warp point (0,1), y coordinate.
dx3 - Destination quad, warp point (1,1), x coordinate.
dy3 - Source quad, warp point (1,1), y coordinate.
sx0 - Source quad, warp point (0,0), x coordinate.
sy0 - Source quad, warp point (0,0), y coordinate.
sx1 - Source quad, warp point (1,0), x coordinate.
sy1 - Source quad, warp point (1,0), y coordinate.
sx2 - Source quad, warp point (0,1), x coordinate.
sy2 - Source quad, warp point (0,1), y coordinate.
sx3 - Source quad, warp point (1,1), x coordinate.
sy3 - Source quad, warp point (1,1), y coordinate.
buffer - The matrix to be projected onto.
Returns:
The vgu error code.
Throws:
IllegalArgumentException - if vg is null.
IllegalArgumentException - if buffer.GetRemaining() is less than 9.
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal