Class WheelswitchFormatter

java.lang.Object
xal.extension.widgets.swing.wheelswitch.WheelswitchFormatter

public class WheelswitchFormatter extends Object
Formats java.lang.Strings to be displayed as digits in the Wheelswitch. The format is specified in a format java.lang.String. WheelswitchFormatter also stores the value, its bounds (minimum and maximum) and also the unit displayed by the Wheelswitch.
Version:
$id$
Author:
Jernej Kamenik
  • Field Details

    • defFormatter

      protected PrintfFormat defFormatter
    • formatter

      protected PrintfFormat formatter
    • formatString

      protected String formatString
    • generatedFormatString

      protected String generatedFormatString
    • unit

      protected String unit
    • valueString

      protected String valueString
    • maximum

      protected double maximum
    • minimum

      protected double minimum
    • value

      protected double value
  • Constructor Details

    • WheelswitchFormatter

      public WheelswitchFormatter(String newFormatString)
      Constructs the PlainWheelswitchFormatter and sets the format string.
      Parameters:
      newFormatString -
      See Also:
    • WheelswitchFormatter

      public WheelswitchFormatter()
      Constructs the PlainWheelswitchFormatter with no format string.
      See Also:
  • Method Details

    • setFormat

      public final void setFormat(String newFormatString) throws IllegalArgumentException
      Sets the format string specifying the format of Wheelswitch display. The format is first checked for validity by the checkFormat(String) method.
      Parameters:
      newFormatString -
      Throws:
      IllegalArgumentException - DOCUMENT ME!
      See Also:
    • getFormat

      public String getFormat()
      Gets the currently stored format string.
      Returns:
      DOCUMENT ME!
    • setMaximum

      public final void setMaximum(double newMaximum)
      Sets a new maximum allowed value.
      Parameters:
      newMaximum - DOCUMENT ME!
    • getMaximum

      public double getMaximum()
      Gets the current maximum allowed value.
      Returns:
      double
    • setMinimum

      public final void setMinimum(double newMinimum)
      Sets a new minimum allowed value.
      Parameters:
      newMinimum - DOCUMENT ME!
    • getMinimum

      public double getMinimum()
      Gets the current minimum allowed value.
      Returns:
      double
    • setString

      public void setString(String newValueString)
      DOCUMENT ME!
      Parameters:
      newValueString - String representing the number to be formatted.
    • getString

      public String getString()
      Gets the formatted string representing the currently stored value.
      Returns:
      String
    • setValue

      public void setValue(double newValue)
      Sets a new value and stores its formatted string. It only accepts values within bounds (maximum and minimum).
      Parameters:
      newValue - DOCUMENT ME!
      See Also:
    • getValue

      public double getValue()
      Gets the currently stored value.
      Returns:
      double
    • checkFormat

      public static boolean checkFormat(String format)
      Checks the number format string. The format string should only consist of characters '#' reperesenting a single number digit, '+' representing a sign digit, '.' representing the decimal symbol digit and 'E' representing the exponent denominator. These characters should be arranged in such way that substitution of the characters '#' with any numerical digits would result in a correct double expression acceptible by Double.parseDouble().
      Parameters:
      format -
      Returns:
      true if a correct format string was entered, false otherwise.
    • transformFormat

      public static String transformFormat(String format)
      A conviniance method for transforming between the Printf type format strings and wheelswitch type format strings. The transform can be used in either direction. The method does not check for validity of the supplied parameter string and may return bogus results if invalid format strings are passed to it.
      Parameters:
      format - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
      Throws:
      NullPointerException - DOCUMENT ME!
      IllegalArgumentException - DOCUMENT ME!
    • setMaximumDigits

      public void setMaximumDigits(int i)
      Sets the maximum allowed number of digits to represent the value.
      Parameters:
      i -
    • getMaximumDigits

      public int getMaximumDigits()
      Sets the maximum allowed number of digits to represent the value.
      Returns:
      number of allowed digits.
    • setUnit

      public void setUnit(String unit)
      Sets the unit.
      Parameters:
      unit - The unit to set
    • getUnit

      public String getUnit()
      Returns the unit.
      Returns:
      String
    • generateFormat

      protected String generateFormat()