UI
Class GEVANumberProperty

java.lang.Object
  extended by UI.GEVAControl
      extended by UI.GEVAPropertyControl
          extended by UI.GEVANumberProperty
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, javax.swing.event.DocumentListener

public class GEVANumberProperty
extends GEVAPropertyControl
implements javax.swing.event.ChangeListener, javax.swing.event.DocumentListener

A name value control that handles numeric inputs. Type can be PT_INT or PT_FLOAT and validates that the value input can be converted to an int or double respectively. Also supports params of "increment,minimum,maximum", where fields can be left blank if not needed e.g. (",,10"). Default for unspecified fields are, increment: 1 for int, 0.1 for float, minimum: -max value for type, maximum: +max value for type.

Author:
eliottbartley

Field Summary
static java.lang.String PT_FLOAT
          Constructor type.
static java.lang.String PT_INT
          Constructor type.
 
Fields inherited from class UI.GEVAPropertyControl
initial, params
 
Fields inherited from class UI.GEVAControl
comment, dirtyListener, name, parent, title, type
 
Constructor Summary
GEVANumberProperty(GEVADirtyListener dirtyListener, GEVAPropertyContainer parent, java.lang.String type, java.lang.String title, java.lang.String name, java.lang.String comment, java.lang.String initial, java.lang.String params)
          Create a numeric input with spinner controls for mouse entry
 
Method Summary
 void changedUpdate(javax.swing.event.DocumentEvent event)
           
 java.awt.Component getComponent(int index)
          Abstract way for a container to know about its child's awt components.
 java.lang.String getText()
          Get the value of teh control, using a text string
 void insertUpdate(javax.swing.event.DocumentEvent event)
           
 boolean load(java.util.Properties properties)
          A control should override this to get its properties.
 void removeUpdate(javax.swing.event.DocumentEvent event)
           
 boolean save(java.util.Properties properties)
          A control should override this to set its properties.
 void setEnabled(boolean enabled)
          Make this control enabled or disabled.
 void setText(java.lang.String text)
          Set the value of the control, using a text string
 void stateChanged(javax.swing.event.ChangeEvent event)
           
 boolean valid()
           
 void validate()
          Get this control to validate itself
 
Methods inherited from class UI.GEVAPropertyControl
addInvalidReason, countComponents, getParam, getParam, getParamBoolean, getParamBoolean, getParamDouble, getParamDouble, getParamEqual, getParamInt, getParamInt, resetInvalidReason, setVisible, setVisibleControlGroup
 
Methods inherited from class UI.GEVAControl
addActionListener, fireActionEvent, getComment, getComponent, getName, getParent, getTitle, getType, isType, removeActionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PT_INT

public static java.lang.String PT_INT
Constructor type. Number must validate to type int


PT_FLOAT

public static java.lang.String PT_FLOAT
Constructor type. Number must validate to type float

Constructor Detail

GEVANumberProperty

public GEVANumberProperty(GEVADirtyListener dirtyListener,
                          GEVAPropertyContainer parent,
                          java.lang.String type,
                          java.lang.String title,
                          java.lang.String name,
                          java.lang.String comment,
                          java.lang.String initial,
                          java.lang.String params)
Create a numeric input with spinner controls for mouse entry

Parameters:
dirtyListener - GUI that listens to dirty events
parent - Container for this control
type - Can be PT_INT or PT_FLOAT. Used when validating the control, it is parsed to the specified type
title - The title to show in the GUI of this control
name - The name used when saving this to the properties file
comment - A tooltip
initial - The initial value
params - Range and step amounts in the format "step,minimum,maximum". If minimum/maximum are not specified, the min/max of the type are used. If step is not speicified +1 is used for int and +0.1 is used for float. When the control's spinners are used, the number increments by 'step' amount and will not be allowed to go outside the range [minimum..maximum] inclusive. If the user types a value that is outside the minimum/maximum range, an error message is displayed
Method Detail

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: GEVAControl
Make this control enabled or disabled.

Specified by:
setEnabled in class GEVAControl
Parameters:
enabled - true to enabled, false to disable

load

public boolean load(java.util.Properties properties)
Description copied from class: GEVAControl
A control should override this to get its properties.

Specified by:
load in class GEVAControl
Parameters:
properties - The properties of a loaded properties file

save

public boolean save(java.util.Properties properties)
Description copied from class: GEVAControl
A control should override this to set its properties. After all controls have had a chance to set the properties, the properties file will be written to by the caller

Specified by:
save in class GEVAControl
Parameters:
properties - The properties of a loaded properties file

getComponent

public java.awt.Component getComponent(int index)
Description copied from class: GEVAControl
Abstract way for a container to know about its child's awt components.

Overrides:
getComponent in class GEVAPropertyControl
Parameters:
index - The index of the component to get
Returns:
The indexed awt component of the control

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent event)
Specified by:
insertUpdate in interface javax.swing.event.DocumentListener

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent event)
Specified by:
removeUpdate in interface javax.swing.event.DocumentListener

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent event)
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener

valid

public boolean valid()

validate

public void validate()
Description copied from class: GEVAControl
Get this control to validate itself

Specified by:
validate in class GEVAControl

getText

public java.lang.String getText()
Description copied from class: GEVAControl
Get the value of teh control, using a text string

Specified by:
getText in class GEVAControl
Returns:
The value of the control in string format

setText

public void setText(java.lang.String text)
Description copied from class: GEVAControl
Set the value of the control, using a text string

Specified by:
setText in class GEVAControl
Parameters:
text - The value to set