DESY ACOP Beans Home

com.cosylab.gui.components.wheelswitch
Class AbstractWheelswitchFormatter

java.lang.Object
  extended by com.cosylab.gui.components.wheelswitch.AbstractWheelswitchFormatter
Direct Known Subclasses:
RadialWheelswitchFormatter, WheelswitchFormatter

public abstract class AbstractWheelswitchFormatter
extends java.lang.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 Summary
protected  boolean debug
           
protected  PrintfFormat defFormatter
           
protected  java.lang.String formatString
           
protected  PrintfFormat formatter
           
protected  java.lang.String generatedFormatString
           
protected  double maximum
           
protected  int maximumDigits
           
protected  double minimum
           
protected  java.lang.String unit
           
protected  double value
           
protected  java.lang.String valueString
           
 
Constructor Summary
AbstractWheelswitchFormatter()
          Constructs the PlainWheelswitchFormatter with no format string.
AbstractWheelswitchFormatter(java.lang.String newFormatString)
          Constructs the PlainWheelswitchFormatter and sets the format string.
 
Method Summary
static boolean checkFormat(java.lang.String format)
          Checks the number format string.
protected  java.lang.String generateFormat()
           
 java.lang.String getFormat()
          Returns the currently stored format string.
 double getMaximum()
          Returns the current maximum allowed value.
 int getMaximumDigits()
          Returns the maximum allowed number of digits to represent the value.
 double getMinimum()
          Returns the current minimum allowed value.
 java.lang.String getString()
          Returns the formatted string representing the currently stored value.
 java.lang.String getUnit()
          Returns the unit.
 double getValue()
          Returns the currently stored value.
protected abstract  void internalSetString(java.lang.String newValueString)
           
 void setFormat(java.lang.String newFormatString)
          Sets the format string specifiing the format of Wheelswitch display.
 void setMaximum(double newMaximum)
          Sets a new maximum allowed value.
 void setMaximumDigits(int i)
          Sets the maximum allowed number of digits to represent the value.
 void setMinimum(double newMinimum)
          Sets a new minimum allowed value.
 void setString(java.lang.String newValueString)
          Sets the value as string.
 void setUnit(java.lang.String unit)
          Sets the unit.
 void setValue(double newValue)
          Sets a new value and stores its formatted string.
static java.lang.String transformFormat(java.lang.String format)
          A conviniance method for transforming between the Printf type format strings and wheelswitch type format strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defFormatter

protected PrintfFormat defFormatter

formatter

protected PrintfFormat formatter

formatString

protected java.lang.String formatString

generatedFormatString

protected java.lang.String generatedFormatString

unit

protected java.lang.String unit

valueString

protected java.lang.String valueString

maximum

protected double maximum

minimum

protected double minimum

value

protected double value

maximumDigits

protected int maximumDigits

debug

protected boolean debug
Constructor Detail

AbstractWheelswitchFormatter

public AbstractWheelswitchFormatter(java.lang.String newFormatString)
Constructs the PlainWheelswitchFormatter and sets the format string.

Parameters:
newFormatString -
See Also:
setFormat(String)

AbstractWheelswitchFormatter

public AbstractWheelswitchFormatter()
Constructs the PlainWheelswitchFormatter with no format string.

See Also:
setFormat(String)
Method Detail

setFormat

public void setFormat(java.lang.String newFormatString)
               throws java.lang.IllegalArgumentException
Sets the format string specifiing the format of Wheelswitch display. The format is first checked for validity by the checkFormat(String) method.

Parameters:
newFormatString -
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!
See Also:
Double.parseDouble(String), NumberFormatException

getFormat

public java.lang.String getFormat()
Returns the currently stored format string.

Returns:
the format

setMaximum

public void setMaximum(double newMaximum)
Sets a new maximum allowed value.

Parameters:
newMaximum - new maximum value

getMaximum

public double getMaximum()
Returns the current maximum allowed value.

Returns:
double

setMinimum

public void setMinimum(double newMinimum)
Sets a new minimum allowed value.

Parameters:
newMinimum - new minimum value

getMinimum

public double getMinimum()
Returns the current minimum allowed value.

Returns:
the minimum

setString

public void setString(java.lang.String newValueString)
Sets the value as string.

Parameters:
newValueString - String representing the number to be formatted. It only accepts values within bounds (maximum and minimum).

getString

public java.lang.String getString()
Returns the formatted string representing the currently stored value.

Returns:
value as string

setValue

public void setValue(double newValue)
Sets a new value and stores its formatted string. It accepts any value.

Parameters:
newValue - new value

internalSetString

protected abstract void internalSetString(java.lang.String newValueString)

getValue

public double getValue()
Returns the currently stored value.

Returns:
the value

checkFormat

public static boolean checkFormat(java.lang.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 java.lang.String transformFormat(java.lang.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 -
Returns:
transformed format
Throws:
java.lang.NullPointerException - if format is null
java.lang.IllegalArgumentException - if format is not supported (does not include f,d,i,e or E tag)

setMaximumDigits

public void setMaximumDigits(int i)
Sets the maximum allowed number of digits to represent the value.

Parameters:
i - new maximum number of digits

getMaximumDigits

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

Returns:
number of allowed digits.

setUnit

public void setUnit(java.lang.String unit)
Sets the unit.

Parameters:
unit - new units

getUnit

public java.lang.String getUnit()
Returns the unit.

Returns:
String

generateFormat

protected java.lang.String generateFormat()


Copyright © 2010. All Rights Reserved.