uk.co.prosperosoftware.pspnum
Class PSPNumS

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JTextField
                                |
                                +--uk.co.prosperosoftware.pspnum.PSPNumS
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.datatransfer.ClipboardOwner, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.SwingConstants

public class PSPNumS
extends javax.swing.JTextField
implements java.io.Serializable, java.awt.datatransfer.ClipboardOwner, java.awt.event.FocusListener

PSPNumS is a 'Swing' version of the PSPNum class. It extends javax.swing.JTextField whereas PSPNum extends java.awt.TextField. Apart from this, code and behaviour of PSPNum and PSPNumS is identical. Please see PSPNum documentation for description of functionality common to both classes.

Version:
4.4 05Jun2003
Author:
www.prosperosoftware.co.uk
See Also:
Serialized Form

Field Summary
static int CARET_POSITION_DECIMAL
          The caret is positioned to the digit nearest the decimal place.
static int CARET_POSITION_DEFAULT
          The caret is positioned by default (per the parent TextField object which PSPNum extends).
static int CARET_POSITION_FIRSTDIGIT
          The caret is positioned to the first digit in the displayed Text.
static int MAX_DIGITS_AFTER
          Maximum number (50) of digits after decimal place for PSPNum.
static int MAX_DIGITS_BEFORE
          Maximum number (50) of digits before decimal place for PSPNum.
static int OVERFLOW_BUMP_BEFOREDP
          When overflow occurs, PSPNum automatically increments DigitsBeforeDP to accommodate the new value.
static int OVERFLOW_EXCEPTION
          When overflow occurs, PSPNum throws an PSPException error for which the getErrNum() function returns PSPException.NumOverflow.
static int OVERFLOW_IGNORE
          When overflow occurs, PSPNum silently ignores the new value.
static int OVERFLOW_IGNORE_BEEP
          When overflow occurs, PSPNum ignores the new value and beeps.
static int OVERFLOW_TRUNCATE
          When overflow occurs, PSPNum silently truncates excess high-order digits.
static int OVERFLOW_TRUNCATE_BEEP
          When overflow occurs, PSPNum truncates excess high-order digits and beeps.
static int TEXT_ALIGN_CENTER
          Text displayed in Text box is centrally aligned (positioned in middle of Text box).
static int TEXT_ALIGN_LEFT
          Text displayed in Text box is left aligned (this is the default for each new PSPNum).
static int TEXT_ALIGN_RIGHT
          Text displayed in Text box is right aligned.
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PSPNumS()
          Default constructor - no parameters.
PSPNumS(int cols)
          Simplest constructor - size of edit box only.
PSPNumS(int cols, int DigitsBeforeDP, int DigitsAfterDP)
          Constructor with size of edit box and size of number.
PSPNumS(int cols, int DigitsBeforeDP, int DigitsAfterDP, java.lang.String Value)
          Constructor with sizes of edit box, number; also initial numeric value.
 
Method Summary
 void add(PSPNumS addNum)
          Add decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void add(java.lang.String addValue)
          Add parameter decimal value to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void divide(PSPNumS divNum)
          Divide decimal value of parameter PSPNum into this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void divide(java.lang.String divValue)
          Divide parameter decimal value into this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void dump()
          Utility function to dump PSPNum persistent property values to 'stdout' via 'System.out.println' call.
 void focusGained(java.awt.event.FocusEvent evt)
          Method invoked when PSPNum gains input focus.
 void focusLost(java.awt.event.FocusEvent evt)
          Method invoked when PSPNum loses input focus.
 java.awt.Color getActiveBackColor()
          Returns active background color.
 int getCaretPosition()
          Gets the position of the text insertion caret for this PSPNum.
 int getDigitsAfterDP()
          Returns number of digits after decimal place.
 int getDigitsBeforeDP()
          Returns number of digits before decimal place.
 java.lang.String getMask()
          Returns all components of edit mask.
 java.lang.String getMaskUsed()
          Returns used components of edit mask.
 int getOverflowCode()
          Returns current OverflowCode flag setting for overflow following program operations.
 int getOverflowKey()
          Returns current OverflowKey flag setting for overflow following user keying.
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of this PSPNum.
 boolean getRound()
          Returns setting (true/false) for arithmetic rounding.
 java.lang.String getText()
          Returns the Text for this PSPNum (trimmed to remove leading/trailing whitespace).
 int getTextAlign()
          Returns current TextAlign flag setting.
 boolean getTextRefresh()
          Get current state of TextRefresh boolean variable.
 java.lang.String getValue()
          Returns unformatted decimal numeric value.
 boolean isEQ(PSPNumS compareNum)
          Checks if this PSPNum is EQ another PSPNum.
 boolean isEQ(java.lang.String compareValue)
          Checks if this PSPNum is EQ a particular numeric value.
 boolean isGE(PSPNumS compareNum)
          Checks if this PSPNum is GE another PSPNum.
 boolean isGE(java.lang.String compareValue)
          Checks if this PSPNum is GE a particular numeric value.
 boolean isGT(PSPNumS compareNum)
          Checks if this PSPNum is GT another PSPNum.
 boolean isGT(java.lang.String compareValue)
          Checks if this PSPNum is GT a particular numeric value.
 boolean isLE(PSPNumS compareNum)
          Checks if this PSPNum is LE another PSPNum.
 boolean isLE(java.lang.String compareValue)
          Checks if this PSPNum is LE a particular numeric value.
 boolean isLT(PSPNumS compareNum)
          Checks if this PSPNum is LT another PSPNum.
 boolean isLT(java.lang.String compareValue)
          Checks if this PSPNum is LT a particular numeric value.
 boolean isNE(PSPNumS compareNum)
          Checks if this PSPNum is NE another PSPNum.
 boolean isNE(java.lang.String compareValue)
          Checks if this PSPNum is NE a particular numeric value.
 boolean isNegative()
          Check if the number is negative.
 boolean isPositive()
          Check if the number is positive.
 boolean isZero()
          Check if the number is zero.
 void lostOwnership(java.awt.datatransfer.Clipboard cb, java.awt.datatransfer.Transferable data)
          method required to be present only for system Clipboard Interface support - does nothing for PSPNum.
 void multiply(PSPNumS multNum)
          Multiply this PSPNum by decimal value of parameter PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively
 void multiply(java.lang.String multValue)
          Multiply this PSPNum by parameter decimal value with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
protected  void processKeyEvent(java.awt.event.KeyEvent evt)
          Keystroke processing - filters out keys inapplicable to decimal numbers.
 void setActiveBackColor(java.awt.Color newBackColor)
          Set background color for PSPNum when it has the input focus (is the active control).
 void setCaretRelativePosition(int newRelativePosition)
          Set caret position for this PSPNum (not for entire class) to relative position given by either CARET_POSITION_FIRSTDIGIT or CARET_POSITION_DECIMAL.
 void setDigitsAfterDP(int newDigitsAfterDP)
          Resets number of digits after decimal place (revise number of digits set initially when PSPNum constructed).
 void setDigitsBeforeDP(int newDigitsBeforeDP)
          Reset number of digits before decimal place (revise number of digits set initially when PSPNum constructed).
 void setFocusCaretRelativePosition(int newRelativePosition)
          Set desired relative positioning of caret for this PSPNum (not for entire class) when it gains the input focus.
 void setMask(java.lang.String newMask)
          Resets edit mask controlling display of formatted value in text box and the keystrokes recognised for input.
 void setOverflowCode(int newCode)
          Set flag for this PSPNum (not for entire class) to control response to numeric overflow when new value set by program operations.
 void setOverflowDefault(byte overflowDefault)
          Set flag for PSPNum class (default applied to new PSPNum's) to control response to numeric overflow when new value set by program operations or user keying.
 void setOverflowKey(int newKey)
          Set flag for this PSPNum (not for entire class) to control response to numeric overflow when user keys new value.
 void setRound(boolean newRound)
          Set default true/false value for arithmetic rounding of new numeric values assigned in code (does not apply to keystrokes).
 void setText(java.lang.String newText)
          Dummy function to reset Text for PSPNum; deliberately does nothing - PSPNum value must be reset using setValue().
 void setTextAlign(int newAlign)
          Set alignment for Text displayed in Text box for this PSPNum (not for entire class).
 void setTextRefresh(boolean refresh)
          Controls whether Text is refreshed whenever the underlying Value - per getValue() function - changes.
 void setValue(PSPNumS assnNum)
          Assigns decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively
 void setValue(PSPNumS assnNum, int Overflow, boolean Round)
          Assigns decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by last two parameters (temporary override values set by preceding setOverflowCode() and setRound() methods).
 void setValue(java.lang.String assnValue)
          Assign parameter decimal value to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void setValue(java.lang.String assnValue, int Overflow, boolean Round)
          Assign parameter decimal value to this PSPNum with treatment of overflow and rounding determined by last two parameters.
 int signum()
          Returns the signum function of this number
 void subtract(PSPNumS subNum)
          Subtract decimal value of parameter PSPNum from this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 void subtract(java.lang.String subValue)
          Subtract parameter decimal value from this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.
 java.lang.String toString()
          Returns a String object representing this PSPNum's value - which is the decimal value also returned by the getValue() method.
 
Methods inherited from class javax.swing.JTextField
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_DIGITS_BEFORE

public static final int MAX_DIGITS_BEFORE
Maximum number (50) of digits before decimal place for PSPNum.

See Also:
Constant Field Values

MAX_DIGITS_AFTER

public static final int MAX_DIGITS_AFTER
Maximum number (50) of digits after decimal place for PSPNum.

See Also:
Constant Field Values

OVERFLOW_BUMP_BEFOREDP

public static final int OVERFLOW_BUMP_BEFOREDP
When overflow occurs, PSPNum automatically increments DigitsBeforeDP to accommodate the new value. This is the default for all new PSPNum's unless you execute the setOverflowDefault() function.

See Also:
Constant Field Values

OVERFLOW_EXCEPTION

public static final int OVERFLOW_EXCEPTION
When overflow occurs, PSPNum throws an PSPException error for which the getErrNum() function returns PSPException.NumOverflow. This error is also thrown if MAX_DIGITS_BEFORE limit is reached when OVERFLOW_BUMP_BEFOREDP is set.

See Also:
Constant Field Values

OVERFLOW_IGNORE

public static final int OVERFLOW_IGNORE
When overflow occurs, PSPNum silently ignores the new value.

See Also:
Constant Field Values

OVERFLOW_IGNORE_BEEP

public static final int OVERFLOW_IGNORE_BEEP
When overflow occurs, PSPNum ignores the new value and beeps.

See Also:
Constant Field Values

OVERFLOW_TRUNCATE

public static final int OVERFLOW_TRUNCATE
When overflow occurs, PSPNum silently truncates excess high-order digits.

See Also:
Constant Field Values

OVERFLOW_TRUNCATE_BEEP

public static final int OVERFLOW_TRUNCATE_BEEP
When overflow occurs, PSPNum truncates excess high-order digits and beeps.

See Also:
Constant Field Values

TEXT_ALIGN_RIGHT

public static final int TEXT_ALIGN_RIGHT
Text displayed in Text box is right aligned. Note that right alignment is only correct if a monospace font is used. The default font is Monospaced plain.

See Also:
Constant Field Values

TEXT_ALIGN_CENTER

public static final int TEXT_ALIGN_CENTER
Text displayed in Text box is centrally aligned (positioned in middle of Text box). Note that center alignment is only correct if a monospace font is used. The default font is Monospaced plain.

See Also:
Constant Field Values

TEXT_ALIGN_LEFT

public static final int TEXT_ALIGN_LEFT
Text displayed in Text box is left aligned (this is the default for each new PSPNum).

See Also:
Constant Field Values

CARET_POSITION_DEFAULT

public static final int CARET_POSITION_DEFAULT
The caret is positioned by default (per the parent TextField object which PSPNum extends). When the PSPNum first gets the input focus, the caret is positioned before the first character (digit or other) in the displayed Text. Thereafter when the PSPNum gets the input focus, the caret is positioned to the position the caret was at when the PSPNum previously lost the input focus.

See Also:
Constant Field Values

CARET_POSITION_FIRSTDIGIT

public static final int CARET_POSITION_FIRSTDIGIT
The caret is positioned to the first digit in the displayed Text.

See Also:
Constant Field Values

CARET_POSITION_DECIMAL

public static final int CARET_POSITION_DECIMAL
The caret is positioned to the digit nearest the decimal place. If the PSPNum has decimal places (DigitsAfterDP is positive), the caret is positioned to just before the decimal place in the displayed Text. Otherwise the caret is positioned to the first digit in the displayed Text.

See Also:
Constant Field Values
Constructor Detail

PSPNumS

public PSPNumS()
Default constructor - no parameters. Size (number of columns) of edit box defaults to 40. Digits before decimal place defaults to 9. Digits after decimal place defaults to 2. This constructor is typically required for tools that must construct PSPNumS's before allowing you to edit their properties. If you can use another constructor (with parameters) directly, we recommend you do so.


PSPNumS

public PSPNumS(int cols)
Simplest constructor - size of edit box only. Digits before decimal place defaults to 9. Digits after decimal place defaults to 2.

Parameters:
cols - The size (number of columns) of the edit box.

PSPNumS

public PSPNumS(int cols,
               int DigitsBeforeDP,
               int DigitsAfterDP)
Constructor with size of edit box and size of number.

Parameters:
cols - The size (number of columns) of the edit box.
DigitsBeforeDP - Number of digits before decimal place.
DigitsAfterDP - Number of digits after decimal place.

PSPNumS

public PSPNumS(int cols,
               int DigitsBeforeDP,
               int DigitsAfterDP,
               java.lang.String Value)
Constructor with sizes of edit box, number; also initial numeric value. Note that the constructor throws no error if the initial numeric value is invalid - it is quietly ignored and the PSPNum simply gets an initial value of zero.

Parameters:
cols - The size (number of columns) of the edit box.
DigitsBeforeDP - Number of digits before decimal place.
DigitsAfterDP - Number of digits after decimal place.
Value - Initial decimal numeric value for PSPNum.
Method Detail

getDigitsBeforeDP

public final int getDigitsBeforeDP()
Returns number of digits before decimal place.

Returns:
Number of digits before decimal place.

setDigitsBeforeDP

public final void setDigitsBeforeDP(int newDigitsBeforeDP)
Reset number of digits before decimal place (revise number of digits set initially when PSPNum constructed).

Parameters:
newDigitsBeforeDP - New digits before decimal place.

getDigitsAfterDP

public final int getDigitsAfterDP()
Returns number of digits after decimal place.

Returns:
Number of digits after decimal place.

setDigitsAfterDP

public final void setDigitsAfterDP(int newDigitsAfterDP)
Resets number of digits after decimal place (revise number of digits set initially when PSPNum constructed).

Parameters:
newDigitsAfterDP - New digits after decimal place.

getTextAlign

public final int getTextAlign()
Returns current TextAlign flag setting.

Returns:
Value for TextAlign flag (integer value corresponding to TEXT_ALIGN_xxx value set by preceding setTextAlign() operation).

setTextAlign

public final void setTextAlign(int newAlign)
                        throws java.lang.IllegalArgumentException
Set alignment for Text displayed in Text box for this PSPNum (not for entire class). New setting must be one of TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER or TEXT_ALIGN_RIGHT.

Parameters:
newAlign - Flag controlling Text alignment.
Throws:
java.lang.IllegalArgumentException - if parameter newAlign is not one of valid TEXT_ALIGN_xxx values.

setText

public final void setText(java.lang.String newText)
Dummy function to reset Text for PSPNum; deliberately does nothing - PSPNum value must be reset using setValue().

Overrides:
setText in class javax.swing.text.JTextComponent
Parameters:
newText - New text (ignored).

getText

public final java.lang.String getText()
Returns the Text for this PSPNum (trimmed to remove leading/trailing whitespace).

Overrides:
getText in class javax.swing.text.JTextComponent
Returns:
trimmed Text for this PSPNum.

setTextRefresh

public final void setTextRefresh(boolean refresh)
Controls whether Text is refreshed whenever the underlying Value - per getValue() function - changes. You may, for example, want to set TextRefresh to false while you perform intermediate calculations on the numeric value, then reset TextRefresh to true again to show the final result. Setting TextRefresh to true always results in an immediate refresh.

Parameters:
refresh - true/false if Text to be refreshed when underlying decimal numeric value changes.

getTextRefresh

public final boolean getTextRefresh()
Get current state of TextRefresh boolean variable.

Returns:
Current state of TextRefresh variable.

getMaskUsed

public final java.lang.String getMaskUsed()
Returns used components of edit mask.

Returns:
Edit mask - used components only.

getMask

public final java.lang.String getMask()
Returns all components of edit mask.

Returns:
Edit mask - all components (both used and unused).

setMask

public final void setMask(java.lang.String newMask)
Resets edit mask controlling display of formatted value in text box and the keystrokes recognised for input. Mask component values remain in effect until reset, so only changed component values need to be set each time.

Parameters:
newMask - New mask values (changed components)

getActiveBackColor

public final java.awt.Color getActiveBackColor()
Returns active background color.

Returns:
Color in effect when PSPNum has input focus.

setActiveBackColor

public final void setActiveBackColor(java.awt.Color newBackColor)
Set background color for PSPNum when it has the input focus (is the active control).

Parameters:
newBackColor - New active background color.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of this PSPNum. Returns exactly the same value as the underlying TextField.getPreferredSize() method, but is overridden here so PSPNum can verify/establish fonts.

Overrides:
getPreferredSize in class javax.swing.JTextField
Returns:
the preferred dimensions for displaying this PSPNum.

focusGained

public void focusGained(java.awt.event.FocusEvent evt)
Method invoked when PSPNum gains input focus. This method processes the event completely for the PSPNum - it does not pass the event up to parent objects. The method is not declared final, which means you can override it in any class which extends PSPNum. If you do this, you must invoke 'super.focusGained(evt)' as the first step within your overriding method.

Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
evt - FocusEvent generated for receipt of input focus.

focusLost

public void focusLost(java.awt.event.FocusEvent evt)
Method invoked when PSPNum loses input focus. This method processes the event completely for the PSPNum - it does not pass the event up to parent objects. The method is not declared final, which means you can override it in any class which extends PSPNum. If you do this, you must invoke 'super.focusLost(evt)' as the first step within your overriding method.

Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
evt - FocusEvent generated for loss of input focus.

getCaretPosition

public final int getCaretPosition()
Gets the position of the text insertion caret for this PSPNum.

Overrides:
getCaretPosition in class javax.swing.text.JTextComponent
Returns:
the position of the text insertion caret where zero denotes first position of displayed Text.

setCaretRelativePosition

public final void setCaretRelativePosition(int newRelativePosition)
                                    throws java.lang.IllegalArgumentException
Set caret position for this PSPNum (not for entire class) to relative position given by either CARET_POSITION_FIRSTDIGIT or CARET_POSITION_DECIMAL. PSPNum must currently have the input focus. New caret position must be one of CARET_POSITION_FIRSTDIGIT or CARET_POSITION_DECIMAL. If the PSPNum does not have the input focus when this method is called, the method call is ignored.

Parameters:
newRelativePosition - Flag controlling relative position caret to be set to now.
Throws:
java.lang.IllegalArgumentException - if parameter newRelativePosition is not one of the valid CARET_POSITION_xxx values.

setFocusCaretRelativePosition

public final void setFocusCaretRelativePosition(int newRelativePosition)
                                         throws java.lang.IllegalArgumentException
Set desired relative positioning of caret for this PSPNum (not for entire class) when it gains the input focus. New relative caret setting must be one of CARET_POSITION_DEFAULT, CARET_POSITION_FIRSTDIGIT or CARET_POSITION_DECIMAL.

Throws:
java.lang.IllegalArgumentException - if parameter newCaretPosition is not one of the valid CARET_POSITION_xxx values.

getRound

public final boolean getRound()
Returns setting (true/false) for arithmetic rounding.

Returns:
true/false value for arithmetic rounding.

setRound

public final void setRound(boolean newRound)
Set default true/false value for arithmetic rounding of new numeric values assigned in code (does not apply to keystrokes).


getOverflowCode

public final int getOverflowCode()
Returns current OverflowCode flag setting for overflow following program operations.

Returns:
Value for OverflowCode flag (integer value corresponding to OVERFLOW_xxx value set by preceding setOverflowCode() operation).

setOverflowCode

public final void setOverflowCode(int newCode)
                           throws java.lang.IllegalArgumentException
Set flag for this PSPNum (not for entire class) to control response to numeric overflow when new value set by program operations. New flag setting must be one of OVERFLOW_TRUNCATE_BEEP, OVERFLOW_TRUNCATE, OVERFLOW_IGNORE_BEEP, OVERFLOW_IGNORE, OVERFLOW_BUMP_BEFOREDP or OVERFLOW_EXCEPTION.

Parameters:
newCode - Flag controlling overflow response.
Throws:
java.lang.IllegalArgumentException - if parameter newCode is not one of the valid OVERFLOW_xxx values.

getOverflowKey

public final int getOverflowKey()
Returns current OverflowKey flag setting for overflow following user keying.

Returns:
Value for OverflowKey flag (integer value corresponding to OVERFLOW_xxx value set by preceding setOverflowKey() operation).

setOverflowKey

public final void setOverflowKey(int newKey)
                          throws java.lang.IllegalArgumentException
Set flag for this PSPNum (not for entire class) to control response to numeric overflow when user keys new value. New flag setting must be one of OVERFLOW_TRUNCATE_BEEP, OVERFLOW_TRUNCATE, OVERFLOW_IGNORE_BEEP, OVERFLOW_IGNORE or OVERFLOW_BUMP_BEFOREDP.

Parameters:
newKey - Flag controlling overflow response.
Throws:
java.lang.IllegalArgumentException - if parameter newKey is not one of the valid OVERFLOW_xxx values.

setOverflowDefault

public void setOverflowDefault(byte overflowDefault)
Set flag for PSPNum class (default applied to new PSPNum's) to control response to numeric overflow when new value set by program operations or user keying. New flag setting must be one of OVERFLOW_TRUNCATE_BEEP, OVERFLOW_TRUNCATE, OVERFLOW_IGNORE_BEEP, OVERFLOW_IGNORE or OVERFLOW_BUMP_BEFOREDP. Until this function is called, the default is OVERFLOW_BUMP_BEFOREDP.

Parameters:
overflowDefault - Flag controlling default overflow response.

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent evt)
Keystroke processing - filters out keys inapplicable to decimal numbers. Allowable keystrokes are 0-9, +/- and new decimal place per DI component of PSPNum edit mask. All other visible keystrokes are ignored.

Overrides:
processKeyEvent in class javax.swing.JComponent
Parameters:
evt - Event generated for keying.

lostOwnership

public final void lostOwnership(java.awt.datatransfer.Clipboard cb,
                                java.awt.datatransfer.Transferable data)
method required to be present only for system Clipboard Interface support - does nothing for PSPNum.

Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner
Parameters:
cb - Object representing the system clipboard.
data - Contents of the clipboard.

toString

public final java.lang.String toString()
Returns a String object representing this PSPNum's value - which is the decimal value also returned by the getValue() method.

Overrides:
toString in class java.awt.Component
Returns:
Current decimal numeric value - unformatted.

getValue

public final java.lang.String getValue()
Returns unformatted decimal numeric value.

Returns:
Current decimal numeric value - unformatted.

setValue

public final void setValue(java.lang.String assnValue)
                    throws PSPException
Assign parameter decimal value to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
assnValue - New decimal numeric value.
Throws:
PSPException - if parameter assnValue (after trimming) has extraneous character.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

setValue

public final void setValue(java.lang.String assnValue,
                           int Overflow,
                           boolean Round)
                    throws java.lang.IllegalArgumentException,
                           PSPException
Assign parameter decimal value to this PSPNum with treatment of overflow and rounding determined by last two parameters.

Parameters:
assnValue - New decimal numeric value.
Overflow - One of OVERFLOW_xxx field values for treatment of overflow.
Round - true/false for arithmetic rounding.
Throws:
java.lang.IllegalArgumentException - if Overflow parameter is not one of the valid OVERFLOW_xxx values.
PSPException - if parameter assnValue (after trimming) has extraneous character.
PSPException - if overflow occurs and Overflow parameter set to OVERFLOW_EXCEPTION.

setValue

public final void setValue(PSPNumS assnNum)
                    throws PSPException
Assigns decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively

Parameters:
assnNum - Number whose value to be assigned.
Throws:
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

setValue

public final void setValue(PSPNumS assnNum,
                           int Overflow,
                           boolean Round)
                    throws java.lang.IllegalArgumentException,
                           PSPException
Assigns decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by last two parameters (temporary override values set by preceding setOverflowCode() and setRound() methods).

Parameters:
assnNum - Number whose value to be assigned.
Overflow - One of OVERFLOW_xxx field values for treatment of overflow.
Round - true/false for arithmetic rounding.
Throws:
java.lang.IllegalArgumentException - if Overflow parameter is not one of the valid OVERFLOW_xxx values.
PSPException - if overflow occurs and Overflow parameter set to OVERFLOW_EXCEPTION.

add

public final void add(PSPNumS addNum)
               throws PSPException
Add decimal value of parameter PSPNum to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
addNum - Number whose value to be added.
Throws:
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

add

public final void add(java.lang.String addValue)
               throws PSPException
Add parameter decimal value to this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
addValue - Value to be added.
Throws:
PSPException - if parameter addValue (after trimming) has extraneous character.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

subtract

public final void subtract(PSPNumS subNum)
                    throws PSPException
Subtract decimal value of parameter PSPNum from this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
subNum - Number whose value to be subtracted.
Throws:
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

subtract

public final void subtract(java.lang.String subValue)
                    throws PSPException
Subtract parameter decimal value from this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
subValue - Value to be subtracted.
Throws:
PSPException - if parameter subValue (after trimming) has extraneous character.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

multiply

public final void multiply(PSPNumS multNum)
                    throws PSPException
Multiply this PSPNum by decimal value of parameter PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively

Parameters:
multNum - Number whose value to be multiplied by.
Throws:
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

multiply

public final void multiply(java.lang.String multValue)
                    throws PSPException
Multiply this PSPNum by parameter decimal value with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
multValue - Value to be multiplied by.
Throws:
PSPException - if parameter multValue (after trimming) has extraneous character.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

divide

public final void divide(PSPNumS divNum)
                  throws java.lang.ArithmeticException,
                         PSPException
Divide decimal value of parameter PSPNum into this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
divNum - Number whose value to be divided by.
Throws:
java.lang.ArithmeticException - if parameter divNum has zero value.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

divide

public final void divide(java.lang.String divValue)
                  throws java.lang.ArithmeticException,
                         PSPException
Divide parameter decimal value into this PSPNum with treatment of overflow and rounding determined by OverflowCode and Round properties respectively.

Parameters:
divValue - Value to be divided by.
Throws:
PSPException - if parameter divValue (after trimming) has extraneous character.
java.lang.ArithmeticException - if parameter divValue has zero value.
PSPException - if overflow occurs and OverflowCode property set to OVERFLOW_EXCEPTION.

signum

public final int signum()
Returns the signum function of this number

Returns:
-1, 0 or 1 as the value of this number is negative, zero or positive.

isPositive

public final boolean isPositive()
Check if the number is positive.

Returns:
True if numeric value positive.

isNegative

public final boolean isNegative()
Check if the number is negative.

Returns:
True if numeric value is negative.

isZero

public final boolean isZero()
Check if the number is zero.

Returns:
True if numeric value is zero.

isEQ

public final boolean isEQ(PSPNumS compareNum)
Checks if this PSPNum is EQ another PSPNum.

Returns:
True if this PSPNum has decimal numeric value equal to that of parameter PSPNum.

isEQ

public final boolean isEQ(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is EQ a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value equal to parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

isNE

public final boolean isNE(PSPNumS compareNum)
Checks if this PSPNum is NE another PSPNum.

Returns:
True if this PSPNum has decimal numeric value not equal to that of parameter PSPNum.

isNE

public final boolean isNE(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is NE a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value not equal to parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

isGT

public final boolean isGT(PSPNumS compareNum)
Checks if this PSPNum is GT another PSPNum.

Returns:
True if this PSPNum has decimal numeric value greater than that of parameter PSPNum.

isGT

public final boolean isGT(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is GT a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value greater than parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

isLT

public final boolean isLT(PSPNumS compareNum)
Checks if this PSPNum is LT another PSPNum.

Returns:
True if this PSPNum has decimal numeric value less than that of parameter PSPNum.

isLT

public final boolean isLT(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is LT a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value less than parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

isGE

public final boolean isGE(PSPNumS compareNum)
Checks if this PSPNum is GE another PSPNum.

Returns:
True if this PSPNum has decimal numeric value greater than or equal to that of parameter PSPNum.

isGE

public final boolean isGE(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is GE a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value greater than or equal to parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

isLE

public final boolean isLE(PSPNumS compareNum)
Checks if this PSPNum is LE another PSPNum.

Returns:
True if this PSPNum has decimal numeric value less than or equal to that of parameter PSPNum.

isLE

public final boolean isLE(java.lang.String compareValue)
                   throws PSPException
Checks if this PSPNum is LE a particular numeric value.

Returns:
True if this PSPNum has decimal numeric value less than or equal to parameter value.
Throws:
PSPException - if parameter compareValue (after trimming) has extraneous character.

dump

public void dump()
Utility function to dump PSPNum persistent property values to 'stdout' via 'System.out.println' call. Use only for debugging e.g. if we ask you to do so to help us resolve any problem you may be having with PSPNum. Do not call this function in your production code.