vitro
Class Drawing

java.lang.Object
  extended by vitro.Drawing

public class Drawing
extends Object

A collection of useful utility routines for drawing 2D graphics.


Constructor Summary
Drawing()
           
 
Method Summary
static void configureRaster(Graphics g)
          Configure a Graphics surface for drawing raster graphics- preference speed and pixel-wise interpolation.
static void configureVector(Graphics g)
          Configure a Graphics surface for drawing vector graphics- antialias and preference rendering quality.
static void drawBezelRect(Graphics g, int x, int y, int width, int height, int thickness, Color ulBezel, Color drBezel, Color fill)
          Draw a '3D' bezeled rectangle.
static void drawBezelRect(Graphics g, Rectangle bound, int thickness, Color ulBezel, Color drBezel, Color main)
          Draw a '3D' bezeled rectangle.
static void drawCircleCentered(Graphics g, int x, int y, int radius, Color outline, Color fill)
          Draw a filled circle with a given fill and outline color.
static void drawRoundRect(Graphics g, int x, int y, int width, int height, int radius, Color outline, Color fill)
          Draw a filled rounded rectangle with a given fill and outline color.
static void drawStringCentered(Graphics g, String s, int x, int y)
          Draw a String centered vertically and horizontal at a given position onscreen.
static int stringHeight(Graphics g, String s)
          Get the height of a String in pixels given the current drawing context.
static int stringWidth(Graphics g, String s)
          Get the width of a String in pixels given the current drawing context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Drawing

public Drawing()
Method Detail

stringWidth

public static int stringWidth(Graphics g,
                              String s)
Get the width of a String in pixels given the current drawing context.

Parameters:
g - the target graphics context.
s - the String to consider.
Returns:
the width of the String in pixels.

stringHeight

public static int stringHeight(Graphics g,
                               String s)
Get the height of a String in pixels given the current drawing context.

Parameters:
g - the target graphics context.
s - the String to consider.
Returns:
the height of the String in pixels.

drawStringCentered

public static void drawStringCentered(Graphics g,
                                      String s,
                                      int x,
                                      int y)
Draw a String centered vertically and horizontal at a given position onscreen.

Parameters:
g - the target graphics surface.
s - the String to draw.
x - the x coordinate of the centerpoint.
y - the y coordinate of the centerpoint.

drawCircleCentered

public static void drawCircleCentered(Graphics g,
                                      int x,
                                      int y,
                                      int radius,
                                      Color outline,
                                      Color fill)
Draw a filled circle with a given fill and outline color.

Parameters:
g - the target graphics surface.
x - the x coordinate of the circle's centerpoint.
y - the y coordinate of the circle's centerpoint.
radius - the circle's radius, in pixels.
outline - the color of the circle's outline.
fill - the color with which to fill the circle.

drawRoundRect

public static void drawRoundRect(Graphics g,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 int radius,
                                 Color outline,
                                 Color fill)
Draw a filled rounded rectangle with a given fill and outline color.

Parameters:
g - the target graphics surface.
x - the x coordinate of the rectangle's top left corner.
y - the y coordinate of the rectangle's top left corner.
width - the width of the rectangle, in pixels.
height - the height of the rectangle, in pixels.
radius - the corner radius, in pixels.
outline - the color of the rectangle's outline.
fill - the color with which to fill the rectangle.

drawBezelRect

public static void drawBezelRect(Graphics g,
                                 Rectangle bound,
                                 int thickness,
                                 Color ulBezel,
                                 Color drBezel,
                                 Color main)
Draw a '3D' bezeled rectangle.

Parameters:
g - the target graphics surface.
bound - a rectangle representing the size and position of the bezeled rectangle.
thickness - the thickness of the bezel, in pixels.
ulBezel - the color for the upper and left edges of the bezel.
drBezel - the color for the down and right edges of the bezel.
main - the primary fill for the rectangle.

drawBezelRect

public static void drawBezelRect(Graphics g,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 int thickness,
                                 Color ulBezel,
                                 Color drBezel,
                                 Color fill)
Draw a '3D' bezeled rectangle.

Parameters:
g - the target graphics surface.
x - the x coordinate of the rectangle's top left corner.
y - the y coordinate of the rectangle's top left corner.
width - the width of the rectangle, in pixels.
height - the height of the rectangle, in pixels.
thickness - the thickness of the bezel, in pixels.
ulBezel - the color for the upper and left edges of the bezel.
drBezel - the color for the down and right edges of the bezel.
fill - the primary fill for the rectangle.

configureRaster

public static void configureRaster(Graphics g)
Configure a Graphics surface for drawing raster graphics- preference speed and pixel-wise interpolation.

Parameters:
g - the target graphics context.

configureVector

public static void configureVector(Graphics g)
Configure a Graphics surface for drawing vector graphics- antialias and preference rendering quality.

Parameters:
g - the target graphics context.