org.zaval.lw
Class LwSpin

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.LwSpin
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwActionListener, LwComponent, LwContainer, LwLayout, TextListener, Validationable

public class LwSpin
extends LwPanel
implements LwLayout, LwActionListener, TextListener

This is spin light weight component that can be used to input a bound integer value. The bound is determined by setBound method. To control current value use setValue and getValue methods. The component performs action event whenever the spin value has been changed. Use addActionListener and removeActionListener methods to register the listener.

The spin value validation and representation are defined by LwSpinValidator. Use setSpinValidator method to customize it.


Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwSpin()
          Constructs the componen.
 
Method Summary
 void actionPerformed(LwActionEvent e)
          Invoked when an action event occured.
 void addActionListener(LwActionListener l)
          Adds the action events listener.
 java.awt.Dimension calcPreferredSize(LayoutContainer target)
          Calculates the preferred size dimension for the layout container.
 void componentAdded(java.lang.Object id, Layoutable lw, int index)
          Invoked when the specified layoutable component is added to the layout container (that uses the layout manager).
 void componentRemoved(Layoutable lw, int index)
          Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
 void enableLoop(boolean b)
          Enables or disables the loop mode.
protected  LwLayout getDefaultLayout()
          Gets the default layout manager that is set with the container during initialization.
 int getMaxValue()
          Gets the maximum value.
 int getMinValue()
          Gets the minimum value.
 LwSpinValidator getSpinValidator()
          Gets the spin validator.
 int getStep()
          Gets the current step.
 TextModel getTextModel()
          Gets the text model.
 int getValue()
          Gets the current value.
 boolean isLoopEnabled()
          Returns the loop mode.
 void layout(LayoutContainer target)
          Lays out the child layoutable components inside the layout container.
 void removeActionListener(LwActionListener l)
          Removes the action events listener so it no longer get action events from the component.
 void setBound(int min, int max)
          Sets the specified bound.
 void setSpinValidator(LwSpinValidator v)
          Sets the specified spin validator.
 void setStep(int s)
          Sets the specified step.
 void setValue(int v)
          Sets the specified value.
 void textInserted(TextEvent e)
          Invoked when a new text has been inserted in the text.
 void textRemoved(TextEvent e)
          Invoked when a part of the text has been removed.
 void textUpdated(TextEvent e)
          Invoked when the text has been updated.
protected  void valueChanged()
          The method is called whenever the spin value has been changed.
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, invalidate, paintOnTop, recalc, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs
 
Methods inherited from class org.zaval.lw.LwCanvas
canHaveFocus, getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, paint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwComponent
canHaveFocus, getLwParent, getViewMan, getVisiblePart, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, paint, repaint, repaint, update
 
Methods inherited from interface org.zaval.util.Validationable
isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 

Constructor Detail

LwSpin

public LwSpin()
Constructs the componen. In this case the bound is [-10 .. +10].
Method Detail

getTextModel

public TextModel getTextModel()
Gets the text model.
Returns:
a text model.

enableLoop

public void enableLoop(boolean b)
Enables or disables the loop mode. If the loop mode is enabled than a spin value will grow from minimal to maximal or from maximal to minimum values.
Parameters:
b - true to enable the loop mode.

isLoopEnabled

public boolean isLoopEnabled()
Returns the loop mode.
Returns:
a loop mode

setStep

public void setStep(int s)
Sets the specified step. The step is used as the spin value increment or decrement whenever a spin button is pressed.
Parameters:
s - the specified step.

getStep

public int getStep()
Gets the current step.
Returns:
a current step

addActionListener

public void addActionListener(LwActionListener l)
Adds the action events listener. The action event is performed when a spin value has been changed.
Parameters:
l - the action events listener.

removeActionListener

public void removeActionListener(LwActionListener l)
Removes the action events listener so it no longer get action events from the component.
Parameters:
l - the action events listener.

componentAdded

public void componentAdded(java.lang.Object id,
                           Layoutable lw,
                           int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). The specified constraints, layoutable component and child index are passed as arguments into the method.
Specified by:
componentAdded in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
id - the layoutable component constraints.
lw - the layoutable component that has been added.
index - the child index.

componentRemoved

public void componentRemoved(Layoutable lw,
                             int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
Specified by:
componentRemoved in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
lw - the layoutable component that has been removed.
index - the child component index.

calcPreferredSize

public java.awt.Dimension calcPreferredSize(LayoutContainer target)
Description copied from interface: LwLayout
Calculates the preferred size dimension for the layout container. The method has to calculate "pure" preferred size, it means that an insets of the container should not be considered.
Specified by:
calcPreferredSize in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container.
Returns:
a "pure" preferred size.

layout

public void layout(LayoutContainer target)
Description copied from interface: LwLayout
Lays out the child layoutable components inside the layout container.
Specified by:
layout in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container that needs to be laid out.

actionPerformed

public void actionPerformed(LwActionEvent e)
Description copied from interface: LwActionListener
Invoked when an action event occured. The specified action event is passed to the method.
Specified by:
actionPerformed in interface LwActionListener
Following copied from interface: org.zaval.lw.event.LwActionListener
Parameters:
e - the specified action event.

getValue

public int getValue()
Gets the current value.
Returns:
a current value.

setValue

public void setValue(int v)
Sets the specified value. If the loop mode is enabled than a case when the new value is less than minimum the method sets maximum value as the current or if the new value is greater than maximum the method sets minimum value as the current.
Parameters:
v - the new current value.

getMinValue

public int getMinValue()
Gets the minimum value. The current value cannot be less the minimum value.
Returns:
a minimum value.

getMaxValue

public int getMaxValue()
Gets the maximum value. The current value cannot be greater the maximum value.
Returns:
a maximum value.

getSpinValidator

public LwSpinValidator getSpinValidator()
Gets the spin validator. The current validator is a mask handler that defines a spin value representation and validation algorithms.
Returns:
a spin validator.

setSpinValidator

public void setSpinValidator(LwSpinValidator v)
Sets the specified spin validator. The validator is a mask handler that defines a spin value representation and validation algorithms.
Parameters:
v - the specified spin validator.

setBound

public void setBound(int min,
                     int max)
Sets the specified bound. The bound defines minimum and maximum values. The current value cannot be less minimum and greater the maximum values.
Parameters:
min - the specified minimum value.
max - the specified maximum value.

textRemoved

public void textRemoved(TextEvent e)
Description copied from interface: TextListener
Invoked when a part of the text has been removed.
Specified by:
textRemoved in interface TextListener
Following copied from interface: org.zaval.data.event.TextListener
Parameters:
e - the text event.

textInserted

public void textInserted(TextEvent e)
Description copied from interface: TextListener
Invoked when a new text has been inserted in the text.
Specified by:
textInserted in interface TextListener
Following copied from interface: org.zaval.data.event.TextListener
Parameters:
e - the text event.

textUpdated

public void textUpdated(TextEvent e)
Description copied from interface: TextListener
Invoked when the text has been updated.
Specified by:
textUpdated in interface TextListener
Following copied from interface: org.zaval.data.event.TextListener
Parameters:
e - the text event.

getDefaultLayout

protected LwLayout getDefaultLayout()
Description copied from class: LwPanel
Gets the default layout manager that is set with the container during initialization. This implementation of the method returns LwRastLayout as the default layout manager, the layout manager is got as a static object by "layout.raster" key.
Overrides:
getDefaultLayout in class LwPanel
Following copied from class: org.zaval.lw.LwPanel
Returns:
a layout manager.

valueChanged

protected void valueChanged()
The method is called whenever the spin value has been changed.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org