public interface Drawable
A Drawable object is one that visually represents itself with an image that is contextless by itself but can be drawn to a Graphics context. Points on the image have x-coordinates that increase from left to right, as well as y-coordinates that increase from top to bottom. The image has an origin point somewhere on (or off) it around which it is flipped, rotated, and scaled.
The Drawable interface also contains the static method getRenderableRegion(), which is useful for checking whether a particular Drawable's image would be visible if drawn at a particular location.
Modifier and Type | Method and Description |
---|---|
void |
draw(Graphics g,
int x,
int y)
Draws this Drawable's image to the specified Graphics context.
|
void |
draw(Graphics g,
int x,
int y,
boolean xFlip,
boolean yFlip,
double angle,
double alpha,
Filter filter)
Draws this Drawable's image to the specified Graphics context.
|
void |
draw(Graphics g,
int x,
int y,
double scale,
boolean xFlip,
boolean yFlip,
double alpha,
Filter filter)
Draws this Drawable's image to the specified Graphics context.
|
void |
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.
|
void |
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom,
boolean xFlip,
boolean yFlip,
double angle,
double alpha,
Filter filter)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.
|
void |
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom,
double scale,
boolean xFlip,
boolean yFlip,
double alpha,
Filter filter)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.
|
static java.awt.Rectangle |
getRenderableRegion(Graphics g)
Returns the rectangular region of the specified Graphics context that can
currently be rendered to.
|
void draw(Graphics g, int x, int y)
g
- The Graphics context to draw the image tox
- The x-coordinate on the Graphics context of the drawn image's
originy
- The y-coordinate on the Graphics context of the drawn image's
originvoid draw(Graphics g, int x, int y, boolean xFlip, boolean yFlip, double angle, double alpha, Filter filter)
g
- The Graphics context to draw the image tox
- The x-coordinate on the Graphics context of the drawn image's
originy
- The y-coordinate on the Graphics context of the drawn image's
originxFlip
- If true, the drawn image is flipped along a vertical line
through its originyFlip
- If true, the drawn image is flipped along a horizontal line
through its originangle
- The angle in degrees by which to rotate the drawn image and
its xFlip and yFlip lines counterclockwise around its originalpha
- The drawn image's alpha (opacity) value from 0 to 1filter
- The Filter to apply to the drawn image, or null if none
should be applied. Not every Filter has an effect on every Drawable.void draw(Graphics g, int x, int y, double scale, boolean xFlip, boolean yFlip, double alpha, Filter filter)
g
- The Graphics context to draw the image tox
- The x-coordinate on the Graphics context of the drawn image's
originy
- The y-coordinate on the Graphics context of the drawn image's
originscale
- The factor by which to scale the drawn image around its
originxFlip
- If true, the drawn image is flipped along a vertical line
through its originyFlip
- If true, the drawn image is flipped along a horizontal line
through its originalpha
- The drawn image's alpha (opacity) value from 0 to 1filter
- The Filter to apply to the drawn image, or null if none
should be applied. Not every Filter has an effect on every Drawable.void draw(Graphics g, int x, int y, int left, int right, int top, int bottom)
g
- The Graphics context to draw the region tox
- The x-coordinate on the Graphics context of the image's originy
- The y-coordinate on the Graphics context of the image's originleft
- The x-coordinate on the image, relative to its origin, of the
region's left edgeright
- The x-coordinate on the image, relative to its origin, of
the region's right edgetop
- The y-coordinate on the image, relative to its origin, of the
region's top edgebottom
- The y-coordinate on the image, relative to its origin, of
the region's bottom edgevoid draw(Graphics g, int x, int y, int left, int right, int top, int bottom, boolean xFlip, boolean yFlip, double angle, double alpha, Filter filter)
g
- The Graphics context to draw the region tox
- The x-coordinate on the Graphics context of the image's originy
- The y-coordinate on the Graphics context of the image's originleft
- The x-coordinate on the image, relative to its origin, of the
region's left edgeright
- The x-coordinate on the image, relative to its origin, of
the region's right edgetop
- The y-coordinate on the image, relative to its origin, of the
region's top edgebottom
- The y-coordinate on the image, relative to its origin, of
the region's bottom edgexFlip
- If true, the drawn region is flipped along a vertical line
through the image's originyFlip
- If true, the drawn region is flipped along a horizontal line
through the image's originangle
- The angle in degrees by which to rotate the drawn region and
its xFlip and yFlip lines counterclockwise around the image's originalpha
- The drawn region's alpha (opacity) value from 0 to 1filter
- The Filter to apply to the drawn region, or null if none
should be applied. Not every Filter has an effect on every Drawable.void draw(Graphics g, int x, int y, int left, int right, int top, int bottom, double scale, boolean xFlip, boolean yFlip, double alpha, Filter filter)
g
- The Graphics context to draw the region tox
- The x-coordinate on the Graphics context of the image's originy
- The y-coordinate on the Graphics context of the image's originleft
- The x-coordinate on the image, relative to its origin, of the
region's left edgeright
- The x-coordinate on the image, relative to its origin, of
the region's right edgetop
- The y-coordinate on the image, relative to its origin, of the
region's top edgebottom
- The y-coordinate on the image, relative to its origin, of
the region's bottom edgescale
- The factor by which to scale the drawn region around the
image's originxFlip
- If true, the drawn region is flipped along a vertical line
through the image's originyFlip
- If true, the drawn region is flipped along a horizontal line
through the image's originalpha
- The drawn region's alpha (opacity) value from 0 to 1filter
- The Filter to apply to the drawn region, or null if none
should be applied. Not every Filter has an effect on every Drawable.static java.awt.Rectangle getRenderableRegion(Graphics g)
g
- The Graphics context to examine