libgdx API

com.badlogic.gdx.graphics.g2d
Class NinePatch

java.lang.Object
  extended by com.badlogic.gdx.graphics.g2d.NinePatch

public class NinePatch
extends java.lang.Object

A 3x3 grid of texture regions. Any of the regions may be omitted. Padding may be set as a hint on how to inset content on top of the ninepatch.


Field Summary
static int BOTTOM_CENTER
           
static int BOTTOM_LEFT
           
static int BOTTOM_RIGHT
           
static int MIDDLE_CENTER
           
static int MIDDLE_LEFT
           
static int MIDDLE_RIGHT
           
static int TOP_CENTER
           
static int TOP_LEFT
           
static int TOP_RIGHT
           
 
Constructor Summary
NinePatch(NinePatch ninePatch)
           
NinePatch(NinePatch ninePatch, Color color)
           
NinePatch(Texture texture)
           
NinePatch(Texture texture, Color color)
           
NinePatch(Texture texture, int left, int right, int top, int bottom)
           
NinePatch(TextureRegion... patches)
           
NinePatch(TextureRegion region)
           
NinePatch(TextureRegion region, Color color)
           
NinePatch(TextureRegion region, int left, int right, int top, int bottom)
           
 
Method Summary
 void draw(SpriteBatch batch, float x, float y, float width, float height)
           
 float getBottomHeight()
           
 Color getColor()
           
 float getLeftWidth()
           
 float getMiddleHeight()
           
 float getMiddleWidth()
           
 float getPadBottom()
          Returns the bottom padding if set, else returns getBottomHeight().
 float getPadLeft()
          Returns the left padding if set, else returns getLeftWidth().
 float getPadRight()
          Returns the right padding if set, else returns getRightWidth().
 float getPadTop()
          Returns the top padding if set, else returns getTopHeight().
 float getRightWidth()
           
 Texture getTexture()
           
 float getTopHeight()
           
 float getTotalHeight()
           
 float getTotalWidth()
           
 void setBottomHeight(float bottomHeight)
           
 void setColor(Color color)
           
 void setLeftWidth(float leftWidth)
           
 void setMiddleHeight(float middleHeight)
           
 void setMiddleWidth(float middleWidth)
           
 void setPadBottom(int bottom)
           
 void setPadding(int left, int right, int top, int bottom)
           
 void setPadLeft(int left)
           
 void setPadRight(int right)
           
 void setPadTop(int top)
           
 void setRightWidth(float rightWidth)
           
 void setTopHeight(float topHeight)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP_LEFT

public static final int TOP_LEFT
See Also:
Constant Field Values

TOP_CENTER

public static final int TOP_CENTER
See Also:
Constant Field Values

TOP_RIGHT

public static final int TOP_RIGHT
See Also:
Constant Field Values

MIDDLE_LEFT

public static final int MIDDLE_LEFT
See Also:
Constant Field Values

MIDDLE_CENTER

public static final int MIDDLE_CENTER
See Also:
Constant Field Values

MIDDLE_RIGHT

public static final int MIDDLE_RIGHT
See Also:
Constant Field Values

BOTTOM_LEFT

public static final int BOTTOM_LEFT
See Also:
Constant Field Values

BOTTOM_CENTER

public static final int BOTTOM_CENTER
See Also:
Constant Field Values

BOTTOM_RIGHT

public static final int BOTTOM_RIGHT
See Also:
Constant Field Values
Constructor Detail

NinePatch

public NinePatch(Texture texture,
                 int left,
                 int right,
                 int top,
                 int bottom)
Parameters:
left - Pixels from left edge.
right - Pixels from right edge.
top - Pixels from top edge.
bottom - Pixels from bottom edge.

NinePatch

public NinePatch(TextureRegion region,
                 int left,
                 int right,
                 int top,
                 int bottom)
Parameters:
left - Pixels from left edge.
right - Pixels from right edge.
top - Pixels from top edge.
bottom - Pixels from bottom edge.

NinePatch

public NinePatch(Texture texture,
                 Color color)

NinePatch

public NinePatch(Texture texture)

NinePatch

public NinePatch(TextureRegion region,
                 Color color)

NinePatch

public NinePatch(TextureRegion region)

NinePatch

public NinePatch(TextureRegion... patches)

NinePatch

public NinePatch(NinePatch ninePatch)

NinePatch

public NinePatch(NinePatch ninePatch,
                 Color color)
Method Detail

draw

public void draw(SpriteBatch batch,
                 float x,
                 float y,
                 float width,
                 float height)

setColor

public void setColor(Color color)

getColor

public Color getColor()

getLeftWidth

public float getLeftWidth()

setLeftWidth

public void setLeftWidth(float leftWidth)

getRightWidth

public float getRightWidth()

setRightWidth

public void setRightWidth(float rightWidth)

getTopHeight

public float getTopHeight()

setTopHeight

public void setTopHeight(float topHeight)

getBottomHeight

public float getBottomHeight()

setBottomHeight

public void setBottomHeight(float bottomHeight)

getMiddleWidth

public float getMiddleWidth()

setMiddleWidth

public void setMiddleWidth(float middleWidth)

getMiddleHeight

public float getMiddleHeight()

setMiddleHeight

public void setMiddleHeight(float middleHeight)

getTotalWidth

public float getTotalWidth()

getTotalHeight

public float getTotalHeight()

setPadding

public void setPadding(int left,
                       int right,
                       int top,
                       int bottom)

getPadLeft

public float getPadLeft()
Returns the left padding if set, else returns getLeftWidth().


setPadLeft

public void setPadLeft(int left)

getPadRight

public float getPadRight()
Returns the right padding if set, else returns getRightWidth().


setPadRight

public void setPadRight(int right)

getPadTop

public float getPadTop()
Returns the top padding if set, else returns getTopHeight().


setPadTop

public void setPadTop(int top)

getPadBottom

public float getPadBottom()
Returns the bottom padding if set, else returns getBottomHeight().


setPadBottom

public void setPadBottom(int bottom)

getTexture

public Texture getTexture()

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)