Class Icon

java.lang.Object
org.xjge.graphics.Icon

public final class Icon
extends java.lang.Object
Represents a quickly comprehensible symbol included to help users better understand an interface. Icons make use of a Atlas and as such, provide utilities for quickly switching between individual sub-images as needed.
Since:
2.0.0
See Also:
Widget
  • Field Summary

    Fields
    Modifier and Type Field Description
    Color color  
  • Constructor Summary

    Constructors
    Constructor Description
    Icon​(Texture texture, int cellWidth, int cellHeight)
    Creates a new icon object which can be used to comprise part of a larger user interface.
  • Method Summary

    Modifier and Type Method Description
    void freeBuffers()
    Convenience method which frees the data buffers allocated by this class.
    void render()
    Renders the icon image.
    void setOpacity​(float opacity)
    Changes the transparency of the icon.
    void setPosition​(int x, int y)
    void setPosition​(org.joml.Vector2i position)
    Sets the current position of the icon.
    void setSubImage​(int cellX, int cellY)
    Sets the sub-image this icon will use

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • color

      public Color color
  • Constructor Details

    • Icon

      public Icon​(Texture texture, int cellWidth, int cellHeight)
      Creates a new icon object which can be used to comprise part of a larger user interface.
      Parameters:
      texture - the texture image to use
      cellWidth - the width of each sub-image cell in pixels
      cellHeight - the height of each sub-image cell in pixels
  • Method Details

    • setPosition

      public void setPosition​(org.joml.Vector2i position)
      Sets the current position of the icon.
      Parameters:
      position - the position to set this icon to in the viewport
    • setPosition

      public void setPosition​(int x, int y)
      Parameters:
      x - the x-coordinate to place the icon at in the viewport
      y - the y-coordinate to place the icon at in the viewport
    • setSubImage

      public void setSubImage​(int cellX, int cellY)
      Sets the sub-image this icon will use
      Parameters:
      cellX - the location of the cell along the x-axis as it appears in the texture atlas
      cellY - the location of the cell along the y-axis as it appears in the texture atlas
    • setOpacity

      public void setOpacity​(float opacity)
      Changes the transparency of the icon.
      Parameters:
      opacity - a number between 0 and 1 used to indicate how transparent the icon will be
    • render

      public void render()
      Renders the icon image.
    • freeBuffers

      public void freeBuffers()
      Convenience method which frees the data buffers allocated by this class.