Various utility functions to draw images, strings, shadows, calculate rectangle intersections, etc.
public static void drawShadow(Graphics g, int x, int y,
int width, int height, int shadowThickness,
Color topColor, Color bottomColor)
Draws a shadow using Graphics g at the given x,
y, width and height with a thickness
defined by shadowThickness. The top color of the shadow
will be drawn in topColor and the bottom color of the
shadow will be drawn in bottomColor.
public static void drawImage(Graphics g, Image image,
ImageObserver observer, int imageWidth, int imageHeight,
int alignment, Rectangle rect, Rectangle clipRect)
Draws an image of width imageWidth and height
imageHeight using the Graphics g and ImageObserver
observer given.
The rect parameter indicates the rectangle used to
determine alignment. The clipRect rectangle parameter given
indicates the rectangle used to clip the drawing.
alignment must be one of the following:
ALIGNMENT_TOP_LEFT ALIGNMENT_TOP ALIGNMENT_TOP_RIGHT ALIGNMENT_LEFT ALIGNMENT_CENTER ALIGNMENT_RIGHT ALIGNMENT_BOTTOM_LEFT ALIGNMENT_BOTTOM ALIGNMENT_BOTTOM_RIGHT
public static void drawString(Graphics g, String string, Font font,
int alignment, Rectangle rect, Rectangle clipRect)
Draws string using the Graphics g and font
given. The rect parameter indicates the
rectangle used to determine alignment. The clipRect
rectangle parameter given indicates the rectangle used
to clip the drawing. alignment must be one of the following:
ALIGNMENT_TOP_LEFT ALIGNMENT_TOP ALIGNMENT_TOP_RIGHT ALIGNMENT_LEFT ALIGNMENT_CENTER ALIGNMENT_RIGHT ALIGNMENT_BOTTOM_LEFT ALIGNMENT_BOTTOM ALIGNMENT_BOTTOM_RIGHT
public static Dimension getImageDimensions(Image image,
ImageObserver observer)
Returns the dimensions of the passed image with
ImageObserver observer.
public static Dimension getFontDimensions(Font font,
boolean useAverageWidth)
Calculates the overall dimension of the characters in
a given font. The height returned is the height of the tallest
glyph. If useAverageWidth is false, the width returned is the
width of the widest glyph. If true, the width returned is the average
width of all of the glyphs.
public static int rectIntersect(Rectangle r1, Rectangle r2)
Determines the intersection of two rectangles r1 and r2.
Returns RECT_OUTSIDE if r1 is outside r2, RECT_INSIDE if r1 is inside
r2 and RECT_PARTIAL if the two rectangles intersect.
public static int version()
Returns the version number of the toolkit. 100 is returned for 1.00, 201 for
2.01, etc.
public static void warning(String msg)
This function generates a system error message containing the string
msg.