DESY ACOP Beans Home

com.cosylab.gui.components
Class LabelledNumberField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.cosylab.gui.components.AbstractDisplayerPanel
                      extended by com.cosylab.gui.components.AbstractNumericDisplayerPanel
                          extended by com.cosylab.gui.components.LabelledNumberField
All Implemented Interfaces:
StateOriginator, PopupManageable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
DoubleNumberDisplayer

public class LabelledNumberField
extends AbstractNumericDisplayerPanel
implements PopupManageable

LabelledNumberField is extended NumberField with title label and units label.

Version:
$id$
Author:
Igor Kriznar, Jernej Kamenik
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class com.cosylab.gui.components.AbstractDisplayerPanel
DYNAMIC_LAYOUT, HORIZONTAL_LAYOUT, VERTICAL_LAYOUT
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LabelledNumberField()
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.Number value)
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.Number value, java.lang.String format)
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.Number value, java.lang.String format, java.lang.String title, java.lang.String units)
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.Number value, java.lang.String format, java.lang.String title, java.lang.String units, boolean unitsWithTitle)
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.Number value, java.lang.String format, java.lang.String title, java.lang.String units, boolean resizable, boolean enchanced, boolean editable, boolean unitsWithTitle)
          Creates a new LabelledNumberField object.
LabelledNumberField(java.lang.String format)
          Creates a new LabelledNumberField object.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds action listener on NumberField.
 void addSetListener(SetListener l)
          Adds set listener to the NumberField.
 int getColumns()
          Returns number of columns on the NumberField.
 AbstractCustomizerPanel getCustomizer()
          Loads the default com.cosylab.gui.components.customizer.Customizer for this displayer and returns it.
 double getDoubleValue()
          Returns the value of type double
 long getLongValue()
          Returns the value of type long
 java.lang.Number getMaximumValue()
          Returns the maximum value allowed by this NumberField.
 java.lang.Number getMinimumValue()
          Returns the minimum value allowed by this NumberField.
protected  NumberField getNumber()
          The NumberField component, that does number editing and rendering.
 NumberDescriptor getNumberDescriptor()
          Returns descriptor object, to which visualization of number as strring is dlegated.
 java.lang.Class<? extends java.lang.Number> getNumberType()
          Returns the type of displayed number.
 java.lang.Number getNumberValue()
          Returns generic representation of the value using the Number class.
 java.awt.Color getOutOfBoundsColor()
          Returns th color which indicates the out of bounds state.
 int getSettingPolicy()
          Returns the currently used seting policy by this Numberfield
 State getState()
          Returns the current state of the component.
protected  javax.swing.JComponent getValueComponent()
          Should return the component to display the value of this displayer.
protected  void internalSetEnabled()
          Overriden to enable/disable min/max labels.
protected  void internalSetEnhanced()
          Overriden to set enahnced mode to min/max labels.
protected  void internalSetFormat()
           
protected  void internalSetResizable()
          Overriden to implement additional functionality.
 boolean isEditable()
          Returns true if user is allowed to set value.
 boolean isTiltingEnabled()
          Returns true if tilting is enabled.
 boolean isWarnOutOfBounds()
          Returns true if the displayer shows a warning when out of bounds.
static void main(java.lang.String[] args)
          Run test applet.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes action listener from NumberField.
 void removeSetListener(SetListener l)
          Removes set listener from the NumberField.
 void setBackground(java.awt.Color bg)
           
 void setColumns(int columns)
          Sets number of columns on the NumberField.
 void setDoubleValue(double newValue)
          Sets the value of type double to be displayed.
 void setEditable(boolean editable)
          Enables/disables user editing of number.
 void setLongValue(long newValue)
          Sets the value of type long to be displayed.
 void setMaximumValue(java.lang.Number newMaximum)
          Sets the maximum allowed value that can be entered in this NumberField.
 void setMinimumValue(java.lang.Number newMinimum)
          Sets the minimum allowed value that can be entered in this NumberField.
 void setNumberDescriptor(NumberDescriptor numberDescriptor)
          When this is set with non-null value, this NumberField uses this descriptor to convert Number to string and back.
 void setNumberType(java.lang.Class<? extends java.lang.Number> newNumberFormat)
          Sets the number format.
 void setNumberValue(java.lang.Number newValue)
          Sets the numeric value for this component.
 void setOutOfBoundsColor(java.awt.Color c)
          Sets the color which indicates the out of bounds state.
 void setSettingPolicy(int newPolicy)
          Sets the setting policy of thi Numberdisplayer.
 void setState(State state)
          Sets the state to the component.
 void setTiltingEnabled(boolean b)
          Enables/disables tilting when value is out of bounds.
 void setWarnOutOfBounds(java.lang.Boolean b)
          If warnOutOfBounds is set to true, user will be notified when a value is set ot of the preset bounds.
 
Methods inherited from class com.cosylab.gui.components.AbstractNumericDisplayerPanel
getFormat, getLayoutOrientation, getMaxComponent, getMinComponent, getUnits, getUnitsComponent, internalSetMaximum, internalSetMinimum, internalSetTitle, internalSetUnits, isBoundsVisible, isUnitsShownWithTitle, isUnitsVisible, layoutDisplayer, layoutValueAndBounds, layoutValueAndTitleAndBounds, layoutValueAndTitleAndUnits, layoutValueAndTitleAndUnitsAndBounds, layoutValueAndUnits, layoutValueAndUnitsAndBounds, setBoundsVisible, setForeground, setFormat, setLayoutOrientation, setTitleMaximumFontSize, setTitleMinimumFontSize, setTransferHandler, setUnits, setUnitsShownWithTitle, setUnitsVisible
 
Methods inherited from class com.cosylab.gui.components.AbstractDisplayerPanel
getPopupManager, getTitle, getTitleComponent, getTitleMaximumFontSize, getTitleMinimumFontSize, isDragEnabled, isDropEnabled, isEnhanced, isPopupEnabled, isResizable, isTitleVisible, layoutValue, layoutValueAndTitle, setDragEnabled, setDropEnabled, setEnabled, setEnhanced, setPopupEnabled, setResizable, setTitle, setTitleVisible
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.cosylab.gui.components.util.PopupManageable
getPopupManager
 

Constructor Detail

LabelledNumberField

public LabelledNumberField()
Creates a new LabelledNumberField object.


LabelledNumberField

public LabelledNumberField(java.lang.String format)
Creates a new LabelledNumberField object.

Parameters:
format - initial format

LabelledNumberField

public LabelledNumberField(java.lang.Number value)
Creates a new LabelledNumberField object.

Parameters:
value - initial value

LabelledNumberField

public LabelledNumberField(java.lang.Number value,
                           java.lang.String format)
Creates a new LabelledNumberField object.

Parameters:
value - initial value
format - initial format

LabelledNumberField

public LabelledNumberField(java.lang.Number value,
                           java.lang.String format,
                           java.lang.String title,
                           java.lang.String units)
Creates a new LabelledNumberField object.

Parameters:
value - initial value
format - initial format
title - initial title
units - initial units

LabelledNumberField

public LabelledNumberField(java.lang.Number value,
                           java.lang.String format,
                           java.lang.String title,
                           java.lang.String units,
                           boolean unitsWithTitle)
Creates a new LabelledNumberField object.

Parameters:
value - initial value
format - initial format
title - initial title
units - initial units
unitsWithTitle - if true units shown in title label and not in separate label

LabelledNumberField

public LabelledNumberField(java.lang.Number value,
                           java.lang.String format,
                           java.lang.String title,
                           java.lang.String units,
                           boolean resizable,
                           boolean enchanced,
                           boolean editable,
                           boolean unitsWithTitle)
Creates a new LabelledNumberField object.

Parameters:
value - initial value
format - initial format
title - initial title
units - initial units
resizable - inital resizable
enchanced - inital enchanced
editable - initial editable
unitsWithTitle - if true units shown in title label and not in separate label
Method Detail

getCustomizer

public AbstractCustomizerPanel getCustomizer()
Description copied from class: AbstractDisplayerPanel
Loads the default com.cosylab.gui.components.customizer.Customizer for this displayer and returns it.

Overrides:
getCustomizer in class AbstractDisplayerPanel
Returns:
the Customizer intance for this displayer

setColumns

public void setColumns(int columns)
Sets number of columns on the NumberField.

See Also:
JTextField.setColumns(int)

getColumns

public int getColumns()
Returns number of columns on the NumberField.

See Also:
JTextField.getColumns()

setDoubleValue

public void setDoubleValue(double newValue)
Sets the value of type double to be displayed.

Parameters:
newValue -

getDoubleValue

public double getDoubleValue()
Returns the value of type double

Returns:
double

setEditable

public void setEditable(boolean editable)
Enables/disables user editing of number.

Parameters:
editable - if true user is allowed to set value.

isEditable

public boolean isEditable()
Returns true if user is allowed to set value.

Returns:
boolean true if user is allowed to input number

setLongValue

public void setLongValue(long newValue)
Sets the value of type long to be displayed.

Parameters:
newValue -

getLongValue

public long getLongValue()
Returns the value of type long

Returns:
long

setMaximumValue

public void setMaximumValue(java.lang.Number newMaximum)
Sets the maximum allowed value that can be entered in this NumberField. Setting maximum to null means no maximum is set. This method does not check for validity of the limit. If maximum is set less than minimum then no value can be set.

Overrides:
setMaximumValue in class AbstractNumericDisplayerPanel
Parameters:
newMaximum - Number

getMaximumValue

public java.lang.Number getMaximumValue()
Returns the maximum value allowed by this NumberField. Can be null if no maximum is set.

Overrides:
getMaximumValue in class AbstractNumericDisplayerPanel
Returns:
Number maximum allowed value.

setMinimumValue

public void setMinimumValue(java.lang.Number newMinimum)
Sets the minimum allowed value that can be entered in this NumberField. Setting minimum to null means no minimum is set. This method does not check for validity of the limit. If minimum is set more than maximum then no value can be set.

Overrides:
setMinimumValue in class AbstractNumericDisplayerPanel
Parameters:
newMinimum - Number

getMinimumValue

public java.lang.Number getMinimumValue()
Returns the minimum value allowed by this NumberField. Can be null if no miminum is set.

Overrides:
getMinimumValue in class AbstractNumericDisplayerPanel
Returns:
Number minimum allowed value

setNumberType

public void setNumberType(java.lang.Class<? extends java.lang.Number> newNumberFormat)
Sets the number format.

Overrides:
setNumberType in class AbstractNumericDisplayerPanel
Parameters:
newNumberFormat -

getNumberType

public java.lang.Class<? extends java.lang.Number> getNumberType()
Returns the type of displayed number.

Overrides:
getNumberType in class AbstractNumericDisplayerPanel
Returns:
type of displayed number

setNumberValue

public void setNumberValue(java.lang.Number newValue)
Sets the numeric value for this component. New value is subject to min/max test if any of them is set. If new value does not fall within these bounds, setting value will do nothing.

Parameters:
newValue - Number

getNumberValue

public java.lang.Number getNumberValue()
Returns generic representation of the value using the Number class.

Returns:
java.lang.Number

setState

public void setState(State state)
Description copied from class: AbstractDisplayerPanel
Sets the state to the component.

Specified by:
setState in interface StateOriginator
Overrides:
setState in class AbstractNumericDisplayerPanel
Parameters:
state - to set.
See Also:
StateOriginator.setState(com.cosylab.application.state.State)

setTiltingEnabled

public void setTiltingEnabled(boolean b)
Enables/disables tilting when value is out of bounds.

Parameters:
b - true if tilting should be enabled
See Also:
NumberField.setTiltingEnabled(boolean)

getState

public State getState()
Description copied from class: AbstractDisplayerPanel
Returns the current state of the component.

Specified by:
getState in interface StateOriginator
Overrides:
getState in class AbstractNumericDisplayerPanel
Returns:
current state.
See Also:
StateOriginator.getState()

isTiltingEnabled

public boolean isTiltingEnabled()
Returns true if tilting is enabled.

Returns:
true if tilting enabled
See Also:
setTiltingEnabled(boolean), NumberField.isTiltingEnabled()

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds action listener on NumberField.

Parameters:
l -

addSetListener

public void addSetListener(SetListener l)
Adds set listener to the NumberField.

See Also:
NumberField.addSetListener(SetListener)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes action listener from NumberField.

Parameters:
l -

removeSetListener

public void removeSetListener(SetListener l)
Removes set listener from the NumberField.

See Also:
NumberField.removeSetListener(SetListener)

getNumber

protected NumberField getNumber()
The NumberField component, that does number editing and rendering.

Returns:
the NumberField component

getValueComponent

protected javax.swing.JComponent getValueComponent()
Description copied from class: AbstractDisplayerPanel
Should return the component to display the value of this displayer. This method is called inside the constructor to add the valueComponent to the AbstractDisplayerPanel. Subclasses should thus use lazy initialization inside this method.

Specified by:
getValueComponent in class AbstractDisplayerPanel
Returns:
the value component of the AbstractDisplayerPanel.

internalSetEnabled

protected void internalSetEnabled()
Description copied from class: AbstractNumericDisplayerPanel
Overriden to enable/disable min/max labels.

Overrides:
internalSetEnabled in class AbstractNumericDisplayerPanel

internalSetEnhanced

protected void internalSetEnhanced()
Description copied from class: AbstractNumericDisplayerPanel
Overriden to set enahnced mode to min/max labels.

Overrides:
internalSetEnhanced in class AbstractNumericDisplayerPanel

internalSetFormat

protected void internalSetFormat()
Overrides:
internalSetFormat in class AbstractNumericDisplayerPanel

internalSetResizable

protected void internalSetResizable()
Description copied from class: AbstractNumericDisplayerPanel
Overriden to implement additional functionality.

Overrides:
internalSetResizable in class AbstractNumericDisplayerPanel
See Also:
AbstractDisplayerPanel.setResizable(boolean)

getNumberDescriptor

public NumberDescriptor getNumberDescriptor()
Returns descriptor object, to which visualization of number as strring is dlegated.

Returns:
number visualization

setNumberDescriptor

public void setNumberDescriptor(NumberDescriptor numberDescriptor)
When this is set with non-null value, this NumberField uses this descriptor to convert Number to string and back. By this user can define his own visualization of Number.

Parameters:
numberDescriptor - new Number visualization, can be null

setSettingPolicy

public void setSettingPolicy(int newPolicy)
Sets the setting policy of thi Numberdisplayer. SET_AS_TYPED updates the Numberfield value when typed. SET_ON_APPLY updates the Numberfield only on actionPerformed events (when the user presses ENTER) SET_ON_EXIT updates the numberfield when it loses focus

Parameters:
newPolicy - new policy
Throws:
java.lang.IllegalArgumentException
See Also:
NumberField.setSettingPolicy(int)

getSettingPolicy

public int getSettingPolicy()
Returns the currently used seting policy by this Numberfield

Returns:
int currently used setting policy.
See Also:
NumberField.getSettingPolicy()

setWarnOutOfBounds

public void setWarnOutOfBounds(java.lang.Boolean b)
If warnOutOfBounds is set to true, user will be notified when a value is set ot of the preset bounds.

Parameters:
b - true if warnings are turned on

isWarnOutOfBounds

public boolean isWarnOutOfBounds()
Returns true if the displayer shows a warning when out of bounds.

Returns:
true if warning is shown

setOutOfBoundsColor

public void setOutOfBoundsColor(java.awt.Color c)
Sets the color which indicates the out of bounds state.

Parameters:
c - new out of bounds state color

getOutOfBoundsColor

public java.awt.Color getOutOfBoundsColor()
Returns th color which indicates the out of bounds state.

Returns:

setBackground

public void setBackground(java.awt.Color bg)
Overrides:
setBackground in class AbstractNumericDisplayerPanel

main

public static void main(java.lang.String[] args)
Run test applet.

Parameters:
args - command line parameters


Copyright © 2010. All Rights Reserved.