|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.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)
|
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)
|
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 java.lang.Object |
equals, hashCode, 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)
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 box
public 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 vertices
public void fillPolygon(int[] x,
int[] y,
int count)
x - x vertex coordinatesy - y vertex coordinatescount - number of vertices
public 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)
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 | ||||||||