com.numobjects.mathbeans
Class NamedFieldPanel

com.numobjects.mathbeans.NamedFieldPanel

public class NamedFieldPanel
implements java.io.Serializable

Named Field Panel

Several Named Fields can be joined together to form a NamedFieldPanel. Each field may have its own color or colors may be alternating or they may be all the same. The NamedFieldPanel may have a title which is a read-only Named Field. Separators of the fields are connected, so that if one drags the separator, all the fields get adjusted. Of course, the fields are math aware.

See Also:
NamedField, CalcSet, Serialized Form

Constructor Summary
NamedFieldPanel()
          Constructor
NamedFieldPanel(java.awt.Color color)
          Constructor
NamedFieldPanel(java.awt.Color color, java.awt.event.ActionListener listener)
          Constructor
NamedFieldPanel(java.lang.String[] names, java.awt.Color color)
          Constructor
 
Method Summary
 int getActiveFieldsCount()
          Gets active fields count (without the title)
 Translator getBackTranslator(int i)
          Gets back translator of the i-th field (that translates values into text)
 Translator getBackTranslator(java.lang.String name)
          Gets back translator of a field with given name (that translates values into text)
 int getCount()
          Gets total fields count
 java.awt.Color[] getFieldBackground()
          Gets fields backgrounds
 java.awt.Color getFieldBackground(int i)
          Gets i-th field's background
 java.awt.Color[] getFieldForeground()
          Gets fields foregrounds
 java.awt.Color getFieldForeground(int i)
          Gets i-th field's foreground
 int getFieldsCount()
          Gets total displayed fields count (including title)
 java.lang.String[] getNames()
          Gets names (field labels)
 java.lang.String getNames(int i)
          Gets i-th name (field label)
 int getPrecision()
          Gets precision (number of decimal digits)
 java.lang.String getPrompt()
          Gets prompt
 java.lang.String getPrompt(java.lang.String name)
          Gets prompt of a field with a given name
 int getRounding()
          Gets rounding (number of displayed digits after the dot)
 int getRounding(int i)
          Gets rounding (number of displayed digits after the dot) of the i-th field
 int getRounding(java.lang.String name)
          Gets rounding (number of displayed digits after the dot) of a field with a given name
 int getSeparator()
          Gets separator position for the panel
 Translator getTranslator(int i)
          Gets translator of the i-th field (that translates text into values)
 Translator getTranslator(java.lang.String name)
          Gets translator of a field with given name (that translates text into values)
 java.lang.String getValue(int i, boolean translate)
          Gets value of the i-th field with translation (each field might be assigned a translator to map the value to a number)
 java.lang.String getValue(java.lang.String name)
          Gets value of a field with given name
 java.lang.String getValue(java.lang.String name, boolean translate)
          Gets value of a field with given name with translation (each field might be assigned a translator to map the value to a number)
 java.lang.String[] getValues()
          Gets values (including the title value)
 java.lang.String[] getValues(boolean translate)
          Gets values (including the title value) with translation
 java.lang.String getValues(int i)
          Get's i-th value
 boolean isAlternating()
          Queries alternating colors property
 boolean isDisplayErrors()
          Queries display error property
 boolean isDisplayTitle()
          Queries display title property
 boolean isEditable()
          Queries editable property
 boolean isMathAware()
          Queries math awareness property
 boolean isMulticolor()
          Queries multicolor property
 boolean isPrompting()
          Queries prompting property
 boolean isResizable()
          Queries resizable property
 void resetError(int i)
          Clears error for the i-th field
 void resetError(java.lang.String name)
          Clears error for a field with given name
 void setActiveFieldsCount(int count)
          Sets active fields count (number of fields without the title)
 void setAlternating(boolean alternating)
          Sets alternating colors property
 void setBackTranslator(int i, Translator translator)
          Sets back translator for the i-th field (to translate values into text)
 void setBackTranslator(java.lang.String name, Translator translator)
          Sets back translator for a field with given name (to translate values into text)
 void setDisplayErrors(boolean b)
          Sets display error property
 void setDisplayTitle(boolean displayTitle)
          Sets display title property
 void setEditable(boolean b)
          Sets editable property
 void setError(int i)
          Sets error for the i-th field
 void setError(java.lang.String name)
          Sets error for a field with given name
 void setErrorMessage(int i, java.lang.String message)
          Sets error message for the i-th field
 void setErrorMessage(java.lang.String name, java.lang.String message)
          Sets error message for a field with given name
 void setFieldBackground(java.awt.Color[] cc)
          Sets fields backgrounds
 void setFieldBackground(int i, java.awt.Color c)
          Sets i-th field's background
 void setFieldForeground(java.awt.Color[] cc)
          Sets fields foregrounds
 void setFieldForeground(int i, java.awt.Color c)
          Sets i-th field's foreground
 void setMathAware(boolean b)
          Sets math awareness property
 void setMulticolor(boolean b)
          Sets multicolor property (each field may have its own color)
 void setNames(int i, java.lang.String name)
          Sets i-th name (field label)
 void setNames(java.lang.String[] names)
          Sets names (field labels)
 void setPrecision(int value)
          Sets precision for computations (number of decimal digits - between 1 and 15)
 void setPrompt(java.lang.String prompt)
          Sets prompt
 void setPrompt(java.lang.String name, java.lang.String prompt)
          Sets prompt for a field with a given name
 void setPrompting(boolean b)
          Sets prompting property
 void setResizable(boolean flag)
          Sets resizable property (movable separator)
 void setRounding(int value)
          Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding)
 void setRounding(int i, int value)
          Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding) for the i-th field
 void setRounding(java.lang.String name, int value)
          Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding) for a field with a given name
 void setSeparator(int width)
          Sets the separator position for all named fields
 void setTranslator(int i, Translator translator)
          Sets translator for the i-th field (to translate text into values)
 void setTranslator(java.lang.String name, Translator translator)
          Sets translator for a field with given name (to translate text into values)
 void setValue(int i, java.lang.String value, boolean translate)
          Sets value of the i-th field with back translation
 void setValue(java.lang.String name, java.lang.String value)
          Sets value of a field with given name
 void setValue(java.lang.String name, java.lang.String value, boolean translate)
          Sets value of a field with given name with back translation
 void setValues(int i, java.lang.String value)
          Sets i-th value
 void setValues(java.lang.String[] values)
          Sets values (including the title value)
 void setValues(java.lang.String[] values, boolean translate)
          Sets values (including the title value) with translation
 

Constructor Detail

NamedFieldPanel

public NamedFieldPanel()
Constructor

NamedFieldPanel

public NamedFieldPanel(java.awt.Color color)
Constructor
Parameters:
color - base color

NamedFieldPanel

public NamedFieldPanel(java.awt.Color color,
                       java.awt.event.ActionListener listener)
Constructor
Parameters:
color - base color
listener - action listener

NamedFieldPanel

public NamedFieldPanel(java.lang.String[] names,
                       java.awt.Color color)
Constructor
Parameters:
names - label texts
color - base color
Method Detail

setEditable

public void setEditable(boolean b)
Sets editable property
Parameters:
b - editable property flag

isEditable

public boolean isEditable()
Queries editable property
Returns:
property flag

setMathAware

public void setMathAware(boolean b)
Sets math awareness property
Parameters:
b - property flag

isMathAware

public boolean isMathAware()
Queries math awareness property
Returns:
property flag

setDisplayErrors

public void setDisplayErrors(boolean b)
Sets display error property
Parameters:
b - property flag

isDisplayErrors

public boolean isDisplayErrors()
Queries display error property
Returns:
property flag

setPrompting

public void setPrompting(boolean b)
Sets prompting property
Parameters:
b - property flag

isPrompting

public boolean isPrompting()
Queries prompting property
Returns:
property flag

setPrompt

public void setPrompt(java.lang.String prompt)
Sets prompt
Parameters:
prompt - prompt string

getPrompt

public java.lang.String getPrompt()
Gets prompt
Returns:
prompt string

setSeparator

public void setSeparator(int width)
Sets the separator position for all named fields
Parameters:
width - separator position

getSeparator

public int getSeparator()
Gets separator position for the panel

setDisplayTitle

public void setDisplayTitle(boolean displayTitle)
Sets display title property
Parameters:
displayTitle - property flag

isDisplayTitle

public boolean isDisplayTitle()
Queries display title property
Returns:
property flag

setAlternating

public void setAlternating(boolean alternating)
Sets alternating colors property
Parameters:
alternating - property flag

isAlternating

public boolean isAlternating()
Queries alternating colors property
Returns:
property flag

setPrecision

public void setPrecision(int value)
Sets precision for computations (number of decimal digits - between 1 and 15)
Parameters:
value - precision value

getPrecision

public int getPrecision()
Gets precision (number of decimal digits)
Returns:
precision

setRounding

public void setRounding(int value)
Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding)
Parameters:
value - rounding value

getRounding

public int getRounding()
Gets rounding (number of displayed digits after the dot)
Returns:
rounding value

setRounding

public void setRounding(int i,
                        int value)
Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding) for the i-th field
Parameters:
i - i
value - rounding value

getRounding

public int getRounding(int i)
Gets rounding (number of displayed digits after the dot) of the i-th field
Parameters:
i - i
Returns:
rounding value

setRounding

public void setRounding(java.lang.String name,
                        int value)
Sets rounding (number of displayed decimal digits after the dot - between -1 and 15, -1 meaning no rounding) for a field with a given name
Parameters:
name - name
value - rounding value

getRounding

public int getRounding(java.lang.String name)
Gets rounding (number of displayed digits after the dot) of a field with a given name
Parameters:
name - name
Returns:
rounding value

setPrompt

public void setPrompt(java.lang.String name,
                      java.lang.String prompt)
Sets prompt for a field with a given name
Parameters:
name - name
prompt - prompt

getPrompt

public java.lang.String getPrompt(java.lang.String name)
Gets prompt of a field with a given name
Parameters:
name - name
Returns:
prompt

setActiveFieldsCount

public void setActiveFieldsCount(int count)
Sets active fields count (number of fields without the title)
Parameters:
count - value to set

getActiveFieldsCount

public int getActiveFieldsCount()
Gets active fields count (without the title)
Returns:
active fields count

setResizable

public void setResizable(boolean flag)
Sets resizable property (movable separator)
Parameters:
flag - property flag

isResizable

public boolean isResizable()
Queries resizable property
Returns:
property flag

setNames

public void setNames(java.lang.String[] names)
Sets names (field labels)
Parameters:
names - array of names to set (including title label)

getNames

public java.lang.String[] getNames()
Gets names (field labels)
Returns:
array of names (including the title label)

setNames

public void setNames(int i,
                     java.lang.String name)
Sets i-th name (field label)
Parameters:
i - i
name - name

getNames

public java.lang.String getNames(int i)
Gets i-th name (field label)
Parameters:
i - i
Returns:
name

setValues

public void setValues(java.lang.String[] values)
Sets values (including the title value)
Parameters:
values - value strings array

getValues

public java.lang.String[] getValues()
Gets values (including the title value)
Returns:
value strings array

setValues

public void setValues(int i,
                      java.lang.String value)
Sets i-th value
Parameters:
i - i
value - value string

getValues

public java.lang.String getValues(int i)
Get's i-th value
Returns:
value string

getValues

public java.lang.String[] getValues(boolean translate)
Gets values (including the title value) with translation
Parameters:
translate - translation flag
Returns:
value strings array

getValue

public java.lang.String getValue(int i,
                                 boolean translate)
Gets value of the i-th field with translation (each field might be assigned a translator to map the value to a number)
Parameters:
i - i
translate - translation flag

setValues

public void setValues(java.lang.String[] values,
                      boolean translate)
Sets values (including the title value) with translation
Parameters:
values - value strings array
translate - translation flag

setValue

public void setValue(int i,
                     java.lang.String value,
                     boolean translate)
Sets value of the i-th field with back translation
Parameters:
i - i
value - value
translate - translation flag

getValue

public java.lang.String getValue(java.lang.String name)
Gets value of a field with given name
Parameters:
name - name
Returns:
value

setValue

public void setValue(java.lang.String name,
                     java.lang.String value)
Sets value of a field with given name
Parameters:
name - name
value - value

getValue

public java.lang.String getValue(java.lang.String name,
                                 boolean translate)
Gets value of a field with given name with translation (each field might be assigned a translator to map the value to a number)
Parameters:
name - name
translate - translation flag

setValue

public void setValue(java.lang.String name,
                     java.lang.String value,
                     boolean translate)
Sets value of a field with given name with back translation
Parameters:
name - name
value - value
translate - translation flag

setError

public void setError(int i)
Sets error for the i-th field
Parameters:
i - i

setErrorMessage

public void setErrorMessage(int i,
                            java.lang.String message)
Sets error message for the i-th field
Parameters:
i - i
message - error string (null sets default value "Error")

setError

public void setError(java.lang.String name)
Sets error for a field with given name
Parameters:
name - name

setErrorMessage

public void setErrorMessage(java.lang.String name,
                            java.lang.String message)
Sets error message for a field with given name
Parameters:
name - name
message - error string (null sets default value "Error")

resetError

public void resetError(int i)
Clears error for the i-th field
Parameters:
i - i

resetError

public void resetError(java.lang.String name)
Clears error for a field with given name
Parameters:
name - name

getCount

public int getCount()
Gets total fields count
Returns:
fields count

getFieldsCount

public int getFieldsCount()
Gets total displayed fields count (including title)
Returns:
fields count

setFieldBackground

public void setFieldBackground(java.awt.Color[] cc)
Sets fields backgrounds
Parameters:
cc - array of colors

getFieldBackground

public java.awt.Color[] getFieldBackground()
Gets fields backgrounds
Returns:
array of colors

setFieldBackground

public void setFieldBackground(int i,
                               java.awt.Color c)
Sets i-th field's background
Parameters:
i - i
c - color

getFieldBackground

public java.awt.Color getFieldBackground(int i)
Gets i-th field's background
Parameters:
i - i
Returns:
field's color

setFieldForeground

public void setFieldForeground(java.awt.Color[] cc)
Sets fields foregrounds
Parameters:
cc - array of colors

getFieldForeground

public java.awt.Color[] getFieldForeground()
Gets fields foregrounds
Returns:
colors array

setFieldForeground

public void setFieldForeground(int i,
                               java.awt.Color c)
Sets i-th field's foreground
Parameters:
i - i
c - color

getFieldForeground

public java.awt.Color getFieldForeground(int i)
Gets i-th field's foreground
Parameters:
i - i
Returns:
field's color

setMulticolor

public void setMulticolor(boolean b)
Sets multicolor property (each field may have its own color)
Parameters:
b - property flag

isMulticolor

public boolean isMulticolor()
Queries multicolor property
Returns:
property flag

setTranslator

public void setTranslator(int i,
                          Translator translator)
Sets translator for the i-th field (to translate text into values)
Parameters:
i - i
translator - translator

getTranslator

public Translator getTranslator(int i)
Gets translator of the i-th field (that translates text into values)
Parameters:
i - i
Returns:
translator

setBackTranslator

public void setBackTranslator(int i,
                              Translator translator)
Sets back translator for the i-th field (to translate values into text)
Parameters:
i - i
translator - translator

getBackTranslator

public Translator getBackTranslator(int i)
Gets back translator of the i-th field (that translates values into text)
Parameters:
i - i
Returns:
translator

setTranslator

public void setTranslator(java.lang.String name,
                          Translator translator)
Sets translator for a field with given name (to translate text into values)
Parameters:
name - name
translator - translator

getTranslator

public Translator getTranslator(java.lang.String name)
Gets translator of a field with given name (that translates text into values)
Parameters:
name - name
Returns:
translator

setBackTranslator

public void setBackTranslator(java.lang.String name,
                              Translator translator)
Sets back translator for a field with given name (to translate values into text)
Parameters:
name - name
translator - translator

getBackTranslator

public Translator getBackTranslator(java.lang.String name)
Gets back translator of a field with given name (that translates values into text)
Parameters:
name - name
Returns:
translator