Class Image

All Implemented Interfaces:
Layout
Direct Known Subclasses:
AnimatedImage, ImageWithParentColor

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 Details

    • 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(@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.
    • Image

      public Image(@Null Drawable drawable, Scaling scaling, int align)
      Parameters:
      drawable - May be null.
  • Method Details

    • 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() on 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(Batch 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 - The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
    • 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.
    • getDrawable

      @Null public Drawable getDrawable()
      Returns:
      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:
      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()
    • toString

      public String toString()
      Overrides:
      toString in class Actor