Enum ShiftType

    • Enum Constant Detail

      • RELATIVE

        public static final ShiftType RELATIVE
        A relative shift where the value is scaled by the shift amount.

        The shift amount is interpreted as a decimal percentage. For example, a shift amount of 0.1 is a shift of +10% which multiplies the value by 1.1. A shift amount of -0.2 is a shift of -20% which multiplies the value by 0.8.

        shiftedValue = (value + value * shiftAmount)

        shiftAmount is well-defined for nonzero value.

      • ABSOLUTE

        public static final ShiftType ABSOLUTE
        An absolute shift where the shift amount is added to the value.

        shiftedValue = (value + shiftAmount)

      • SCALED

        public static final ShiftType SCALED
        A scaled shift where the value is multiplied by the shift.

        shiftedValue = (value * shiftAmount)

        shiftAmount is well-defined for nonzero value.

    • Method Detail

      • values

        public static ShiftType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ShiftType c : ShiftType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ShiftType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • of

        public static ShiftType of​(String name)
        Obtains an instance from the specified name.

        Parsing handles the mixed case form produced by toString() and the upper and lower case variants of the enum constant name.

        Parameters:
        name - the name to parse
        Returns:
        the type
        Throws:
        IllegalArgumentException - if the name is not known
      • applyShift

        public abstract double applyShift​(double value,
                                          double shiftAmount)
        Applies the shift to the value using appropriate logic for the shift type.
        Parameters:
        value - the value to shift
        shiftAmount - the shift to apply
        Returns:
        the shifted value
      • toValueAdjustment

        public abstract ValueAdjustment toValueAdjustment​(double shiftAmount)
        Returns a value adjustment that applies the shift amount using appropriate logic for the shift type.
        Parameters:
        shiftAmount - the shift to apply
        Returns:
        a value adjustment that applies the shift amount using appropriate logic for the shift type
      • computeShift

        public abstract double computeShift​(double baseValue,
                                            double shiftedValue)
        Computes the shift amount using appropriate logic for the shift type.
        Parameters:
        baseValue - the base value
        shiftedValue - the shifted value
        Returns:
        the shift amount
      • toString

        public String toString()
        Returns the formatted name of the type.
        Overrides:
        toString in class Enum<ShiftType>
        Returns:
        the formatted string representing the type