mil.af.afit.router
Class Preferences

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mil.af.afit.router.Preferences
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Preferences
extends java.util.Observable
implements java.io.Externalizable

This class saves various preferences for a Kernel and optionally for any application that uses the kernel. Although some methods are available for use by specific components of this software package, any code interested in saving information (for example: window positions or last directory accessed) can use the getProperty and setProperty methods to save strings.

Since:
1.0
See Also:
Kernel, Serialized Form

Field Summary
static java.lang.String EFFORT
          Amount of effort specified.
static java.lang.String HEADER
          Header used when saving preferences to a file.
static java.lang.String SITE_DEFAULT_PRIORITY
          Default site priority for new sites.
static java.lang.String SITE_DEFAULT_SERVICE_TIME
          Default site service (loiter) time for new sites.
static java.lang.String SOLVER
          Name of last solver that was used.
static java.lang.String THREADS
          Number of threads to specify for solvers to use.
static java.lang.String USE_POST_OPT
          Whether or not to use the extra post-optimization when solving.
static java.lang.String VEHICLE_DEFAULT_ALTITUDE
          Default vehicle altitude (in feet) for new vehicles.
static java.lang.String VEHICLE_DEFAULT_RANGE
          Default vehicle range (in hours) for new vehicles.
static java.lang.String VEHICLE_DEFAULT_SPEED
          Default vehicle speed (in knots) for new vehicles.
static java.lang.String WINDOW_DEFAULT_X
          Default x position of upper left corner for new windows.
static java.lang.String WINDOW_DEFAULT_Y
          Default y position of upper left corner of new windows.
 
Constructor Summary
Preferences()
          Constructs preferences with default values.
 
Method Summary
 int getDefaultPriority()
          Returns the default priority for sites.
 int getDefaultServiceTime()
          Returns the default service (loiter) time (in minutes) for sites.
 int getDefaultWindowX()
          Returns the default x position to use on new windows.
 int getDefaultWindowY()
          Returns the default y position to use on new windows.
 int getLastNumberOfThreads()
          Returns the number of threads that solvers should try to use.
 double getLastRequestedSolutionEffort()
          Returns the amount of effort (from zero to one) requested by the user.
 java.util.Properties getProperties()
          Returns all the properties contained in the preferences.
 java.lang.String getProperty(java.lang.String key)
          Returns the property stored by key.
 void readExternal(java.io.ObjectInput oi)
          Needs an InputStream to work properly.
 void replace(Preferences newPrefs)
          Replaces these preferences with newPrefs.
 void replace(java.util.Properties props)
          Replaces these preferences with the properties stored in props.
 void setDefaultPriority(int priority)
          Sets the default priority for new sites.
 void setDefaultServiceTime(int time)
          Sets the default service (loiter) time (in minutes) for new sites.
 void setDefaultWindowXPosition(int x)
          Sets the default x position for new windows.
 void setDefaultWindowYPosition(int y)
          Sets the default y position for new windows.
 void setLastNumberOfThreads(int threads)
          Sets the number of threads for solvers to try to use.
 void setLastRequestedSolutionEffort(double effort)
          Sets the effort to use when solving.
 void setProperty(java.lang.String key, java.lang.String thing)
          Sets a property stored in key.
 void setUsePostOptimization(boolean state)
          Sets whether or not to use post-optimization when solving.
 boolean usePostOptimization()
          Returns whether or not to use the extra post-optimization when solving.
 void writeExternal(java.io.ObjectOutput oo)
          Needs an OutputStream to work properly.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOW_DEFAULT_X

public static final java.lang.String WINDOW_DEFAULT_X
Default x position of upper left corner for new windows.
Since:
1.0

WINDOW_DEFAULT_Y

public static final java.lang.String WINDOW_DEFAULT_Y
Default y position of upper left corner of new windows.
Since:
1.0

VEHICLE_DEFAULT_SPEED

public static final java.lang.String VEHICLE_DEFAULT_SPEED
Default vehicle speed (in knots) for new vehicles.
Since:
1.0

VEHICLE_DEFAULT_ALTITUDE

public static final java.lang.String VEHICLE_DEFAULT_ALTITUDE
Default vehicle altitude (in feet) for new vehicles.
Since:
1.0

VEHICLE_DEFAULT_RANGE

public static final java.lang.String VEHICLE_DEFAULT_RANGE
Default vehicle range (in hours) for new vehicles.
Since:
1.0

SITE_DEFAULT_PRIORITY

public static final java.lang.String SITE_DEFAULT_PRIORITY
Default site priority for new sites.
Since:
1.0

SITE_DEFAULT_SERVICE_TIME

public static final java.lang.String SITE_DEFAULT_SERVICE_TIME
Default site service (loiter) time for new sites.
Since:
1.0

SOLVER

public static final java.lang.String SOLVER
Name of last solver that was used.
Since:
1.0

EFFORT

public static final java.lang.String EFFORT
Amount of effort specified.
Since:
1.0

USE_POST_OPT

public static final java.lang.String USE_POST_OPT
Whether or not to use the extra post-optimization when solving.
Since:
1.0

THREADS

public static final java.lang.String THREADS
Number of threads to specify for solvers to use.
Since:
1.0

HEADER

public static final java.lang.String HEADER
Header used when saving preferences to a file.
Since:
1.0
Constructor Detail

Preferences

public Preferences()
Constructs preferences with default values.
Since:
1.0
Method Detail

getDefaultWindowX

public final int getDefaultWindowX()
Returns the default x position to use on new windows.
Returns:
default x position for new windows
Since:
1.0

getDefaultWindowY

public final int getDefaultWindowY()
Returns the default y position to use on new windows.
Returns:
default y position for new windows
Since:
1.0

usePostOptimization

public final boolean usePostOptimization()
Returns whether or not to use the extra post-optimization when solving. The post-op uses a tabu search that adds to the solve time but may yield better answers on complicated problems.
Returns:
whether or not to use post-optimization
Since:
1.0.2
See Also:
HSolver

getLastRequestedSolutionEffort

public final double getLastRequestedSolutionEffort()
Returns the amount of effort (from zero to one) requested by the user.
Returns:
effort requested by user
Since:
1.0

getLastNumberOfThreads

public final int getLastNumberOfThreads()
Returns the number of threads that solvers should try to use. This is sometimes helpful on multiprocessor computers.
Returns:
threads to use
Since:
1.0

getDefaultServiceTime

public final int getDefaultServiceTime()
Returns the default service (loiter) time (in minutes) for sites.
Returns:
default service time for sites
Since:
1.0
See Also:
Site

getDefaultPriority

public final int getDefaultPriority()
Returns the default priority for sites.
Returns:
default priority for sites
Since:
1.0
See Also:
Site

getProperty

public final java.lang.String getProperty(java.lang.String key)
Returns the property stored by key.
Parameters:
key - key for property to retrieve
Returns:
property stored by key
Since:
1.0

getProperties

public final java.util.Properties getProperties()
Returns all the properties contained in the preferences.
Returns:
all properties
Since:
1.0
See Also:
Properties

setDefaultWindowXPosition

public final void setDefaultWindowXPosition(int x)
Sets the default x position for new windows.
Parameters:
x - default x position for new windows.
Since:
1.0

setDefaultWindowYPosition

public final void setDefaultWindowYPosition(int y)
Sets the default y position for new windows.
Parameters:
x - default y position for new windows.
Since:
1.0

setUsePostOptimization

public final void setUsePostOptimization(boolean state)
Sets whether or not to use post-optimization when solving.
Parameters:
state - whether or not to use post-optimization when solving
Since:
1.0

setLastRequestedSolutionEffort

public final void setLastRequestedSolutionEffort(double effort)
Sets the effort to use when solving.
Parameters:
effort - effort to use when solving
Since:
1.0

setLastNumberOfThreads

public final void setLastNumberOfThreads(int threads)
Sets the number of threads for solvers to try to use.
Parameters:
threads - the number of threads for solvers to try to use.
Since:
1.0

setDefaultServiceTime

public final void setDefaultServiceTime(int time)
Sets the default service (loiter) time (in minutes) for new sites.
Parameters:
time - the default service (loiter) time (in minutes) for new sites.
Since:
1.0

setDefaultPriority

public final void setDefaultPriority(int priority)
Sets the default priority for new sites.
Parameters:
time - the default priority for new sites.
Since:
1.0

setProperty

public final void setProperty(java.lang.String key,
                              java.lang.String thing)
Sets a property stored in key. Works like java.util.Properties.
Parameters:
key - key for storing the property
thing - property to store
Since:
1.0
See Also:
Properties

replace

public final void replace(Preferences newPrefs)
Replaces these preferences with newPrefs. This is used when loading a new Kernel. Observers registered with the original preferences will still be registered, but anything registered with newPrefs will not still be registered.
Parameters:
newPrefs - the new preferences to use
Since:
1.0

replace

public final void replace(java.util.Properties props)
Replaces these preferences with the properties stored in props. This is identical in nature to the replace( newPrefs ) method.
Parameters:
props - the properties for the new preferences to use
Since:
1.0

readExternal

public void readExternal(java.io.ObjectInput oi)
                  throws java.io.IOException
Needs an InputStream to work properly.
Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput oo)
                   throws java.io.IOException
Needs an OutputStream to work properly.
Specified by:
writeExternal in interface java.io.Externalizable