Class 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.
    • 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.
      • Image

        public Image​(@Null
                     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() 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​(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.
      • 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()
      • getImageX

        public float getImageX()
      • getImageY

        public float getImageY()
      • getImageWidth

        public float getImageWidth()
      • getImageHeight

        public float getImageHeight()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Actor