|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
waba.lang.Object | +--waba.fx.Graphics
Graphics draws on a surface.
Surfaces are objects that implement the ISurface interface. MainWindow and Image are both examples of surfaces.
Here is an example that uses Graphics to draw a line:
public class MyProgram extends MainWindow { public void onPaint(Graphics g) { g.setColor(0, 0, 255); g.drawLine(0, 0, 10, 10); ...
Field Summary | |
static int |
DRAW_AND
The constant for a draw operation that AND's the source with the destination. |
static int |
DRAW_OR
The constant for a draw operation that OR's the source with the destination. |
static int |
DRAW_OVER
The constant for a draw operation that draws the source over the destination. |
static int |
DRAW_XOR
The constant for a draw operation that XOR's the source with the destination. |
Constructor Summary | |
Graphics(ISurface surface)
Constructs a graphics object which can be used to draw on the given surface. |
Method Summary | |
void |
clearClip()
Clears the current clipping rectangle. |
void |
copyRect(ISurface surface,
int x,
int y,
int width,
int height,
int dstX,
int dstY)
Copies a rectangular area from a surface to the given coordinates on the current surface. |
void |
drawCursor(int x,
int y,
int width,
int height)
Draws a cursor by XORing the given rectangular area on the surface. |
void |
drawDots(int x1,
int y1,
int x2,
int y2)
Draws a dotted line at the given coordinates. |
void |
drawImage(Image image,
int x,
int y)
Draws an image at the given x and y coordinates. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line at the given coordinates. |
void |
drawPolygon(int[] x,
int[] y,
int count)
Draws the outline of a polygon with the given coordinates. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws a rectangle at the given coordinates. |
void |
drawText(char[] chars,
int start,
int count,
int x,
int y)
Draws text at the given coordinates. |
void |
drawText(String s,
int x,
int y)
Draws text at the given coordinates. |
void |
fillPolygon(int[] x,
int[] y,
int count)
Draws a filled polygon with the given coordinates. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills a rectangular area with the current color. |
void |
free()
Frees any system resources (native device contexts) associated with the graphics object. |
Rect |
getClip(Rect r)
Sets the x, y, width and height coordinates in the rectangle passed to the current clip coordinates. |
void |
setClip(int x,
int y,
int width,
int height)
Sets a clipping rectangle. |
void |
setColor(int r,
int g,
int b)
Sets the current color for drawing operations. |
void |
setDrawOp(int drawOp)
Sets the drawing operation. |
void |
setFont(Font font)
Sets the current font for operations that draw text. |
void |
translate(int x,
int y)
Translates the origin of the current coordinate system by the given x and y values. |
Methods inherited from class waba.lang.Object |
toString |
Field Detail |
public static final int DRAW_OVER
public static final int DRAW_AND
public static final int DRAW_OR
public static final int DRAW_XOR
Constructor Detail |
public Graphics(ISurface surface)
If you are trying to create a graphics object for drawing in a subclass of control, use the createGraphics() method in the Control class. It creates a graphics object and translated the origin to the origin of the control.
Method Detail |
public void clearClip()
public void copyRect(ISurface surface, int x, int y, int width, int height, int dstX, int dstY)
Not all combinations of surfaces are supported on all platforms. PalmOS has problems copying from an Window surface to an Image and between two Image surfaces. Java doesn't allow copying from an Window surface to an Image.
surface
- the surface to copy fromx
- the source x coordinatey
- the source y coordinatewidth
- the width of the area on the source surfaceheight
- the height of the area on the source surfacedstX
- the destination x location on the current surfacedstY
- the destination y location on the current surfacesetDrawOp(int)
public void free()
public void drawText(char[] chars, int start, int count, int x, int y)
chars
- the character array to displaystart
- the start position in arraycount
- the number of characters to displayx
- the left coordinate of the text's bounding boxy
- the top coordinate of the text's bounding boxpublic void drawImage(Image image, int x, int y)
public void drawCursor(int x, int y, int width, int height)
public void drawLine(int x1, int y1, int x2, int y2)
public void drawRect(int x, int y, int width, int height)
public void drawDots(int x1, int y1, int x2, int y2)
public void drawPolygon(int[] x, int[] y, int count)
x
- x vertex coordinatesy
- y vertex coordinatescount
- number of verticespublic void fillPolygon(int[] x, int[] y, int count)
x
- x vertex coordinatesy
- y vertex coordinatescount
- number of verticespublic void drawText(String s, int x, int y)
public void fillRect(int x, int y, int width, int height)
public void setClip(int x, int y, int width, int height)
public Rect getClip(Rect r)
public void setColor(int r, int g, int b)
r
- the red value (0..255)g
- the green value (0..255)b
- the blue value (0..255)public void setDrawOp(int drawOp)
Not all operations are supported on all platforms. When used with Java, DRAW_OVER is supported for all types of drawing and DRAW_XOR is supported for drawing lines, rectangles, text and images. However, DRAW_XOR is not supported when copying surface areas and the DRAW_AND and DRAW_OR operations aren't supported at all under Java.
PalmOS platforms supports all the drawing operations when drawing images and copying surface regions. However, only the DRAW_OVER operation is supported when drawing lines, rectangles and text. If you need to use the XOR drawing operation for drawing lines under PalmOS, you can draw the line into an image and then draw the image with an XOR drawing operation.
Win32 and Windows CE platforms support all the drawing operations except when drawing text. Only DRAW_OVER is supported when drawing text. If you need to draw XOR'ed text, you can draw the text into an image and then draw the image with an XOR draw operation.
When calculating the result of XOR, AND and OR drawing, the value of the color black is all 1's (fully set) in binary and white is all 0's (fully unset).
op
- drawing operationDRAW_OVER
,
DRAW_AND
,
DRAW_OR
,
DRAW_XOR
public void setFont(Font font)
public void translate(int x, int y)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |