Class Image
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.Actor
-
- com.badlogic.gdx.scenes.scene2d.ui.Widget
-
- com.badlogic.gdx.scenes.scene2d.ui.Image
-
- All Implemented Interfaces:
Layout
public class Image extends Widget
Displays aDrawable, scaled various way within the widgets bounds. The preferred size is the min size of the drawable. Only when using aTextureRegionDrawablewill the actor's scale, rotation, and origin be used when drawing.
-
-
Constructor Summary
Constructors Constructor Description Image()Creates an image with no drawable, stretched, and aligned center.Image(NinePatch patch)Creates an image stretched, and aligned center.Image(TextureRegion region)Creates an image stretched, and aligned center.Image(Texture texture)Creates an image stretched, and aligned center.Image(Skin skin, java.lang.String drawableName)Creates an image 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddraw(Batch batch, float parentAlpha)If this method is overridden, the super method orWidget.validate()should be called to ensure the widget is laid out.intgetAlign()DrawablegetDrawable()floatgetImageHeight()floatgetImageWidth()floatgetImageX()floatgetImageY()floatgetMinHeight()floatgetMinWidth()floatgetPrefHeight()floatgetPrefWidth()voidlayout()Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()on any each child whose width or height has changed, and callsLayout.validate()on each child.voidsetAlign(int align)voidsetDrawable(Skin skin, java.lang.String drawableName)voidsetDrawable(Drawable drawable)Sets a new drawable for the image.voidsetScaling(Scaling scaling)java.lang.StringtoString()-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
-
-
-
Constructor Detail
-
Image
public Image()
Creates an image with no drawable, stretched, and aligned center.
-
Image
public Image(@Null NinePatch patch)
Creates an image stretched, and aligned center.- Parameters:
patch- May be null.
-
Image
public Image(@Null 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, java.lang.String drawableName)
Creates an image stretched, and aligned center.
-
Image
public Image(@Null Drawable drawable)
Creates an image stretched, and aligned center.- Parameters:
drawable- May be null.
-
Image
public Image(@Null Drawable drawable, Scaling scaling)
Creates an image aligned center.- Parameters:
drawable- May be null.
-
-
Method Detail
-
layout
public void layout()
Description copied from interface:LayoutComputes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()on any each child whose width or height has changed, and callsLayout.validate()on each child. This method should almost never be called directly, insteadLayout.validate()should be used.
-
draw
public void draw(Batch batch, float parentAlpha)
Description copied from class:WidgetIf this method is overridden, the super method orWidget.validate()should be called to ensure the widget is laid out.
-
setDrawable
public void setDrawable(Skin skin, java.lang.String drawableName)
-
setDrawable
public void setDrawable(@Null 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,Widget.pack()can be used to size the image to its pref size.- Parameters:
drawable- May be null.
-
setScaling
public void setScaling(Scaling scaling)
-
setAlign
public void setAlign(int align)
-
getAlign
public int getAlign()
-
getMinWidth
public float getMinWidth()
- Specified by:
getMinWidthin interfaceLayout- Overrides:
getMinWidthin classWidget
-
getMinHeight
public float getMinHeight()
- Specified by:
getMinHeightin interfaceLayout- Overrides:
getMinHeightin classWidget
-
getPrefWidth
public float getPrefWidth()
- Specified by:
getPrefWidthin interfaceLayout- Overrides:
getPrefWidthin classWidget
-
getPrefHeight
public float getPrefHeight()
- Specified by:
getPrefHeightin interfaceLayout- Overrides:
getPrefHeightin classWidget
-
getImageX
public float getImageX()
-
getImageY
public float getImageY()
-
getImageWidth
public float getImageWidth()
-
getImageHeight
public float getImageHeight()
-
-