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 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

Constructor Summary
Image()
          Creates an image with no region or patch, stretched, and aligned center.
Image(Drawable drawable)
          Creates an image stretched, and aligned center.
Image(Drawable drawable, Scaling scaling)
          Creates an image aligned center.
Image(Drawable drawable, Scaling scaling, int align)
           
Image(NinePatch patch)
          Creates an image stretched, and aligned center.
Image(Skin skin, String drawableName)
          Creates an image stretched, and aligned center.
Image(Texture texture)
          Creates an image stretched, and aligned center.
Image(TextureRegion region)
          Creates an image stretched, and aligned center.
 
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.
 Drawable getDrawable()
           
 float getImageHeight()
           
 float getImageWidth()
           
 float getImageX()
           
 float getImageY()
           
 float getMinHeight()
           
 float getMinWidth()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 void layout()
          Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child.
 void setAlign(int align)
           
 void setDrawable(Drawable drawable)
           
 void setDrawable(Skin skin, String drawableName)
           
 void setScaling(Scaling scaling)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, hit, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate
 
Methods inherited from class java.lang.Object
equals, 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(NinePatch patch)
Creates an image stretched, and aligned center.

Parameters:
patch - May be null.

Image

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

Parameters:
region - May be null.

Image

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


Image

public Image(Skin skin,
             String drawableName)
Creates an image stretched, and aligned center.


Image

public Image(Drawable drawable)
Creates an image stretched, and aligned center.

Parameters:
drawable - May be null.

Image

public Image(Drawable drawable,
             Scaling scaling)
Creates an image aligned center.

Parameters:
drawable - May be null.

Image

public Image(Drawable drawable,
             Scaling scaling,
             int align)
Parameters:
drawable - 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, calls Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child. This method should almost never 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
parentAlpha - Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.

setDrawable

public void setDrawable(Skin skin,
                        String drawableName)

setDrawable

public void setDrawable(Drawable drawable)

getDrawable

public Drawable getDrawable()

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

getImageX

public float getImageX()

getImageY

public float getImageY()

getImageWidth

public float getImageWidth()

getImageHeight

public float getImageHeight()


Copyright © 2013. All Rights Reserved.