com.sygem.swing.jpopupslider
Class PopupNumberModel

java.lang.Object
  extended bycom.sygem.swing.jpopupslider.PopupNumberModel
All Implemented Interfaces:
java.io.Serializable

public class PopupNumberModel
extends java.lang.Object
implements java.io.Serializable

Specifies the model for storing the current value of a JPopupSlider.

Title: JPopupSlider
Description: Displays a slider bar in a popup window
Copyright: Copyright (c) 2004
Company: SyGem Software

Version:
1.0
See Also:
Serialized Form

Constructor Summary
PopupNumberModel(double value, double minimum, double maximum, double stepSize)
          Constructs a PopupNumberModel with the specified value, minimum/maximum bounds, and stepSize.
PopupNumberModel(int value, int minimum, int maximum, int stepSize)
          Constructs a PopupNumberModel with the specified value, minimum/maximum bounds, and stepSize.
PopupNumberModel(java.lang.Number value, java.lang.Number minimum, java.lang.Number maximum, java.lang.Number stepSize)
          Constructs a PopupNumberModel that represents a closed sequence of numbers from minimum to maximum.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the model's listener list.
 javax.swing.event.ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added to this PopupNumberModel with addChangeListener().
 java.util.EventListener[] getListeners(java.lang.Class listenerType)
          Return an array of all the listeners of the given type that were added to this model.
 java.lang.Number getMaximum()
          Returns the highest number in the model.
 java.lang.Number getMinimum()
          Returns the lowest number in this sequence.
 java.lang.Number getStepSize()
          Returns the size of the value used to draw step marks on the popup window.
 java.lang.Number getValue()
          Returns the value of the popup slider.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the model's listener list.
 void setMaximum(java.lang.Number maximum)
          Changes the upper bound for numbers in this model.
 void setMinimum(java.lang.Number minimum)
          Changes the lower bound for numbers in this model.
 void setStepSize(java.lang.Number stepSize)
          Changes the distance at which step marks are drawn on the popup window.
 void setValue(java.lang.Object value)
          Sets the current value for this popup slider.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PopupNumberModel

public PopupNumberModel(double value,
                        double minimum,
                        double maximum,
                        double stepSize)
Constructs a PopupNumberModel with the specified value, minimum/maximum bounds, and stepSize.

Parameters:
value - the current value of the model
minimum - the first number in the sequence
maximum - the last number in the sequence
stepSize - the step value used for rendering the popup window
Throws:
java.lang.IllegalArgumentException - if the following expression is false: minimum <= value <= maximum

PopupNumberModel

public PopupNumberModel(int value,
                        int minimum,
                        int maximum,
                        int stepSize)
Constructs a PopupNumberModel with the specified value, minimum/maximum bounds, and stepSize.

Parameters:
value - the current value of the model
minimum - the first number in the sequence
maximum - the last number in the sequence
stepSize - the step value used for rendering the popup window
Throws:
java.lang.IllegalArgumentException - if the following expression is false: minimum <= value <= maximum

PopupNumberModel

public PopupNumberModel(java.lang.Number value,
                        java.lang.Number minimum,
                        java.lang.Number maximum,
                        java.lang.Number stepSize)
Constructs a PopupNumberModel that represents a closed sequence of numbers from minimum to maximum.

If any parameter is null, or if both minimum and maximum are specified and mininum > maximum then an IllegalArgumentException is thrown. Similarly if (minimum <= value <= maximum) is false, an IllegalArgumentException is thrown.

Parameters:
value - the current (non null) value of the model
minimum - the first number in the sequence (non null)
maximum - the last number in the sequence (non null)
stepSize - the step value used for rendering the popup window
Throws:
java.lang.IllegalArgumentException - if any parameter is null or if the following expression is false: minimum <= value <= maximum
Method Detail

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the model's listener list. The ChangeListeners must be notified when the models value changes.

Parameters:
l - the ChangeListener to add
See Also:
removeChangeListener(javax.swing.event.ChangeListener)

getChangeListeners

public javax.swing.event.ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this PopupNumberModel with addChangeListener().

Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Return an array of all the listeners of the given type that were added to this model. For example to find all of the ChangeListeners added to this model:
 myPopupNumberModel.getListeners(ChangeListener.class);
 

Parameters:
listenerType - the type of listeners to return, e.g. ChangeListener.class
Returns:
all of the objects receiving listenerType notifications from this model

getMaximum

public java.lang.Number getMaximum()
Returns the highest number in the model.

Returns:
the value of the maximum property
See Also:
setMaximum(java.lang.Number)

getMinimum

public java.lang.Number getMinimum()
Returns the lowest number in this sequence.

Returns:
the value of the minimum property
See Also:
setMinimum(java.lang.Number)

getStepSize

public java.lang.Number getStepSize()
Returns the size of the value used to draw step marks on the popup window.

Returns:
the value of the stepSize property
See Also:
setStepSize(java.lang.Number)

getValue

public java.lang.Number getValue()
Returns the value of the popup slider.

Returns:
the value property
See Also:
setValue(java.lang.Object)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the model's listener list.

Parameters:
l - the ChangeListener to remove
See Also:
addChangeListener(javax.swing.event.ChangeListener)

setMaximum

public void setMaximum(java.lang.Number maximum)
Changes the upper bound for numbers in this model.

This property must be a Number of the same type as the value.

This method fires a ChangeEvent if the maximum has changed.

Parameters:
maximum - a Number with the same type as value
See Also:
getMaximum(), setMinimum(java.lang.Number), addChangeListener(javax.swing.event.ChangeListener)

setMinimum

public void setMinimum(java.lang.Number minimum)
Changes the lower bound for numbers in this model. This property must be a Number of the same type as the value.

This method fires a ChangeEvent if the minimum has changed.

Parameters:
minimum - a Number with the same type as value
See Also:
getMinimum(), setMaximum(java.lang.Number), addChangeListener(javax.swing.event.ChangeListener)

setStepSize

public void setStepSize(java.lang.Number stepSize)
Changes the distance at which step marks are drawn on the popup window. An IllegalArgumentException is thrown if stepSize is null.

This method fires a ChangeEvent if the stepSize has changed.

Parameters:
stepSize - the size of the value used to draw step marks on the popup window
See Also:
getStepSize(), addChangeListener(javax.swing.event.ChangeListener)

setValue

public void setValue(java.lang.Object value)
Sets the current value for this popup slider. If value is null, or not a Number, an IllegalArgumentException is thrown. No bounds checking is done here; the new value may invalidate the (minimum <= value <= maximum) invariant enforced by the constructors.

This method fires a ChangeEvent if the value has changed.

Parameters:
value - the current (non null) Number for this sequence
Throws:
java.lang.IllegalArgumentException - if value is null or not a Number
See Also:
getValue(), addChangeListener(javax.swing.event.ChangeListener)


Copyright © 2004 SyGem Software. All Rights Reserved.