libgdx API

com.badlogic.gdx.scenes.scene2d.ui
Class Image

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.ui.Widget
          extended by com.badlogic.gdx.scenes.scene2d.ui.Image
All Implemented Interfaces:
Layout

public class Image
extends Widget

Displays a TextureRegion or NinePatch, scaled various way within the widgets bounds. The preferred size is the actual size of the region or ninepatch. Only when using a TextureRegion will the actor's scale, rotation, and origin be used when drawing.

Author:
Nathan Sweet

Field Summary
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y
 
Constructor Summary
Image()
          Creates an image with no region or patch, stretched, and aligned center.
Image(NinePatch patch)
          Creates an image stretched, and aligned center.
Image(NinePatch patch, Scaling scaling)
          Creates an image aligned center.
Image(NinePatch patch, Scaling scaling, int align)
           
Image(NinePatch patch, Scaling scaling, int align, java.lang.String name)
           
Image(Texture texture)
          Creates an image stretched, and aligned center.
Image(TextureRegion region)
          Creates an image stretched, and aligned center.
Image(TextureRegion region, Scaling scaling)
          Creates an image aligned center.
Image(TextureRegion region, Scaling scaling, int align)
           
Image(TextureRegion region, Scaling scaling, int align, java.lang.String name)
           
Image(Texture texture, Scaling scaling)
          Creates an image aligned center.
Image(Texture texture, Scaling scaling, int align)
           
Image(Texture texture, Scaling scaling, int align, java.lang.String name)
           
 
Method Summary
 void draw(SpriteBatch batch, float parentAlpha)
          If this method is overridden, the super method or Widget.validate() should be called to ensure the widget is laid out.
 float getImageHeight()
           
 float getImageWidth()
           
 float getImageX()
           
 float getImageY()
           
 float getMinHeight()
           
 float getMinWidth()
           
 NinePatch getPatch()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 TextureRegion getRegion()
           
 void layout()
          Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child and calls Layout.invalidate() and then Layout.validate() on each one.
 void setAlign(int align)
           
 void setClickListener(ClickListener clickListener)
           
 void setPatch(NinePatch patch)
           
 void setRegion(TextureRegion region)
           
 void setScaling(Scaling scaling)
           
 boolean touchDown(float x, float y, int pointer)
           
 void touchDragged(float x, float y, int pointer)
           
 void touchUp(float x, float y, int pointer)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, hit, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, toScreenCoordinates, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Image

public Image()
Creates an image with no region or patch, stretched, and aligned center.


Image

public Image(Texture texture)
Creates an image stretched, and aligned center.


Image

public Image(Texture texture,
             Scaling scaling)
Creates an image aligned center.


Image

public Image(Texture texture,
             Scaling scaling,
             int align)

Image

public Image(Texture texture,
             Scaling scaling,
             int align,
             java.lang.String name)

Image

public Image(TextureRegion region)
Creates an image stretched, and aligned center.

Parameters:
region - May be null.

Image

public Image(TextureRegion region,
             Scaling scaling)
Creates an image aligned center.

Parameters:
region - May be null.

Image

public Image(TextureRegion region,
             Scaling scaling,
             int align)
Parameters:
region - May be null.

Image

public Image(TextureRegion region,
             Scaling scaling,
             int align,
             java.lang.String name)
Parameters:
region - May be null.

Image

public Image(NinePatch patch)
Creates an image stretched, and aligned center.

Parameters:
patch - May be null.

Image

public Image(NinePatch patch,
             Scaling scaling)
Creates an image aligned center.

Parameters:
patch - May be null.

Image

public Image(NinePatch patch,
             Scaling scaling,
             int align)
Parameters:
patch - May be null.

Image

public Image(NinePatch patch,
             Scaling scaling,
             int align,
             java.lang.String name)
Parameters:
patch - May be null.
Method Detail

layout

public void layout()
Description copied from interface: Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child and calls Layout.invalidate() and then Layout.validate() on each one. Usually this should not be called directly, instead Layout.validate() should be used.

Specified by:
layout in interface Layout
Overrides:
layout in class Widget

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: Widget
If this method is overridden, the super method or Widget.validate() should be called to ensure the widget is laid out.

Overrides:
draw in class Widget
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

setRegion

public void setRegion(TextureRegion region)
Parameters:
region - May be null.

getRegion

public TextureRegion getRegion()

setPatch

public void setPatch(NinePatch patch)
Parameters:
patch - May be null.

getPatch

public NinePatch getPatch()

setScaling

public void setScaling(Scaling scaling)

setAlign

public void setAlign(int align)

getMinWidth

public float getMinWidth()
Specified by:
getMinWidth in interface Layout
Overrides:
getMinWidth in class Widget

getMinHeight

public float getMinHeight()
Specified by:
getMinHeight in interface Layout
Overrides:
getMinHeight in class Widget

getPrefWidth

public float getPrefWidth()
Specified by:
getPrefWidth in interface Layout
Overrides:
getPrefWidth in class Widget

getPrefHeight

public float getPrefHeight()
Specified by:
getPrefHeight in interface Layout
Overrides:
getPrefHeight in class Widget

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Overrides:
touchDown in class Widget

touchUp

public void touchUp(float x,
                    float y,
                    int pointer)
Overrides:
touchUp in class Widget

touchDragged

public void touchDragged(float x,
                         float y,
                         int pointer)
Overrides:
touchDragged in class Widget

setClickListener

public void setClickListener(ClickListener clickListener)

getImageX

public float getImageX()

getImageY

public float getImageY()

getImageWidth

public float getImageWidth()

getImageHeight

public float getImageHeight()

libgdx API

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