Package org.hyperonline.hyperlib.pref
Class PreferencesSet
- java.lang.Object
-
- org.hyperonline.hyperlib.pref.PreferencesSet
-
public class PreferencesSet extends java.lang.Object
This class provides a set of related preferences, with some functionality grouped together. Each preference is prefixed by the same name, so that the preferences all show up near each other in the dashboard. Example use-cases are subsystems, PID controllers, and specific tasks like vision and driving, which may have many related preferences. It is safe to share this object, as well as the Preference objects it creates, among multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SEPARATOR
-
Constructor Summary
Constructors Constructor Description PreferencesSet(java.lang.String name)
Construct a newPreferencesSet
object with the given name.PreferencesSet(java.lang.String name, PreferencesListener listener)
Construct a newPreferencesSet
object with the given name andPreferencesListener
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanPreference
addBoolean(java.lang.String name, boolean value)
Create a newBooleanPreference
and add it to the setDoublePreference
addDouble(java.lang.String name, double value)
Create a newDoublePreference
and add it to the setIntPreference
addInt(java.lang.String name, int value)
Create a newIntPreference
and add it to the setScalarPreference
addScalar(java.lang.String name, java.lang.String components, double... value)
StringPreference
addString(java.lang.String name, java.lang.String value)
Create a newStringPreference
and add it to the setjava.lang.String
getName()
The name of the set is the prefix used for each preference
-
-
-
Field Detail
-
SEPARATOR
public static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PreferencesSet
public PreferencesSet(java.lang.String name, PreferencesListener listener)
Construct a newPreferencesSet
object with the given name andPreferencesListener
. Each time a preference in the set is updated, the listener will be called.- Parameters:
name
- The prefix to use for all preferences in the set. This name must be unique among allPreferencesSet
objects.listener
- The listener to call each time an update happens
-
PreferencesSet
public PreferencesSet(java.lang.String name)
Construct a newPreferencesSet
object with the given name.- Parameters:
name
- The prefix to use for all preferences in the set. This name must be unique among allPreferencesSet
objects.
-
-
Method Detail
-
getName
public java.lang.String getName()
The name of the set is the prefix used for each preference- Returns:
- The name of the set
-
addDouble
public DoublePreference addDouble(java.lang.String name, double value)
Create a newDoublePreference
and add it to the set- Parameters:
name
- The name of the preferencevalue
- The default value- Returns:
- The newly created preference
-
addInt
public IntPreference addInt(java.lang.String name, int value)
Create a newIntPreference
and add it to the set- Parameters:
name
- The name of the preferencevalue
- The default value- Returns:
- The newly created preference
-
addBoolean
public BooleanPreference addBoolean(java.lang.String name, boolean value)
Create a newBooleanPreference
and add it to the set- Parameters:
name
- The name of the preferencevalue
- The default value- Returns:
- The newly created preference
-
addString
public StringPreference addString(java.lang.String name, java.lang.String value)
Create a newStringPreference
and add it to the set- Parameters:
name
- The name of the preferencevalue
- The default value- Returns:
- The newly created preference
-
addScalar
public ScalarPreference addScalar(java.lang.String name, java.lang.String components, double... value)
- Parameters:
name
- name of the ScalarPreferencecomponents
- A sequence of letters indicating the components. For example, "RGB", "HSV", "XYZ", etc. It may be any length.value
- Array of values to assign to components- Returns:
- {ScalarPreference}
-
-