Class ColorOption

All Implemented Interfaces:
ClientColorBinding, Serializable<ColorOption.Value>

public class ColorOption extends Option<ColorOption.Value> implements ClientColorBinding
An option for selecting and configuring colors

ColorOption provides a way to store and modify color values with associated opacity settings
  • Constructor Details

    • ColorOption

      public ColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity)
      Creates a new color option with single opacity
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      defaultColor - The default color
      fillOpacity - The opacity value used
    • ColorOption

      public ColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, Option<?> parent)
      Creates a new color option with single opacity and a parent option
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      defaultColor - The default color
      fillOpacity - The opacity value used
      parent - The parent option, or null if this is a root option
    • ColorOption

      public ColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, float outlineOpacity)
      Creates a new color option with separate fill and outline opacity
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      defaultColor - The default color
      fillOpacity - The opacity value for fill
      outlineOpacity - The opacity value for outline
    • ColorOption

      public ColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, float outlineOpacity, Option<?> parent)
      Creates a new color option with separate fill and outline opacity and a parent option
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      defaultColor - The default color
      fillOpacity - The opacity value for fill
      outlineOpacity - The opacity value for outline
      parent - The parent option, or null if this is a root option
    • ColorOption

      protected ColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, float outlineOpacity, boolean singleOpacity)
  • Method Details

    • getValue

      public ColorOption.Value getValue()
      Description copied from class: Option
      Gets the current value of this option
      Specified by:
      getValue in class Option<ColorOption.Value>
      Returns:
      The current value
    • setValue

      public ColorOption.Value setValue(ColorOption.Value newValue)
      Description copied from class: Option
      Sets the value of this option
      Specified by:
      setValue in class Option<ColorOption.Value>
      Parameters:
      newValue - The new value to set
      Returns:
      The value that was set (may be different from newValue if validation was performed)
    • reset

      public ColorOption.Value reset()
      Description copied from class: Option
      Resets this option to its default value
      Specified by:
      reset in class Option<ColorOption.Value>
      Returns:
      The default value
    • isSingleOpacity

      public boolean isSingleOpacity()
      Checks if this color option uses a single opacity value
      Returns:
      true if single opacity is used, false if separate fill and outline opacity values are used
    • getDefaultValue

      public ColorOption.Value getDefaultValue()
      Gets a copy of the default value for this option
      Returns:
      A copy of the default value
    • toJson

      public com.google.gson.JsonObject toJson()
      Specified by:
      toJson in interface Serializable<ColorOption.Value>
      Returns:
      The object as a JsonObject
    • fromJson

      public ColorOption.Value fromJson(com.google.gson.JsonObject object)
      Specified by:
      fromJson in interface Serializable<ColorOption.Value>
      Parameters:
      object - The JsonObject to deserialize
      Returns:
      The deserialized object
    • onClientColorDeleted

      public void onClientColorDeleted()
      Description copied from interface: ClientColorBinding
      Called when the bound color has been deleted. Implementations should fall back to a safe default.
      Specified by:
      onClientColorDeleted in interface ClientColorBinding