Class TrcDiscreteValue

java.lang.Object
trclib.dataprocessor.TrcDiscreteValue

public class TrcDiscreteValue extends Object
This class implements a discrete value where the value can only be set in the interval of specified increment. It provides methods to set the value up or down by increment. It also provides methods to change the increment by an order of 10, in essence making the increment to specify the significant digit of the value to be changed. This is especially useful for using the buttons of a game controller to change a value without using a keyboard to type in a value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
     
    private final double
     
    private final double
     
    private final String
     
    private double
     
    private final double
     
    private final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcDiscreteValue(String instanceName, double valueMin, double valueMax, double incMin, double incMax, double defValue, double defInc)
    Constructor: Create an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    This method decreases the increment by an order of 10 only if the resulting increment does not go below incMin.
    double
    This method decreases the value by the increment amount only if the resulting value does not go below valueMin.
    double
    This method returns the current increment.
    double
    This method returns the current value.
    This method returns the instance name.
    double
    This method increases the increment by an order of 10 only if the resulting increment does not go above incMax.
    double
    This method increases the value by the increment amount only if the resulting value does not go above valueMax.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • instanceName

      private final String instanceName
    • valueMin

      private final double valueMin
    • valueMax

      private final double valueMax
    • incMin

      private final double incMin
    • incMax

      private final double incMax
    • value

      private double value
    • inc

      private double inc
  • Constructor Details

    • TrcDiscreteValue

      public TrcDiscreteValue(String instanceName, double valueMin, double valueMax, double incMin, double incMax, double defValue, double defInc)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      valueMin - specifies the value's minimum.
      valueMax - specifies the value's maximum.
      incMin - specifies the increment's minimum.
      incMax - specifies the increment's maximum.
      defValue - specifies the initial value.
      defInc - specifies the initial increment.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • getValue

      public double getValue()
      This method returns the current value.
      Returns:
      current value.
    • getIncrement

      public double getIncrement()
      This method returns the current increment.
      Returns:
      current increment.
    • upValue

      public double upValue()
      This method increases the value by the increment amount only if the resulting value does not go above valueMax.
      Returns:
      the resulting value.
    • downValue

      public double downValue()
      This method decreases the value by the increment amount only if the resulting value does not go below valueMin.
      Returns:
      the resulting value.
    • upIncrement

      public double upIncrement()
      This method increases the increment by an order of 10 only if the resulting increment does not go above incMax.
      Returns:
      the resulting increment.
    • downIncrement

      public double downIncrement()
      This method decreases the increment by an order of 10 only if the resulting increment does not go below incMin.
      Returns:
      the resulting increment.