DESY ACOP Beans Home

com.cosylab.gui.components.numberfield
Interface NumberDescriptor

All Known Implementing Classes:
AngleNumberDescriptor, DefaultNumberDescriptor, HMSNumberDescriptor, Rad2DegNumberDescriptor, Rad2HMSNumberDescriptor

public interface NumberDescriptor

Implementation of this interface provides conversion of a Number to String and back. This interface acts as kind of interpretation of a Number with bijective transformation to string.

This interfaces provides more flexible visualization of number as string than is available with standard ANSI C kind of formatting. For example: display and edit double value in hh:mm:ss format (interpret it as degrees).

It is advised for the descriptor implementation to define two final static String fields: NAME and DESCRIPTION. First should be short descriptive name and second should be short description. These strings are used in GUI choosers for NumberField visualization.

Author:
Igor Kriznar

Method Summary
 java.lang.String getFormat()
          Returns the format
 java.lang.Class getNumberType()
          Returns last set number type.
 java.lang.Number parseNumber(java.lang.String number)
          Parses string and creates Number.
 java.lang.String printEditString(java.lang.Number number)
          Converts provided Number to a string, which is displayed when NumberField enters in to edit mode and wants to edit value.
 java.lang.String printString(java.lang.Number number)
          Converts provided Number to a string, which is used for displaying the value.
 void setFormat(java.lang.String format)
          Set the Number format
 void setNumberType(java.lang.Class newClass)
          Sets number type to descriptor, ame as used on number field.
 

Method Detail

parseNumber

java.lang.Number parseNumber(java.lang.String number)
Parses string and creates Number. If string is not presentation of a number and can not be parsed, then null must be returned.

Parameters:
number - a string representing a number
Returns:
instance of Number or null if string can not be parsed

printString

java.lang.String printString(java.lang.Number number)
Converts provided Number to a string, which is used for displaying the value.

Parameters:
number - a number to be transformed to string
Returns:
a String representing a number.

printEditString

java.lang.String printEditString(java.lang.Number number)
Converts provided Number to a string, which is displayed when NumberField enters in to edit mode and wants to edit value. Edit string is usually stripped from unnecessary characters and prepared for easyer user editing.

Parameters:
number - a number to be transformed to string
Returns:
a String representation a number prepared for editing.

getFormat

java.lang.String getFormat()
Returns the format

Returns:
Format

setFormat

void setFormat(java.lang.String format)
Set the Number format

Parameters:
format -

setNumberType

void setNumberType(java.lang.Class newClass)
Sets number type to descriptor, ame as used on number field.

Parameters:
newClass - number type

getNumberType

java.lang.Class getNumberType()
Returns last set number type.

Returns:
last set number type


Copyright © 2010. All Rights Reserved.