Class 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.
    • Constructor Detail

      • PreferencesSet

        public PreferencesSet​(java.lang.String name,
                              PreferencesListener listener)
        Construct a new PreferencesSet object with the given name and PreferencesListener. 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 all PreferencesSet objects.
        listener - The listener to call each time an update happens
      • PreferencesSet

        public PreferencesSet​(java.lang.String name)
        Construct a new PreferencesSet object with the given name.
        Parameters:
        name - The prefix to use for all preferences in the set. This name must be unique among all PreferencesSet 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 new DoublePreference and add it to the set
        Parameters:
        name - The name of the preference
        value - The default value
        Returns:
        The newly created preference
      • addInt

        public IntPreference addInt​(java.lang.String name,
                                    int value)
        Create a new IntPreference and add it to the set
        Parameters:
        name - The name of the preference
        value - The default value
        Returns:
        The newly created preference
      • addBoolean

        public BooleanPreference addBoolean​(java.lang.String name,
                                            boolean value)
        Create a new BooleanPreference and add it to the set
        Parameters:
        name - The name of the preference
        value - The default value
        Returns:
        The newly created preference
      • addString

        public StringPreference addString​(java.lang.String name,
                                          java.lang.String value)
        Create a new StringPreference and add it to the set
        Parameters:
        name - The name of the preference
        value - 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 ScalarPreference
        components - 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}