frysk.gui.prefs
Class IntPreference

java.lang.Object
  extended by frysk.gui.prefs.FryskPreference
      extended by frysk.gui.prefs.IntPreference
All Implemented Interfaces:
Saveable

public class IntPreference
extends FryskPreference

IntPreference represents a preference that takes integer values within a contiguous range.


Nested Class Summary
static interface IntPreference.IntPreferenceListener
           
 
Constructor Summary
IntPreference(String name, int min, int max, int fallback)
          Creates a new IntPreference.
 
Method Summary
 void addListener(IntPreference.IntPreferenceListener listener)
          Adds a new listener to this preference.
 int getCurrentValue()
           
 int getMaxValue()
           
 int getMinValue()
           
 void load(Preferences prefs)
          Loads the value of this preference from the provided model
 void revert()
          Replaces the current value of the preference with the one in the model
 void save(Preferences prefs)
          Saves the current value of this preference into the model and notifies all listeners
 void setCurrentValue(int newVal)
          Sets the value of this preference.
 
Methods inherited from class frysk.gui.prefs.FryskPreference
getName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntPreference

public IntPreference(String name,
                     int min,
                     int max,
                     int fallback)
Creates a new IntPreference. Note that if the default value is outside the bounds set by min and max it will be set to the closest bound.

Parameters:
name - The name of the preference
min - The minimum value
max - The maximum value
fallback - The default value.
Method Detail

getCurrentValue

public int getCurrentValue()
Returns:
The current value of the preference

getMinValue

public int getMinValue()
Returns:
The minimum value of the preference

getMaxValue

public int getMaxValue()
Returns:
The maximum value of the preference

setCurrentValue

public void setCurrentValue(int newVal)
Sets the value of this preference. Note that if this value is outside of the min,max for this preference it will be set to the closest bound

Parameters:
newVal - The new value for this preference.

save

public void save(Preferences prefs)
Saves the current value of this preference into the model and notifies all listeners


load

public void load(Preferences prefs)
Loads the value of this preference from the provided model


addListener

public void addListener(IntPreference.IntPreferenceListener listener)
Adds a new listener to this preference. The listener will be notified whenever this preference saves information into the preference model.

Parameters:
listener - The IntPreferenceListener

revert

public void revert()
Replaces the current value of the preference with the one in the model

Specified by:
revert in class FryskPreference