|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Object
Graphics
public class Graphics
Provides simple 2D geometric rendering capability. This is to be
used with
Script.paint(Component, Graphics, Style, int, int) and
PaintCallback.paint(Component, Graphics, Style, int, int).
A paint callback function can be given as an argument to the
constructor Canvas.Canvas(Style, PaintCallback) of
Canvas. The Graphics instance appears as an argument
for the paint functions and can be used for drawing custom
graphics there.
| Method Summary | |
|---|---|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws a circular or elliptical arc covering the specified rectangle. |
void |
drawImage(Image img,
int x,
int y,
int anchor)
Draws the specified image by using the anchor point. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line between the coordinates (x1,y1) and
(x2,y2) using
the current color and stroke style. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws the outline of the specified rectangle using the current color and stroke style. |
void |
drawString(String str,
int x,
int y,
int anchor)
Draws the specified String using the current font and color. |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills the specified rectangle with the current color. |
void |
fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Fills the specified triangle will the current color. |
int, int, int, int |
getClip()
Returns the current clipping area. |
int |
getColor()
Gets the current color. |
Font |
getFont()
Gets the current font used by text drawing operations. |
int, int |
getTranslate()
Returns the current translation origin. |
void |
setClip(int x,
int y,
int width,
int height,
boolean absolute)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setColor(int color)
Sets the current color to the specified RGB values. |
void |
setFont(Font font)
Sets the font for all subsequent text rendering operations. |
void |
translate(int x,
int y)
Translates the origin of the graphics context to the point (x, y) in the current coordinate system. |
| Methods inherited from class Object |
|---|
toString, equals, hashCode |
| Methods inherited from |
|---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public int getColor()
0x00RRGGBBsetColor(int)public void setColor(int color)
0x00RRGGBB. The high
order byte of this value is ignored.
color - the color being setgetColor()public Font getFont()
setFont(Font)public void setFont(Font font)
font - the specified fontgetFont(),
drawString(String, int, int, int)
public void drawLine(int x1,
int y1,
int x2,
int y2)
(x1,y1) and
(x2,y2) using
the current color and stroke style.
x1 - the x coordinate of the start of the liney1 - the y coordinate of the start of the linex2 - the x coordinate of the end of the liney2 - the y coordinate of the end of the line
public void drawRect(int x,
int y,
int width,
int height)
(width + 1)
pixels wide by (height + 1) pixels tall.
If either width or height is less than
zero, nothing is drawn.
x - the x coordinate of the rectangle to be drawny - the y coordinate of the rectangle to be drawnwidth - the width of the rectangle to be drawnheight - the height of the rectangle to be drawnfillRect(int, int, int, int)
public void fillRect(int x,
int y,
int width,
int height)
x - the x coordinate of the rectangle to be filledy - the y coordinate of the rectangle to be filledwidth - the width of the rectangle to be filledheight - the height of the rectangle to be filleddrawRect(int, int, int, int)
public void fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
x1 - the x coordinate of the first vertex of the triangley1 - the y coordinate of the first vertex of the trianglex2 - the x coordinate of the second vertex of the triangley2 - the y coordinate of the second vertex of the trianglex3 - the x coordinate of the third vertex of the triangley3 - the y coordinate of the third vertex of the triangle
public void drawImage(Image img,
int x,
int y,
int anchor)
img - the specified image to be drawnx - the x coordinate of the anchor pointy - the y coordinate of the anchor pointanchor - the anchor point for positioning the image
public void drawString(String str,
int x,
int y,
int anchor)
String using the current font and color.
The x,y position is the position of the anchor point.
str - the String to be drawnx - the x coordinate of the anchor pointy - the y coordinate of the anchor pointanchor - the anchor point for positioning the text
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
x - the x coordinate of the upper-left corner of the arc to be filled.y - the y coordinate of the upper-left corner of the arc to be filled.width - the width of the arc to be filledheight - the height of the arc to be filledstartAngle - the beginning angle [0..360].arcAngle - the angular extent of the arc, relative to the start angle [0..360].
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
x - the x coordinate of the upper-left corner of the arc to be filled.y - the y coordinate of the upper-left corner of the arc to be filled.width - the width of the arc to be filledheight - the height of the arc to be filledstartAngle - the beginning angle [0..360].arcAngle - the angular extent of the arc, relative to the start angle [0..360].
public void translate(int x,
int y)
translate() calls are cumulative.
The application can set an absolute origin (ax, ay) using
the following technique:
int x, int y = g.getTranslate(); g.translate(ax - x, ay - y);x - the x coordinate of the new translation origin y - the y coordinate of the new translation origin
public int, int getTranslate()
(int translateX, int translateY) tuplepublic int, int, int, int getClip()
(int clipX, int clipY,
int clipWidth, int clipHeight).
public void setClip(int x,
int y,
int width,
int height,
boolean absolute)
absolute is false the the current clip
is intesected with the specified rectangle. Rendering operations
have no effect outside of the clipping area.
x - the x coordinate of the rectangle to intersect the clip withy - the y coordinate of the rectangle to intersect the clip withwidth - the width of the rectangle to intersect the clip withheight - the height of the rectangle to intersect the clip withabsolute - If true sets new clip, otherwise intersects with
current clip
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||