|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.image.NinePatch
public class NinePatch
The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes. Normally, the middle is transparent so that the patch can provide a selection about a rectangle. Essentially, it allows the creation of custom graphics that will scale the way that you define, when content added within the image exceeds the normal bounds of the graphic. This is an AWT clone of the NinePatch functionality that exists in Google's Android graphic system. See http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
| Field Summary | |
|---|---|
protected int |
_bottom
|
protected int |
_bottomPad
|
protected BufferedImage |
_img
|
protected int |
_left
|
protected int |
_leftPad
|
protected int |
_right
|
protected int |
_rightPad
|
protected int |
_top
The size of the non-stretchable regions on each side. |
protected int |
_topPad
The amount of padding on each side until we're in the content area. |
| Constructor Summary | |
|---|---|
NinePatch(BufferedImage img)
Builds a NinePatch based on the given image. |
|
NinePatch(BufferedImage img,
Rectangle center,
Rectangle content)
Builds a NinePatch based on the given image. |
|
| Method Summary | |
|---|---|
Rectangle |
getBoundsSurrounding(Rectangle content)
Returns a rectangle describing the bounds of this NinePatch when drawn such that it frames the given content rectangle. |
protected static Rectangle |
getRectangle(BufferedImage img,
boolean stretch)
Parses the image to find the bounds of the rectangle defined by pixels on the outside. |
void |
paint(Graphics2D gfx,
Rectangle location)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final BufferedImage _img
protected final int _top
protected final int _bottom
protected final int _left
protected final int _right
protected final int _topPad
protected final int _bottomPad
protected final int _leftPad
protected final int _rightPad
| Constructor Detail |
|---|
public NinePatch(BufferedImage img)
public NinePatch(BufferedImage img,
Rectangle center,
Rectangle content)
center - specifies the stretchable center of the image.content - if non-null, specifies the usable content area of the image| Method Detail |
|---|
public void paint(Graphics2D gfx,
Rectangle location)
public Rectangle getBoundsSurrounding(Rectangle content)
protected static Rectangle getRectangle(BufferedImage img,
boolean stretch)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||