APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class Image

extends Widget
Class Inheritance
Imports
com.badlogic.gdx.graphics.Color, .Texture, com.badlogic.gdx.graphics.g2d.Batch, .NinePatch, .TextureRegion, com.badlogic.gdx.math.Vector2, com.badlogic.gdx.scenes.scene2d.utils.Drawable, .NinePatchDrawable, .TextureRegionDrawable, .TransformDrawable, com.badlogic.gdx.utils.Align, .Null, .Scaling

Displays a Drawable, scaled various way within the widgets bounds. The preferred size is the min size of the drawable. Only when using a TextureRegionDrawable will the actor's scale, rotation, and origin be used when drawing.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private int
private Drawable
private float
private float
private float
private float
private Scaling

Constructor Summary

AccessConstructor and Description
public
Image()

Creates an image with no drawable, stretched, and aligned center.

public
Image(NinePatch
May be null.
patch
)

Creates an image stretched, and aligned center.

public
Image(TextureRegion
May be null.
region
)

Creates an image stretched, and aligned center.

public
Image(Texture texture)

Creates an image stretched, and aligned center.

public
Image(Skin skin, String drawableName)

Creates an image stretched, and aligned center.

public
Image(Drawable
May be null.
drawable
)

Creates an image stretched, and aligned center.

public
Image(Drawable
May be null.
drawable
,
Scaling scaling)

Creates an image aligned center.

public
Image(Drawable
May be null.
drawable
,
Scaling scaling, int align)

Method Summary

Modifier and TypeMethod and Description
public void
draw(Batch batch, float parentAlpha)

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.draw.

If this method is overridden, the super method or validate() should be called to ensure the widget is laid out.

public int
public Drawable
getDrawable()

Returns: May be null.

public float
public float
public float
public float
public float
public float
public float
public float
public void
layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls invalidate() on any each child whose width or height has changed, and calls validate() on each child.

public void
setAlign(int align)

public void
setDrawable(Skin skin, String drawableName)

public void
setDrawable(Drawable
May be null.
drawable
)

Sets a new drawable for the image.

public void
public String
toString()

Overrides com.badlogic.gdx.scenes.scene2d.Actor.toString.

Returns a string representation of the object.

Inherited from com.badlogic.gdx.scenes.scene2d.ui.Widget:
getMaxHeightgetMaxWidthinvalidateinvalidateHierarchyneedsLayoutpacksetFillParentsetLayoutEnabledsizeChangedvalidate

Field Detail

alignback to summary
private int align
drawableback to summary
private Drawable drawable
imageHeightback to summary
private float imageHeight
imageWidthback to summary
private float imageWidth
imageXback to summary
private float imageX
imageYback to summary
private float imageY
scalingback to summary
private Scaling scaling

Constructor Detail

Imageback to summary
public Image()

Creates an image with no drawable, stretched, and aligned center.

Imageback to summary
public Image(NinePatch patch)

Creates an image stretched, and aligned center.

Parameters
patch:NinePatch

May be null.

Imageback to summary
public Image(TextureRegion region)

Creates an image stretched, and aligned center.

Parameters
region:TextureRegion

May be null.

Imageback to summary
public Image(Texture texture)

Creates an image stretched, and aligned center.

Imageback to summary
public Image(Skin skin, String drawableName)

Creates an image stretched, and aligned center.

Imageback to summary
public Image(Drawable drawable)

Creates an image stretched, and aligned center.

Parameters
drawable:Drawable

May be null.

Imageback to summary
public Image(Drawable drawable, Scaling scaling)

Creates an image aligned center.

Parameters
drawable:Drawable

May be null.

Imageback to summary
public Image(Drawable drawable, Scaling scaling, int align)
Parameters
drawable:Drawable

May be null.

Method Detail

drawback to summary
public void draw(Batch batch, float parentAlpha)

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.draw.

Doc from com.badlogic.gdx.scenes.scene2d.ui.Widget.draw.

If this method is overridden, the super method or validate() should be called to ensure the widget is laid out.

getAlignback to summary
public int getAlign()
getDrawableback to summary
public Drawable getDrawable()
Returns:Drawable

May be null.

Annotations
@Null
getImageHeightback to summary
public float getImageHeight()
getImageWidthback to summary
public float getImageWidth()
getImageXback to summary
public float getImageX()
getImageYback to summary
public float getImageY()
getMinHeightback to summary
public float getMinHeight()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.getMinHeight.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getMinHeight.

getMinWidthback to summary
public float getMinWidth()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.getMinWidth.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getMinWidth.

getPrefHeightback to summary
public float getPrefHeight()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.getPrefHeight.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefHeight.

getPrefWidthback to summary
public float getPrefWidth()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.getPrefWidth.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefWidth.

layoutback to summary
public void layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.Widget.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Doc from com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls invalidate() on any each child whose width or height has changed, and calls validate() on each child. This method should almost never be called directly, instead validate() should be used.

setAlignback to summary
public void setAlign(int align)
setDrawableback to summary
public void setDrawable(Skin skin, String drawableName)
setDrawableback to summary
public void setDrawable(Drawable drawable)

Sets a new drawable for the image. The image's pref size is the drawable's min size. If using the image actor's size rather than the pref size, pack() can be used to size the image to its pref size.

Parameters
drawable:Drawable

May be null.

setScalingback to summary
public void setScaling(Scaling scaling)
toStringback to summary
public String toString()

Overrides com.badlogic.gdx.scenes.scene2d.Actor.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.