Class IconComponent

java.lang.Object
com.simsilica.lemur.component.AbstractGuiComponent
com.simsilica.lemur.component.IconComponent
All Implemented Interfaces:
ColoredComponent, GuiComponent, Cloneable
Direct Known Subclasses:
NSVGIcon

public class IconComponent extends AbstractGuiComponent implements Cloneable, ColoredComponent
Presents an image as a stackable component that can either by anchored to the sides and take up component space or treated as an overlay. If it is used as an overlay then it will not affect the preferred size of the overall component stack.
  • Constructor Details

    • IconComponent

      public IconComponent(String imagePath)
    • IconComponent

      public IconComponent(String imagePath, float iconScale, float xMargin, float yMargin, float zOffset, boolean lit)
    • IconComponent

      public IconComponent(String imagePath, Vector2f iconScale, float xMargin, float yMargin, float zOffset, boolean lit)
    • IconComponent

      public IconComponent(Texture image, Vector2f iconScale, float xMargin, float yMargin, float zOffset, boolean lit)
  • Method Details

    • clone

      public IconComponent clone()
      Specified by:
      clone in interface GuiComponent
      Overrides:
      clone in class AbstractGuiComponent
    • attach

      public void attach(GuiControl parent)
      Specified by:
      attach in interface GuiComponent
      Overrides:
      attach in class AbstractGuiComponent
    • detach

      public void detach(GuiControl parent)
      Specified by:
      detach in interface GuiComponent
      Overrides:
      detach in class AbstractGuiComponent
    • setImageTexture

      public void setImageTexture(Texture t)
    • getImageTexture

      public Texture getImageTexture()
    • setColor

      public void setColor(ColorRGBA c)
      Description copied from interface: ColoredComponent
      Sets the color for this component.
      Specified by:
      setColor in interface ColoredComponent
    • resetColor

      protected void resetColor()
    • getColor

      public ColorRGBA getColor()
      Description copied from interface: ColoredComponent
      Returns the current color of this component.
      Specified by:
      getColor in interface ColoredComponent
    • setAlpha

      public void setAlpha(float f)
      Description copied from interface: ColoredComponent
      Sets an alpha multiplier that will be applied to the color when set to the actual visuals.
      Specified by:
      setAlpha in interface ColoredComponent
    • getAlpha

      public float getAlpha()
      Description copied from interface: ColoredComponent
      Returns the current alpha multiplier that is applied to the color when set to the actual visuals.
      Specified by:
      getAlpha in interface ColoredComponent
    • setIconScale

      public void setIconScale(float scale)
    • setIconScale

      public void setIconScale(Vector2f scale)
    • getIconScale

      public Vector2f getIconScale()
    • setIconSize

      public void setIconSize(Vector2f iconSize)
      Forces the size of the icon to be the size specified regardless of it's actual pixel size. So if setIconSize(new Vector2f(64, 64)) is used for an icon that is actually 32x32, it will be doubled in size. The iconScale is applied after this scaling. Set iconSize to null to go back to the actual image size.
    • getIconSize

      public Vector2f getIconSize()
    • setHAlignment

      public void setHAlignment(HAlignment a)
    • getHAlignment

      public HAlignment getHAlignment()
    • setVAlignment

      public void setVAlignment(VAlignment a)
    • getVAlignment

      public VAlignment getVAlignment()
    • setMargin

      public void setMargin(float x, float y)
    • setMargin

      public void setMargin(Vector2f margin)
    • getMargin

      public Vector2f getMargin()
    • setZOffset

      public void setZOffset(float z)
    • getZOffset

      public float getZOffset()
    • setOffset

      public void setOffset(Vector3f v)
    • getOffset

      public Vector3f getOffset()
    • setOverlay

      public void setOverlay(boolean f)
    • isOverlay

      public boolean isOverlay()
    • setAlphaDiscard

      public void setAlphaDiscard(float alphaDiscard)
      Sets the alphaDiscardThreshold for the image material. If an alpha value is below this threshold then it will be discarded rather than being written to the color and zbuffers. Set to 0 to disable. Defaults to 0.

      Note: for 2D UIs this threshold is not necessary as 2D GUIs will always sort purely back-to-front on Z. For 3D UIs, this setting may prevent visual artifacts from certain directions for very transparent pixels (background showing through, etc.))

    • getAlphaDiscard

      public float getAlphaDiscard()
    • getMaterial

      public GuiMaterial getMaterial()
    • calculatePreferredSize

      public void calculatePreferredSize(Vector3f size)
      Specified by:
      calculatePreferredSize in interface GuiComponent
    • reshape

      public void reshape(Vector3f pos, Vector3f size)
      Specified by:
      reshape in interface GuiComponent
    • resetAlignment

      protected void resetAlignment()
    • getIcon

      protected Geometry getIcon()
    • createIcon

      protected Geometry createIcon()
    • getEffectiveIconSize

      protected Vector2f getEffectiveIconSize()