Class Appearance

java.lang.Object
de.gurkenlabs.litiengine.gui.Appearance

public class Appearance extends Object
Represents the appearance settings for a GUI component.
  • Constructor Details

    • Appearance

      public Appearance()
      Constructs a new Appearance with default settings.
    • Appearance

      public Appearance(Color foreColor)
      Constructs a new Appearance with the specified foreground color.
      Parameters:
      foreColor - the foreground color
    • Appearance

      public Appearance(Color foreColor, Color backColor)
      Constructs a new Appearance with the specified foreground and background colors.
      Parameters:
      foreColor - the foreground color
      backColor - the background color
  • Method Details

    • equals

      public boolean equals(Object obj)
      Compares this Appearance object to the specified object for equality.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if the specified object is equal to this Appearance, false otherwise
    • hashCode

      public int hashCode()
      Returns a hash code value for this Appearance object.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this Appearance object
    • getForeColor

      public Color getForeColor()
      Gets the foreground color.
      Returns:
      the foreground color
    • getBackgroundColor1

      public Color getBackgroundColor1()
      Gets the first background color.
      Returns:
      the first background color
    • getBackgroundColor2

      public Color getBackgroundColor2()
      Gets the second background color.
      Returns:
      the second background color
    • getBackgroundPaint

      public Paint getBackgroundPaint(double width, double height)
      Gets the background paint for the specified dimensions.
      Parameters:
      width - the width of the component
      height - the height of the component
      Returns:
      the background paint, or null if the background is transparent
    • getBorderColor

      public Color getBorderColor()
      Gets the border color.
      Returns:
      the border color
    • getBorderStyle

      public Stroke getBorderStyle()
      Gets the border style.
      Returns:
      the border style
    • getBorderRadius

      public float getBorderRadius()
      Gets the border radius.
      Returns:
      the border radius
    • isHorizontalBackgroundGradient

      public boolean isHorizontalBackgroundGradient()
      Checks if the background gradient is horizontal.
      Returns:
      true if the background gradient is horizontal, false otherwise
    • isTransparentBackground

      public boolean isTransparentBackground()
      Checks if the background is transparent.
      Returns:
      true if the background is transparent, false otherwise
    • setForeColor

      public void setForeColor(Color foreColor)
      Sets the foreground color and triggers a change event.
      Parameters:
      foreColor - the new foreground color
    • setBackgroundColor1

      public void setBackgroundColor1(Color backColor1)
      Sets the first background color and triggers a change event.
      Parameters:
      backColor1 - the new first background color
    • setBackgroundColor2

      public void setBackgroundColor2(Color backColor2)
      Sets the second background color and triggers a change event.
      Parameters:
      backColor2 - the new second background color
    • setBorderColor

      public void setBorderColor(Color color)
      Sets the border color.
      Parameters:
      color - the new border color
    • setBorderStyle

      public void setBorderStyle(Stroke style)
      Sets the border style.
      Parameters:
      style - the new border style
    • setBorderRadius

      public void setBorderRadius(float radius)
      Sets the border radius.
      Parameters:
      radius - the new border radius
    • setHorizontalBackgroundGradient

      public void setHorizontalBackgroundGradient(boolean horizontal)
      Sets whether the background gradient is horizontal and triggers a change event.
      Parameters:
      horizontal - true if the background gradient is horizontal, false otherwise
    • setTransparentBackground

      public void setTransparentBackground(boolean transparentBackground)
      Sets whether the background is transparent and triggers a change event.
      Parameters:
      transparentBackground - true if the background is transparent, false otherwise
    • onChange

      public void onChange(Consumer<Appearance> cons)
      Adds a consumer to be notified when the appearance changes.
      Parameters:
      cons - the consumer to be added
    • update

      public void update(Appearance updateAppearance)
      Updates the appearance settings with the values from the specified Appearance object.
      Parameters:
      updateAppearance - the Appearance object containing the new settings
    • fireOnChangeEvent

      protected void fireOnChangeEvent()
      Triggers the change event for all registered consumers.