|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.ui.Graphics
Provides a surface on which applications can draw.
A graphics object encapsulates the state information needed for basic rendering operations, making it accessible to applications (for example, the current font, and drawing color).
Example
g = getGraphics();
// draw here
pushContext(...);
draw(g);
popContext();
draw(Graphics g) {
// draw or fill various objects
// might {push, recurse paint(), pop}
}
The context stack
Typically your application maintains one graphics object for each screen it
must present to the user. Each manager controlled by the screen uses that
graphics object to handle the layout and painting of each field the manager
contains.
To accomodate this model, the graphics object maintains an internal context stack. Each stack element contains information about the current drawing context, including the clipping region, the drawing offset and the current foreground colour.
Typically, a field's manager pushes a transform on the stack that describes the field's extent as the clipping region, and a drawing offset to position drawing. Then it hands the graphics object to the field when it requests the field to update itself.
Each transform pushed onto the stack describes the transform in terms of the parent coordinates, so that each draw operation can be done using local coordinates and translated back through the stack to finally appear on the appropriate location of the screen.
The drawing anchor
When you use one of this class's methods to draw an object, or text, you must
set the drawing anchor. This anchor describes the pixel in the
drawing region where the invoked method begins to draw. The coordinate system
for the drawing anchor assumes that the top left pixel in the region is
coordinate 0,0.
The drawing anchor is not persistent. Each time you call one of these methods, you must provide a position for the anchor, and if maintaining information about relative positions of the anchor is important, then your code must do that.
What happens to clipped objects
When you draw an object and the size of that object would have a portion of
it fall outside the clipping region, then those portions are clipped off
(i.e. the object or text is cropped to fit the clipping region).
Rendering text
This class provides a variety of drawText methods you use to
render text on the drawing region. The most fundamental of these methods
renders a single character's glyph on the drawing region. The exact position
of the drawn glyph, with respect to the drawing anchor, is determined by a
combination of constant drawing style values inherited from the
DrawStyle interface.
| The drawn glyph appears... | ||||
| LEFT | RIGHT | HCENTER | HFULL | |
|---|---|---|---|---|
| TOP | Below and to the right of the drawing anchor. | Below and to the left of the drawing anchor. | Below and horizontally centered on the drawing anchor. | N/A |
| BOTTOM | Above and to the right of the drawing anchor. | Above and to the left of the drawing anchor. | Above and horizontally centered on the drawing anchor. | N/A |
| BASELINE | Baseline to the right of the drawing anchor. | Baseline to the left of the drawing ancrho. | Baseline horizontally centered on the drawing anchor. | N/A |
| VCENTER | Center of left edge to the right of the drawing anchor. | Center of right edge to the left of the drawing anchor. | Absolute center of glyph on the drawing anchor. | N/A |
Note: the HFULL drawing position flag, to fully
justify text, has not yet been implemented.
By default, the drawText methods assume the drawing position
flags (TOP | LEFT). You can request another method of drawing
the glyphs by passing other combinations of this class's constant drawing
position values.
What happens to clipped text
The mechanism for handling clipping with drawText operations is
slightly more complex.
The text drawing methods clip in two ways: pixels that fall outside the
general clipping region, and pixels that fall outside a text width
parameter specified to the appropriate drawText method. Text
drawing methods that don't support a text width parameter assume a width
that's the equal to the width of the entire set of text glyphs they are to
draw.
If you pass the ELLIPSIS constant to a drawText
method, in combination with the drawing position constants, then clipping by
the text width parameter is handled specially. The method replaces the last
fully rendered glyph, and any pixels of a partially rendered glyph, with the
ellipsis glyph. If the ellipsis glyph would be clipped by the text width
parameter, then no ellipsis character appears to replace the glyphs clipped.
Width of text rendered
All of the drawText methods return the number of pixels of
block width of text drawn. Imagine that each glyph is mounted on a
little block that you would press onto paper to print the glyph. The
block width of a glyph is the size of that block: in all cases,
therefore, the block width is wider than the width of pixels used to actually
draw the glyph, since the block width also includes spacing pixels along the
right hand side to accomodate following glyphs.
You should also note that the block width of drawn text returned by the
drawText methods includes any pixels that are clipped
by the clipping region. However, if you pass a width parameter into the
drawText method to constrain the region available for drawing,
and this width parameter clips the drawn text, the clipped pixels do
not count in the width of text rendered returned by the method.
Italic text
Note that the "blocks" of italic glyphs form a parallelogram, not a
rectangle. The blocks lean over to ensure that italic characters positioned
next to one another will kern properly. When rendering italic text, the block
width returned by the drawText method measures the width from
one side of the parallelogram block to the other just as it does with roman
glyphs (and not from bottom-left corner across to a vertical line
dropped from top-right corner).
This means that a non-italic glyhph rendered just next to an italic glyph may occlude the leaning corner of the italic glyph.
| Field Summary | ||
static int |
BLACK
Black (0x00101010). |
|
static byte |
CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT
Cubic bezier control-point type for drawing paths. |
|
static byte |
CURVEDPATH_END_POINT
End-point type for drawing paths. |
|
static byte |
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT
Quadratic bezier control-point type for drawing paths. |
|
|
static int |
DRAWSTYLE_AALINES
Drawing style for anti-aliased rendering of lines, used by setDrawingStyle(int, boolean) and isDrawingStyleSet(int). |
|
static int |
DRAWSTYLE_AAPOLYGONS
Drawing style for anti-aliased rendering of polygons, used by setDrawingStyle(int, boolean) and isDrawingStyleSet(int). |
|
static int |
DRAWSTYLE_FOCUS
This style is set by the framework when painting is being done for focus drawing. |
|
static int |
DRAWSTYLE_SELECT
This style is set by the framework when painting is being done for selection drawing. |
static int |
FULL_BLACK
Full black (0x00000000). |
|
static int |
FULL_WHITE
Full white (0x00ffffff). |
|
|
static int |
ROP_CONST_GLOBALALPHA
Raster operation constant for blending the constant foreground colour, using a constant global alpha value with destination pixels. |
static int |
ROP_SRC_ALPHA
Raster operation constant for normal bitmap copy with an alpha channel. |
|
|
static int |
ROP_SRC_ALPHA_GLOBALALPHA
Raster operation constant for blending a source bitmap with an alpha channel and a constant global alpha value with destination pixels. |
static int |
ROP_SRC_COPY
Raster operation constant for normal bitmap copy. |
|
|
static int |
ROP_SRC_GLOBALALPHA
Raster operation constant for blending a source bitmap using a constant global alpha value with destination pixels. |
static int |
ROP_SRCMONOEXPAND_ALPHA
Raster operation constant for expanding a monochrome source bitmap with current foreground and background drawing colours, respecting the alpha channel. |
|
static int |
ROP_SRCMONOEXPAND_COPY
Raster operation constant for expanding a monochrome source bitmap with the current foreground and background drawing colours. |
|
static int |
ROP2_0
Binary raster op constant for zeroing out the destination. |
|
static int |
ROP2_1
Binary raster op constant for filling dest with 1 values. |
|
static int |
ROP2_D
Binary raster op constant for nop. |
|
static int |
ROP2_Dn
Binary raster op constant for invert destination. |
|
static int |
ROP2_DSa
Binary raster op constant for masking ( source and dest ). |
|
static int |
ROP2_DSan
Binary raster op constant for ( not ( source and dest ) ). |
|
static int |
ROP2_DSna
Binary raster op constant for ( ( not source ) and dest ). |
|
static int |
ROP2_DSno
Binary raster op constant for ( ( not source ) or dest ). |
|
static int |
ROP2_DSo
Binary raster op constant for ( source or dest ). |
|
static int |
ROP2_DSon
Binary raster op constant for ( not ( source or dest ) ). |
|
static int |
ROP2_DSx
Binary raster op constant for selective invert ( source xor dest ). |
|
static int |
ROP2_DSxn
Binary raster op constant for ( not ( source xor dest ) ). |
|
static int |
ROP2_S
Binary raster op constant for normal source copy. |
|
static int |
ROP2_SDna
Binary raster op constant for ( ( not dest ) and source ). |
|
static int |
ROP2_SDno
Binary raster op constant for ( source or ( not dest ) ). |
|
static int |
ROP2_Sn
Binary raster op constant for ( not source ). |
|
static boolean |
SCREEN_HAS_BORDER
Does the screen have a lit border around the drawable area of the screen? |
|
static int |
WHITE
White (0x00EBEBEB). |
|
| Fields inherited from interface net.rim.device.api.ui.DrawStyle |
BASELINE, BOTTOM, ELLIPSIS, HALIGN_MASK, HCENTER, HDEFAULT, HFULL, LEADING, LEFT, RIGHT, TOP, TRAILING, TRUNCATE_BEGINNING, VALIGN_MASK, VCENTER, VDEFAULT, VFULL |
| Constructor Summary | ||
Graphics(Bitmap bitmap)
Constructs a Graphics object for drawing to a bitmap. |
||
| Method Summary | ||
void |
clear()
Clears the entire graphics area to the current background. |
|
void |
clear(int x,
int y,
int width,
int height)
Clears a region to the current background. |
|
void |
clear(XYRect region)
Clears a region specified by an XYRect object to the current background. |
|
boolean |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Copies a region of this graphics canvas. |
|
boolean |
copyArea(XYRect region,
int dx,
int dy)
Copies a region of this graphics canvas, specified by an XYRect. |
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws an arc through a specified rectangle. |
|
void |
drawARGB(int[] data,
int offset,
int scanLength,
int x,
int y,
int width,
int height)
Similar to drawRGB, but source data also contains alpha. |
|
void |
drawBitmap(int x,
int y,
int width,
int height,
Bitmap bitmap,
int left,
int top)
Draws a bitmap. |
|
void |
drawBitmap(XYRect dest,
Bitmap bitmap,
int left,
int top)
Draws a bitmap on a region specified by an XYRect object. |
|
void |
drawEllipse(int cx,
int cy,
int px,
int py,
int qx,
int qy,
int startAngle,
int arcAngle)
Draws an ellipse. |
|
void |
drawFilledPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets)
Draws a set of filled paths. |
|
void |
drawImage(int x,
int y,
int width,
int height,
EncodedImage image,
int frameIndex,
int left,
int top)
Draws an encoded image. |
|
void |
drawImage(XYRect dest,
EncodedImage image,
int frameIndex,
int left,
int top)
Draws an encoded image on a region specified by an XYRect object. |
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line. |
|
void |
drawPathOutline(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets,
boolean closed)
Draw a set of path outlines. |
|
void |
drawPoint(int x,
int y)
Draws a point. |
|
void |
drawRect(int x,
int y,
int width,
int height)
Draws a rectangle. |
|
void |
drawRGB(int[] data,
int offset,
int scanLength,
int x,
int y,
int width,
int height)
Draws raw RGB data from an int array. |
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rectangle with rounded edges. |
|
|
void |
drawShadedFilledPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] colors,
int[] offsets)
Draws a set of shaded filled paths. |
int |
drawText(byte[] text,
int offset,
int len,
int x,
int y,
int flags,
int width)
Draws text contained in a byte array. |
|
int |
drawText(char[] text,
int offset,
int len,
int x,
int y,
int flags,
int width)
Draws text contained in a char array. |
|
int |
drawText(char character,
int x,
int y,
int flags,
int width)
Draws a text character. |
|
int |
drawText(StringBuffer text,
int offset,
int len,
int x,
int y,
int flags,
int width)
Draws text contained in a string buffer. |
|
int |
drawText(String text,
int x,
int y)
Draws a text string. |
|
int |
drawText(String text,
int x,
int y,
int flags)
Draws a text string with specified positioning. |
|
int |
drawText(String text,
int x,
int y,
int flags,
int width)
Draws text within a specified width. |
|
int |
drawText(String text,
int offset,
int len,
int x,
int y,
int flags,
int width)
Draws text contained in a string. |
|
void |
drawTexturedPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets,
int xOrigin,
int yOrigin,
int dux,
int dvx,
int duy,
int dvy,
Bitmap textureData)
Draws a set of texture-filled paths. |
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills a circular or elliptical arc covering a specified rectangle. |
|
void |
fillEllipse(int cx,
int cy,
int px,
int py,
int qx,
int qy,
int startAngle,
int arcAngle)
Fills an ellipse. |
|
void |
fillRect(int x,
int y,
int width,
int height)
Fills a rectangle. |
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills a rectangle with rounded edges. |
|
void |
getAbsoluteClippingRect(XYRect clip)
Retreives the absolute coordinates of current clipping region. |
|
int |
getBackgroundColor()
Retrieves the current background color. |
|
XYRect |
getClippingRect()
Retrieves the local coordinates of current clipping region. |
|
int |
getColor()
Retrieves the current foreground drawing color. |
|
int |
getContextStackSize()
Retrieves the size of the stack of drawing contexts. |
|
void |
getDrawingOffset(XYPoint offset)
Retrieves the absolute coordinates for the current drawing offset. |
|
Font |
getFont()
Retrieves the current font for the current graphics context. |
|
|
int |
getGlobalAlpha()
Retrieves the current global alpha value. |
|
static int |
getNumColors()
Retrieve the number of colors that the device's screen can display. |
static int |
getScreenHeight()
Retrieves total drawing height of the screen. |
|
static int |
getScreenHorizontalResolution()
Retrieve screen's horizontal resolution in pixels per meter (PPM). |
|
static int |
getScreenVerticalResolution()
Retrieve screen's vertical resolution in pixels per meter (PPM). |
|
static int |
getScreenWidth()
Retrieves total drawing width of the screen. |
|
int |
getStipple()
Retrieves the current line stippling value. |
|
int |
getTranslateX()
Retrieves the horizontal component of the current drawing offset. |
|
int |
getTranslateY()
Retrieves the vertical component of the current drawing offset. |
|
void |
invert(int x,
int y,
int width,
int height)
Inverts a region. |
|
void |
invert(XYRect rect)
Inverts a region specified by an XYRect object. |
|
|
static boolean |
isColor()
Determines if the device has a color display. |
|
boolean |
isDrawingStyleSet(int drawStyle)
Determines whether the specified drawing style is turned on. |
|
boolean |
isRopSupported(int rop)
Determines if a raster operation is supported. |
void |
popContext()
Pops a drawing context off the stack. |
|
boolean |
pushContext(int x,
int y,
int width,
int height,
int xOffset,
int yOffset)
Pushes a clipping region (and optional drawing offset) onto the context stack. |
|
boolean |
pushContext(XYRect clip,
int xOffset,
int yOffset)
Pushes a clipping region (and optional drawing offset) onto the context stack. |
|
boolean |
pushRegion(int x,
int y,
int width,
int height,
int xScroll,
int yScroll)
Pushes a drawing region (and optional scroll offset) onto the context stack. |
|
boolean |
pushRegion(XYRect region)
Pushes a drawing region onto the context stack, specified by a XYRect object. |
|
boolean |
pushRegion(XYRect region,
int xScroll,
int yScroll)
Pushes a drawing region (and optional scroll offset) onto the context stack. |
|
void |
rop(int rop,
int x,
int y,
int width,
int height,
Bitmap source,
int left,
int top)
Executes an area raster operation on the specified region. |
|
void |
setBackgroundColor(int RGB)
Sets the current background color. |
|
void |
setColor(int RGB)
Sets the current color. |
|
|
void |
setDrawingStyle(int drawStyle,
boolean on)
Sets the current drawing style. |
void |
setFont(Font font)
Sets the current font for the current graphics context. |
|
|
void |
setGlobalAlpha(int alpha)
Sets the current global alpha value for drawing operations. |
void |
setStipple(int mask)
Sets the current line stippling value. |
|
void |
tileRop(int rop,
int x,
int y,
int width,
int height,
Bitmap source,
int left,
int top)
Executes an area raster operation on the specified region, tiling the source bitmap if necessary. |
|
void |
translate(int x,
int y)
Apply a translation to the current drawing offset. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ROP_SRC_COPY
public static final int ROP_SRCMONOEXPAND_COPY
public static final int ROP_SRC_ALPHA
public static final int ROP_SRCMONOEXPAND_ALPHA
public static final int ROP_CONST_GLOBALALPHA
Set the global alpha value using setGlobalAlpha(int).
public static final int ROP_SRC_GLOBALALPHA
Set the global alpha value using setGlobalAlpha(int).
public static final int ROP_SRC_ALPHA_GLOBALALPHA
Set the global alpha value using setGlobalAlpha(int).
public static final int ROP2_0
public static final int ROP2_DSon
public static final int ROP2_DSna
public static final int ROP2_Sn
public static final int ROP2_SDna
public static final int ROP2_Dn
public static final int ROP2_DSx
public static final int ROP2_DSan
public static final int ROP2_DSa
public static final int ROP2_DSxn
public static final int ROP2_DSno
public static final int ROP2_S
public static final int ROP2_SDno
public static final int ROP2_DSo
public static final int ROP2_1
public static final int DRAWSTYLE_AALINES
setDrawingStyle(int, boolean) and isDrawingStyleSet(int).
If this style is set, lines and path outlines may be antialiased.
This style is off by default.
public static final int DRAWSTYLE_AAPOLYGONS
setDrawingStyle(int, boolean) and isDrawingStyleSet(int).
If this style is set, filled paths and polygons may be antialiased.
This style is off by default.
public static final int DRAWSTYLE_FOCUS
public static final int DRAWSTYLE_SELECT
public static final byte CURVEDPATH_END_POINT
A curve or line ends on this point. The value of this constant will always be 0, so it is possible to just create a points array and set only the values of the curves' control points.
public static final byte CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT
The control point of a quadratic bezier is the single point that "stretches" the curve awway from the end points. If a point is a quadratic bezier control point, the points preceeding and succeeding it must be end points.
public static final byte CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT
A control point of a cubic bezier is one of two points that "stretch" the curve awway from the end points. Cubic bezier control points must come in sets of two, with end points coming before the first control point and after the second.
public static final boolean SCREEN_HAS_BORDER
| Constructor Detail |
public Graphics(Bitmap bitmap)
bitmap - Bitmap to draw into.
Must be Bitmap.COLUMNWISE_MONOCHROME or the default type of the
device.IllegalArgumentException - If the type of 'bitmap' is not
supported, or the bitmap is readonly.| Method Detail |
public void clear(int x,
int y,
int width,
int height)
Use this method to clear only a region within the entire graphics area. You specify the region to clear by describing its extent in passed parameters.
x - Left edge of the region.y - Top edge of the region.width - Width of the region.height - Height of the region.public void clear(XYRect region)
Use this method to clear only a region within the entire graphics area. You specify the region to clear with an XYRect that you pass to this method.
region - Rectangular region to clear.
public boolean copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Use this method to copy a region of the drawing buffer. You specify the source region by describing its extent in passed parameters. The source region is left intact (i.e. not cleared).
To paste the copy of the region to the left of or above the drawing
anchor, specify a negative value for the dx or
dy parameters.
If a portion of the source rectangle lies outside the bounds of the
clipping region, this method does not copy the associated pixels. You can
refresh the omitted area by invoking paint on the
component.
This method fails in situations where the pixels are not
available. This can happen when a front buffer screen is obscuring this
graphics context's screen. In this case, this method returns false; you
should then prompt a full repaint by invoking
invalidate on the screen.
x - Left edge of the source region.y - Top edge of the source regionwidth - Width of the source region.height - Height of the source region.dx - Horizontal distance to move the region.dy - Vertical distance to move the region.public boolean copyArea(XYRect region, int dx, int dy)
XYRect.
Use this method to copy a region of the drawing buffer. You specify
the source region with an XYRect that you pass to this
method. The source region is left intact (i.e. not cleared).
To paste the copy of the region to the left of or above the drawing
anchor, specify a negative value for the dx and
dy parameters.
If a portion of the source region lies outside the bounds of the
clipping region, this method does not copy the associated pixels. You can
refresh the omitted area by invoking Field.paint(net.rim.device.api.ui.Graphics) on the component.
This method fails in situations where the pixels are not
available. This can happen when a front buffer screen is obscuring this
graphics context's screen. In this case, this method returns false; you
should then prompt a full repaint by invoking
invalidate on the screen.
region - Source region to copy.dx - Horizontal distance to move the region.dy - Vertical distance to move the region.
public void drawARGB(int[] data,
int offset,
int scanLength,
int x,
int y,
int width,
int height)
data - offset - scanLength - x - y - width - height -
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
The center of the drawn arc is the center of a rectangle whose origin
is (x,y) and whose size is specified by the
width and height parameters.
The arc begins at startAngle and extends for
arcAngle degrees, using the current draw color. The drawing
algorithm assumes that the 0 degree position is in the center of the
right edge of the rectangle. The direction of the arc drawn depends on
the relative values of startAngle and arcAngle:
(startAngle < arcAngle), this method draws the arc
in a counterclockwise direction.
startAngle > arcAngle, this method draws the arc
in a clockwise direction.
The resulting arc covers an area width pixels wide by
height pixels tall and end points are one pixel outside the
extent of the rectangle). If either width or height is less than zero,
this method draws nothing.
The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds. ATTENTION: This method doesn't support transformations specified in the setTransformation method.
x - Horizontal coordinate of the arc's starting position.y - Vertical coordinate of the arc's starting position.width - Width of rectangle containing the arc.height - Height of rectangle containing the arc.startAngle - The angle position at which to commence drawing.arcAngle - Angular extent of the arc, relative to the
start angle.
public void drawEllipse(int cx,
int cy,
int px,
int py,
int qx,
int qy,
int startAngle,
int arcAngle)
Draws an ellipse with the specified endpoints P = (px, py) and Q = (qx, qy) of two conjugate diameters of the ellipse. The endpoints are specified as absolute coordinates.
cx - the x-ordinate of the ellipse centrecy - the y-ordinate of the ellipse centrepx - the x-ordinate of the point Ppy - the y-ordinate of the point Pqx - the x-ordinate of the point Qqy - the y-ordinate of the point QstartAngle - the arc start anglearcAngle - angular extent of the arc, relative to the start anglepublic boolean isRopSupported(int rop)
Use this method to query if a particular raster operation is
supported for the Graphics object. Note that all ROP2s as well as
ROP_SRC_COPY, ROP_SRCMONOEXPAND_COPY,
ROP_SRC_ALPHA and ROP_SRCMONOEXPAND_ALPHA are always
supported.
rop - Constant for the raster operation to query.
public void rop(int rop,
int x,
int y,
int width,
int height,
Bitmap source,
int left,
int top)
Use this method to run a raster operation with or without a source bitmap.
You must specify the extent of the region to draw to, as well as the top left position in the (optional) source bitmap.
rop - Constant for the raster operation to execute.x - Left edge of the destination region.y - Top edge of the destination region.width - Width of the destination region.height - Height of the destination region.source - Source bitmap to use (may be null for some raster operations)left - Left edge of region within bitmap to use.top - Top edge of region within bitmap to use.
public void tileRop(int rop,
int x,
int y,
int width,
int height,
Bitmap source,
int left,
int top)
Use this method to run a raster operation with or without a source bitmap.
You must specify the extent of the region to draw to, as well as the top left position in the (optional) source bitmap.
rop - Constant for the raster operation to execute.x - Left edge of the destination region.y - Top edge of the destination region.width - Width of the destination region.height - Height of the destination region.source - Source bitmap to use (may be null for some raster operations)left - Left edge of region within bitmap to use.top - Top edge of region within bitmap to use.public void drawBitmap(XYRect dest, Bitmap bitmap, int left, int top)
XYRect object.
Use this method to draw a bitmap. You specify the destination region for the bitmap with an XYRect that you pass to this method.
You must also specify the extent of the bitmap to draw (the top left
corner of this extent defined by the top and
left parameters). If a portion of part of the bitmap you
want to draw falls outside the size of the destination region, this
method crops to fit.
dest - Destination region in which to draw the bitmap.bitmap - Bitmap to draw.left - Left edge of region within bitmap to draw.top - Top edge of region within bitmap to draw.
public void drawBitmap(int x,
int y,
int width,
int height,
Bitmap bitmap,
int left,
int top)
Use this method to draw a bitmap. You specify the destination region for the bitmap by describing the extent of the region with passed parameters.
You must also specify the extent of the bitmap to draw (the top left
corner of this extent defined by the top and
left parameters). If a portion of part of the bitmap you
want to draw falls outside the size of the destination region, this
method crops to fit.
Pixels are drawn exactly as in the Bitmap, with no color transformations.
To have a monochrome image act like a rubber stamp, use rop(int, int, int, int, int, net.rim.device.api.system.Bitmap, int, int) with
ROP_SRCMONOEXPAND_COPY or ROP_SRCMONOEXPAND_ALPHA.
x - Left edge of the destination region.y - Top edge of the destination region.width - Width of the destination region.height - Height of the destination region.bitmap - Bitmap to draw.left - Left edge of region within bitmap to draw.top - Top edge of region within bitmap to draw.public void drawImage(XYRect dest, EncodedImage image, int frameIndex, int left, int top)
XYRect object.
Use this method to draw an image. You specify the destination region for the image with an XYRect that you pass to this method.
The region to be drawn is decoded, drawn and then thrown away. Thus
if you plan to draw a full encoded image multiple times it is faster to
first decode into a Bitmap object and draw that.
You must also specify the extent of the image to draw (the top left
corner of this extent defined by the top and
left parameters). If a portion of part of the image you want
to draw falls outside the size of the destination region, this method
crops to fit.
dest - Destination region in which to draw the bitmap.image - Encoded image to drawframeIndex - The frame to drawleft - Left edge of region within bitmap to draw.top - Top edge of region within bitmap to draw.
public void drawImage(int x,
int y,
int width,
int height,
EncodedImage image,
int frameIndex,
int left,
int top)
Use this method to draw an encoded image. You specify the destination region for the bitmap by describing the extent of the region with passed parameters.
The region to be drawn is decoded, drawn and then thrown away. Thus
if you plan to draw a full encoded image multiple times it is faster to
first decode into a Bitmap object and draw that.
You must also specify the extent of the image to draw (the top left
corner of this extent defined by the top and
left parameters). If a portion of part of the image you want
to draw falls outside the size of the destination region, this method
crops to fit.
Pixels are drawn exactly as in the Bitmap, with no color transformations.
To have a monochrome image act like a rubber stamp, use rop(int, int, int, int, int, net.rim.device.api.system.Bitmap, int, int) with
ROP_SRCMONOEXPAND_COPY or ROP_SRCMONOEXPAND_ALPHA.
x - Left edge of the destination region.y - Top edge of the destination region.width - Width of the destination region.height - Height of the destination region.image - Encoded image to draw.frameIndex - The frame to drawleft - Left edge of region within bitmap to draw.top - Top edge of region within bitmap to draw.
public void drawFilledPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets)
Use this method to draw one or more filled non-intersecting paths that contain line segments or curves. You specify the x and y coordinates and point types of the paths desired.
The offsets indicate the beginnings of each path in the data array. The data in the ith path is defined to be the (xPts,yPts) values from offsets[i] to offsets[i+1]-1 inclusive. Thus if there are N values in offsets, there are N-1 paths defined, where the final value is one greater than the offset where the final point of the final path is located in the points data. If offsets is null, the xPts and yPts data will be treated as a single path, and these arrays must have the same length.
The xPts and yPts arrays keep track of each vertex in the polygon and each value in the xPts array must have a corresponding value at the same index in the yPts array, and a corresponding value at the same index in the pointTypes array.
None of the edges in a path may cross any other edge in any of the paths (including itself). If edges do cross, the drawing behaviour is undefined. A path may be fully contained within another path, e.g. a "donut" shape.
The paths are filled by the "even-odd" rule. Thus if a ray is drawn from any point, the area containing the point will be filled if the ray passes through an odd number of edges and will not be filled if is passes through an even number of edges.
Note that each non-null array parameter must be a different array.
xPts - Ordered list of x values for each vertex in the paths.yPts - Ordered list of y values for each vertex in the paths.pointTypes - One of CURVEDPATH_END_POINT,
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
or CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT. There must be one of
these values for each (x,y) point defined. If pointTypes is null, all
point are assumed to be of type CURVEDPATH_END_POINT.
If a point's value is CURVEDPATH_END_POINT, then a line or
curve ends on this point. If a curve control point is next to this
point, a curve will have this point as an endpoint. Otherwise, straight
lines are drawn between successive end points.
If a point's value is CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
the point is a control point for a quadratic bezier. The control point of
a quadratic bezier is the single point that "stretches" the curve away
from the end points. If a point is a quadratic bezier control point, the
points preceeding and succeeding it must be end points
(CURVEDPATH_END_POINT).
If a point's value is CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT,
the point is a control point for a cubic bezier. A cubic bezier has two
control points that "stretch" the curve away from the end points. Cubic
bezier control points must come in sets of two, with end points
(CURVEDPATH_END_POINT) coming before the first control point and
after the second.
offsets - List defining the beginnings of each path in the xPts/yPts
data arrays, or null to indicate a single path. A path that begins at
point (xPts[offsets[i]],yPts[offsets[i]]) will end at point
(xPts[offsets[i+1]]-1,yPts[offsets[i+1]]-1).IllegalArgumentException - If the data is malformed. For example,
the values in offsets is negative or not in increasing order, there are
fewer than 2 points in a single path, the values in offsets index outside
the points arrays, the values in pointTypes are invalid, or offsets is
null and xPts and yPts are not the same length.
public void drawShadedFilledPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] colors,
int[] offsets)
Use this method to draw one or more filled non-intersecting paths that contain line segments and curves. You specify the x and y coordinates and point types of the paths desired as well as the color values of each vertex which will be blended together creating the shading effect.
The offsets indicate the beginnings of each path in the data array. The data in the ith path is defined to be the (xPts,yPts) values from offsets[i] to offsets[i+1]-1 inclusive. Thus if there are N values in offsets, there are N-1 paths defined, where the final value is one greater than the offset where the final point of the final path is located in the points data. If offsets is null, the xPts and yPts data will be treated as a single path, and these arrays must have the same length.
The xPts and yPts arrays keep track of each vertex in the polygon and each value in the xPts array must have a corresponding value at the same index in the yPts array, and a corresponding value at the same index in the pointTypes array. Similarly the color array stores the RGB color of each vertex ( in 0x00RRGGBB format ) and its indices must correspond with those of both the xPts and yPts arrays.
None of the edges in a path may cross any other edge in any of the paths (including itself). If edges do cross, the drawing behaviour is undefined. A path may be fully contained within another path, for example, a "donut" shape.
The paths are filled by the "even-odd" rule. Thus if a ray is drawn from any point, the area containing the point will be filled if the ray passes through an odd number of edges and will not be filled if is passes through an even number of edges.
Note that each non-null array parameter must be a different array.
xPts - Ordered list of x values for each vertex in the paths.yPts - Ordered list of y values for each vertex in the paths.pointTypes - One of CURVEDPATH_END_POINT,
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
or CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT. There must be one of
these values for each (x,y) point defined. If pointTypes is null, all
point are assumed to be of type CURVEDPATH_END_POINT.
If a point's value is CURVEDPATH_END_POINT, then a line or
curve ends on this point. If a curve control point is next to this
point, a curve will have this point as an endpoint. Otherwise, straight
lines are drawn between successive end points.
If a point's value is
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT, the point is a
control point for a quadratic bezier. The control point of a quadratic
bezier is the single point that "stretches" the curve awway from the end
points. If a point is a quadratic bezier control point, the points
preceeding and succeeding it must be end points (CURVEDPATH_END_POINT).
If a point's value is CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT,
the point is a control point for a cubic bezier. A cubic bezier has two
control points that "stretch" the curve away from the end points. Cubic
bezier control points must come in sets of two, with end points
(CURVEDPATH_END_POINT) coming before the first control point and after
the second.
colors - Ordered list of color values for each vertex ( 0x00RRGGBB
format ). If null, a solid filled path will be drawn in the current
foreground color.offsets - List defining the beginnings of each path in the xPts/yPts
data arrays, or null to indicate a single path. A path that begins at
point (xPts[offsets[i]],yPts[offsets[i]]) will end at point
(xPts[offsets[i+1]]-1,yPts[offsets[i+1]]-1).IllegalArgumentException - If the data is malformed. For example,
the values in offsets is negative or not in increasing order, there are
fewer than 2 points in a single path, the values in offsets index outside
the points arrays, the values in pointTypes are invalid, or offsets is
null and xPts and yPts are not the same length.
public void drawPathOutline(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets,
boolean closed)
Use this method to draw a set of path outlines that contains line segments and curves. The xPts and yPts arrays keep track of each vertex in the path. Each value in the xPts array must have corresponding values at the same index in the yPts array and the pointTypes array.
The offsets array keeps track of the locations of each path in the set of paths. If offsets is null, the xPts and yPts data will be treated as a single path, and these arrays must have the same length.
Note that each non-null array parameter must be a different array.
xPts - Ordered list of x values for each vertex in the paths.yPts - Ordered list of y values for each vertex in the paths.pointTypes - One of Graphics.CURVEDPATH_END_POINT,
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
or CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT. There must be one of
these values for each (x,y) point defined. If pointTypes is null, all
point are assumed to be of type CURVEDPATH_END_POINT.
If a point's value is CURVEDPATH_END_POINT, then a line or
curve ends on this point. If a curve control point is next to this
point, a curve will have this point as an endpoint. Otherwise, straight
lines are drawn between successive end points.
If a point's value is CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
the point is a control point for a quadratic bezier. The control point of a
quadratic bezier is the single point that "stretches" the curve awway
from the end points. If a point is a quadratic bezier control point, the
points preceeding and succeeding it must be end points
(CURVEDPATH_END_POINT).
If a point's value is CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT,
the point is a control point for a cubic bezier. A cubic bezier has two
control points that "stretch" the curve away from the end points. Cubic
bezier control points must come in sets of two, with end points
(CURVEDPATH_END_POINT) coming before the first control point and after
the second.
offsets - List defining the beginnings of each path in the xPts/yPts
data arrays, or null to indicate a single path. A path that begins at
point (xPts[offsets[i]],yPts[offsets[i]]) will end at point
(xPts[offsets[i+1]]-1,yPts[offsets[i+1]]-1).closed - If this value is true, each path in the set will be closed
by connecting the final point in the path's data with the first point.IllegalArgumentException - If the data is malformed. e.g. the
values in offsets is negative or not in increasing order, there are fewer
than 2 points in a single path, the values in offsets index outside the
points arrays, the values in pointTypes are invalid, or offsets is null
and xPts and yPts are not the same length.
public void drawTexturedPath(int[] xPts,
int[] yPts,
byte[] pointTypes,
int[] offsets,
int xOrigin,
int yOrigin,
int dux,
int dvx,
int duy,
int dvy,
Bitmap textureData)
Use this method to draw one or more texture-filled non-intersecting paths that contain line segments or curves. You specify the x and y coordinates and point types of the paths desired.
The offsets indicate the beginnings of each path in the data array. The data in the ith path is defined to be the (xPts,yPts) values from offsets[i] to offsets[i+1]-1 inclusive. Thus if there are N values in offsets, there are N-1 paths defined, where the final value is one greater than the offset where the final point of the final path is located in the points data. If offsets is null, the xPts and yPts data will be treated as a single path, and these arrays must have the same length.
The xPts and yPts arrays keep track of each vertex in the polygon and each value in the xPts array must have a corresponding value at the same index in the yPts array, and a corresponding value at the same index in the pointTypes array.
None of the edges in a path may cross any other edge in any of the paths (including itself). If edges do cross, the drawing behaviour is undefined. A path may be fully contained within another path, e.g. a "donut" shape.
The paths are filled by the "even-odd" rule. Thus if a ray is drawn from any point, the area containing the point will be filled if the ray passes through an odd number of edges and will not be filled if is passes through an even number of edges.
The texture used to fill the path is specified as a Bitmap. Starting
from the texture origin (as specified in local coordinates by
xOrigin and yOrigin), the texture is mapped
into the path, being tiled as necessary to fill the region. The scale and
angle used to map the texture are specified by the two walk vectors
(dux, dvx) and (duy,
dvy) (u and v are taked to correspond to x and y, but in
texture space rather than in screen space). dux and
dvx indicate how many u and v coordinates to skip in the
texture per x coordinate on the screen. Likewise, duy and
dvy indicate how texture coordinates to skip per y
coordinate on the screen. These four values are represented in 15.16
fixed point, allowing for eight bits of decimal precision. Using these
walk vectors it is possible to achieve arbitrary rotation, scaling, and
skewing on a given texture.
Note that each non-null array parameter must be a different array.
xPts - Ordered list of x values for each vertex in the paths.yPts - Ordered list of y values for each vertex in the paths.pointTypes - One of CURVEDPATH_END_POINT,
CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
or CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT. There must be one of
these values for each (x,y) point defined. If pointTypes is null, all
point are assumed to be of type CURVEDPATH_END_POINT.
If a point's value is CURVEDPATH_END_POINT, then a line or
curve ends on this point. If a curve control point is next to this point,
a curve will have this point as an endpoint. Otherwise, straight lines
are drawn between successive end points.
If a point's value is CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
the point is a control point for a quadratic bezier. The control point
of a quadratic bezier is the single point that "stretches" the curve away
from the end points. If a point is a quadratic bezier control point, the
points preceeding and succeeding it must be end points
(CURVEDPATH_END_POINT).
If a point's value is CURVEDPATH_CUBIC_BEZIER_CONTROL_POINT,
the point is a control point for a cubic bezier. A cubic bezier has two
control points that "stretch" the curve away from the end points. Cubic
bezier control points must come in sets of two, with end points
(CURVEDPATH_END_POINT) coming before the first control point and
after the second.
offsets - List defining the beginnings of each path in the
xPts/yPts data arrays, or null to indicate a single path. A path that
begins at point (xPts[offsets[i]],yPts[offsets[i]]) will end at point
(xPts[offsets[i+1]]-1,yPts[offsets[i+1]]-1).xOrigin - X component of the texture origin in local screen
coordinates.yOrigin - Y component of the texture origin in local screen
coordinates.dux - Number of u points to skip in the texture per x point on
screen (15.16 fixed point).dvx - Number of v points to skip in the texture per x point on
screen (15.16 fixed point).duy - Number of u points to skip in the texture per y point on
screen (15.16 fixed point).dvy - Number of v points to skip in the texture per y point on
screen (15.16 fixed point).textureData - Non-null bitmap to be used as a texture.IllegalArgumentException - If the data is malformed. For example,
the values in offsets is negative or not in increasing order, there are
fewer than 2 points in a single path, the values in offsets index outside
the points