Class WheelswitchFormatter
java.lang.Object
xal.extension.widgets.swing.wheelswitch.WheelswitchFormatter
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 Summary
FieldsModifier and TypeFieldDescriptionprotected PrintfFormatprotected Stringprotected PrintfFormatprotected Stringprotected doubleprotected doubleprotected Stringprotected doubleprotected String -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the PlainWheelswitchFormatter with no format string.WheelswitchFormatter(String newFormatString) Constructs the PlainWheelswitchFormatter and sets the format string. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckFormat(String format) Checks the number format string.protected StringGets the currently stored format string.doubleGets the current maximum allowed value.intSets the maximum allowed number of digits to represent the value.doubleGets the current minimum allowed value.Gets the formatted string representing the currently stored value.getUnit()Returns the unit.doublegetValue()Gets the currently stored value.final voidSets the format string specifying the format ofWheelswitchdisplay.final voidsetMaximum(double newMaximum) Sets a new maximum allowed value.voidsetMaximumDigits(int i) Sets the maximum allowed number of digits to represent the value.final voidsetMinimum(double newMinimum) Sets a new minimum allowed value.voidDOCUMENT ME!voidSets the unit.voidsetValue(double newValue) Sets a new value and stores its formatted string.static StringtransformFormat(String format) A conviniance method for transforming between the Printf type format strings and wheelswitch type format strings.
-
Field Details
-
defFormatter
-
formatter
-
formatString
-
generatedFormatString
-
unit
-
valueString
-
maximum
protected double maximum -
minimum
protected double minimum -
value
protected double value
-
-
Constructor Details
-
WheelswitchFormatter
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
Sets the format string specifying the format ofWheelswitchdisplay. The format is first checked for validity by thecheckFormat(String)method.- Parameters:
newFormatString-- Throws:
IllegalArgumentException- DOCUMENT ME!- See Also:
-
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
DOCUMENT ME!- Parameters:
newValueString- String representing the number to be formatted.
-
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
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 byDouble.parseDouble().- Parameters:
format-- Returns:
- true if a correct format string was entered, false otherwise.
-
transformFormat
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
Sets the unit.- Parameters:
unit- The unit to set
-
getUnit
Returns the unit.- Returns:
- String
-
generateFormat
-