java.lang.Object | +--com.sun.kjava.Graphics
This class contains various methods for drawing on a display. The coordinate system used is such that the points along horizontal axis increase in value from left to right and point along the vertical axis increase in value from top to bottom.
Field Summary | |
static int |
AND
Region copy mode: The copied region is AND'ed with the destination. |
static int |
AND_NOT
Region copy mode: The copied region is AND'ed with the inverted destination region. |
static int |
ERASE
Erase mode. |
static int |
GRAY
Gray drawing mode. |
static int |
INVERT
Invert mode. |
static int |
NOT
Region copy mode: The copied region is inverted and overwrites the destination. |
static int |
OFFSCREEN_WINDOW
|
static int |
ONSCREEN_WINDOW
|
static int |
OR
Region copy mode: The copied region is OR'ed with the destination. |
static int |
OVERWRITE
Region copy mode: The copied region overwrites the destination. |
static int |
PLAIN
Plain drawing mode. |
static int |
RAISED
Constant for a slightly raised border. |
static int |
SIMPLE
Constant for a plain rectangle border. |
static int |
SOUND_ALARM
System sound for the alarm. |
static int |
SOUND_CLICK
System sound for a click. |
static int |
SOUND_CONFIRMATION
System sound for confirmation. |
static int |
SOUND_ERROR
System sound for error. |
static int |
SOUND_INFO
System sound for info. |
static int |
SOUND_STARTUP
System sound for startup. |
static int |
SOUND_WARNING
System sound for warning. |
static int |
XOR
Region copy mode: The copied region is XOR'ed with the destination. |
Method Summary | |
static int |
borderType(int cornerDiam,
int shadow,
int width)
Constructs a border type. |
static void |
clearScreen()
Clear the screen. |
static void |
copyOffScreenRegion(int left,
int top,
int width,
int height,
int dstX,
int dstY,
int mode,
int srcWind,
int dstWind)
Copy a rectangular region from one place to another, possibly in different windows. |
static void |
copyRegion(int left,
int top,
int width,
int height,
int dstX,
int dstY,
int mode)
Copy a rectangular region from one place to another. |
static void |
drawBitmap(int left,
int top,
Bitmap bitmap)
Draw a bitmap. |
static void |
drawBorder(int left,
int top,
int width,
int height,
int mode,
int frameType)
Draw a rectangular border. |
static void |
drawLine(int srcX,
int srcY,
int dstX,
int dstY,
int mode)
Draw a line. |
static void |
drawRectangle(int left,
int top,
int width,
int height,
int mode,
int cornerDiam)
Draw a solid rectangle. |
static int |
drawString(java.lang.String text,
int left,
int top)
Draw a string at a given position. |
static int |
drawString(java.lang.String text,
int left,
int top,
int mode)
Draw a string at a given position. |
static Graphics |
getGraphics()
There is only ever one Graphics object in the system, and this returns it. |
static int |
getHeight(java.lang.String s)
Returns the height of a string in pixels. |
static int |
getWidth(java.lang.String s)
Returns the width of a string in pixels. |
static void |
playSound(int sound)
Play a system sound. |
static void |
resetDrawRegion()
Reset the region in which drawing can be performed to be the whole screen. |
static void |
setDrawRegion(int left,
int top,
int width,
int height)
Set the region in which drawing can be performed. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int SIMPLE
public static final int RAISED
public static final int PLAIN
public static final int GRAY
public static final int ERASE
public static final int INVERT
public static final int OVERWRITE
public static final int AND
public static final int AND_NOT
public static final int XOR
public static final int OR
public static final int NOT
public static final int ONSCREEN_WINDOW
public static final int OFFSCREEN_WINDOW
public static final int SOUND_INFO
public static final int SOUND_WARNING
public static final int SOUND_ERROR
public static final int SOUND_STARTUP
public static final int SOUND_ALARM
public static final int SOUND_CONFIRMATION
public static final int SOUND_CLICK
Method Detail |
public static Graphics getGraphics()
public static void drawLine(int srcX, int srcY, int dstX, int dstY, int mode)
srcX
- the X coordinate of the starting pointsrcY
- the Y coordinate of the starting pointdstX
- the X coordinate of the destination pointdstY
- the Y coordinate of the destination pointmode
- the drawing mode to use (one of PLAIN, GRAY, ERASE
or INSERT
.public static void drawRectangle(int left, int top, int width, int height, int mode, int cornerDiam)
left
- the x coordinate of the rectangle's top left cornertop
- the y coordinate of the rectangle's top left cornerwidth
- the width of the rectangleheight
- the height of the rectanglemode
- the drawing mode to use (one of PLAIN, GRAY, ERASE
or INSERT
.cornerDiam
- the diameter of four imaginary circles used to form the
rounded corners. An imaginary circle is placed within each corner
tangent to the rectangle on two sides.public static void drawBorder(int left, int top, int width, int height, int mode, int frameType)
left
- the x coordinate of the rectangle's top left cornertop
- the y coordinate of the rectangle's top left cornerwidth
- the width of the rectangleheight
- the height of the rectanglemode
- the drawing mode to use (one of PLAIN, GRAY, ERASE
or INSERT
.frameType
- one of SIMPLE
, RAISED
or a
type constructed by a call to borderType
.public static int borderType(int cornerDiam, int shadow, int width)
cornerDiam
- the diameter of four imaginary circles used to form
rounded corners. Must be in the range 0..38.shadow
- the width of a shadow. Must be in the range 0..3.width
- width of the border.Must be in the range 0..3.public static int drawString(java.lang.String text, int left, int top, int mode)
"null"
if
text
is null
.text
- the String to drawleft
- the x coordinate of the top left bound of first character.top
- the y coordinate of the top left bound of first character.mode
- the drawing mode to use (one of PLAIN, RAY, ERASE
or INVERT
.public static int drawString(java.lang.String text, int left, int top)
drawString(text, left, top, PLAIN)
.text
- the String to drawleft
- the x coordinate of the top left bound of first character.top
- the y coordinate of the top left bound of first character.public static int getWidth(java.lang.String s)
s
- the String to measurepublic static int getHeight(java.lang.String s)
s
- the String to measurepublic static void setDrawRegion(int left, int top, int width, int height)
null
then the region is set to be the entire window.left
- the x coordinate of the top left position of the regionleft
- the y coordinate of the top left position of the regionwidth
- the width of the regionheight
- the height of the regionpublic static void resetDrawRegion()
public static void copyRegion(int left, int top, int width, int height, int dstX, int dstY, int mode)
left
- the x coordinate of the region's top left cornertop
- the y coordinate of the region's top left cornerwidth
- the width of the regionheight
- the height of the regiondstX
- the x coordinate of the point to which the region should
be copieddstY
- the y coordinate of the point to which the region should
be copiedmode
- the copy mode (one of
OVERWRITE, AND, AND_NOT, XOR, OR, INVERT
)public static void copyOffScreenRegion(int left, int top, int width, int height, int dstX, int dstY, int mode, int srcWind, int dstWind)
left
- the x coordinate of the source region's top left cornertop
- the y coordinate of the source region's top left cornerwidth
- the width of the source regionheight
- the height of the source regiondstX
- the x coordinate of the point to which the region should
be copied in the destinationdstY
- the y coordinate of the point to which the region should
be copied in the destinationmode
- the copy mode (one of
OVERWRITE, AND, AND_NOT, XOR, OR, INVERT
)srcWind
- either ONSCREEN_WINDOW or OFFSCREEN_WINDOWdstWind
- either ONSCREEN_WINDOW or OFFSCREEN_WINDOWpublic static void clearScreen()
public static void drawBitmap(int left, int top, Bitmap bitmap)
left
- the x coordinate of the bitmap's top left cornertop
- the y coordinate of the bitmap's top left cornerbitmap
- the bitmap to be drawnpublic static void playSound(int sound)
sound
- one of the SOUND_xxx constants