Package dev.boze.api.option
Class ColorOption
- All Implemented Interfaces:
ClientColorBinding,Serializable<ColorOption.Value>
An option for selecting and configuring colors
ColorOption provides a way to store and modify color values with associated opacity settings
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classColor selection value stored by the option. -
Field Summary
Fields inherited from class dev.boze.api.option.Option
description, name, owner -
Constructor Summary
ConstructorsModifierConstructorDescriptionColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity) Creates a new color option with single opacityColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, float outlineOpacity) Creates a new color option with separate fill and outline opacityprotectedColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, float outlineOpacity, boolean singleOpacity) 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 optionColorOption(BaseModule owner, String name, String description, ClientColor defaultColor, float fillOpacity, Option<?> parent) Creates a new color option with single opacity and a parent option -
Method Summary
Modifier and TypeMethodDescriptionfromJson(com.google.gson.JsonObject object) Gets a copy of the default value for this optiongetValue()Gets the current value of this optionbooleanChecks if this color option uses a single opacity valuevoidCalled when the bound color has been deleted.reset()Resets this option to its default valuesetValue(ColorOption.Value newValue) Sets the value of this optioncom.google.gson.JsonObjecttoJson()Methods inherited from class dev.boze.api.option.Option
getFullName, getParent, isParent, setParent
-
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 optionname- The name of this optiondescription- The description of this optiondefaultColor- The default colorfillOpacity- 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 optionname- The name of this optiondescription- The description of this optiondefaultColor- The default colorfillOpacity- The opacity value usedparent- 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 optionname- The name of this optiondescription- The description of this optiondefaultColor- The default colorfillOpacity- The opacity value for filloutlineOpacity- 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 optionname- The name of this optiondescription- The description of this optiondefaultColor- The default colorfillOpacity- The opacity value for filloutlineOpacity- The opacity value for outlineparent- 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
Description copied from class:OptionGets the current value of this option- Specified by:
getValuein classOption<ColorOption.Value>- Returns:
- The current value
-
setValue
Description copied from class:OptionSets the value of this option- Specified by:
setValuein classOption<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
Description copied from class:OptionResets this option to its default value- Specified by:
resetin classOption<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
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:
toJsonin interfaceSerializable<ColorOption.Value>- Returns:
- The object as a JsonObject
-
fromJson
- Specified by:
fromJsonin interfaceSerializable<ColorOption.Value>- Parameters:
object- The JsonObject to deserialize- Returns:
- The deserialized object
-
onClientColorDeleted
public void onClientColorDeleted()Description copied from interface:ClientColorBindingCalled when the bound color has been deleted. Implementations should fall back to a safe default.- Specified by:
onClientColorDeletedin interfaceClientColorBinding
-