pop.model
Class ModelManager

java.lang.Object
  |
  +--pop.model.ModelManager

public class ModelManager
extends java.lang.Object

Loosely manages the model's activities. Maintains the only handle to the set of Statics constants, and is the only handle by which a gui or other application may control the model's behavior.

See Also:
Statics

Constructor Summary
ModelManager(Constants c)
          Handy constructor takes a Constants object.
ModelManager(int maximum_age, int categories, java.lang.String[] category_names, int years, int base_year, java.lang.String model_title)
          Alternate, uglier constructor requires multiple parameters.
 
Method Summary
 void destroy()
          Destroys the current model; necessary to create a new one.
 boolean has_fert_source()
          True if the model has a source of fertility rates.
 boolean has_migrant_source()
          True if the model has a source of migration data.
 boolean has_mort_source()
          True if the model has a source of mortality rates.
 boolean has_pop_source()
          True if the model has a source of initial population sizes.
 boolean increment_model()
          Increments the model one year, until the current year is equal to Statics.years().
static ModelManager load(java.lang.String filename)
          Tries to load a new model from the specified file.
 PopulationSizesFactory pop_source()
          Returns initial population sizes factory if one is available; null otherwise.
 void reset()
          Resets the current year to 0, so model can be rerun.
 Results results()
          Returns the results (null if model not yet incremented).
 void run_model()
          Runs the model for all remaining years (0 to end if increment() not invoked).
 boolean save(java.lang.String filename)
          Saves the current model to a new file with the specified filename.
 void set_factory(FertilityFactory fert_source)
          Sets the factory that will produce fertility factors.
 void set_factory(MigrationFactory migrant_source)
          Sets the factory that will produce migration data.
 void set_factory(MortalityFactory mort_source)
          Sets the factory that will produce mortality factors.
 void set_factory(PopulationSizesFactory pop_source)
          Sets the factory that will produce initial population sizes.
 void set_new_labels(Constants c)
          Changes just the labels in Statics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelManager

public ModelManager(Constants c)
Handy constructor takes a Constants object.

ModelManager

public ModelManager(int maximum_age,
                    int categories,
                    java.lang.String[] category_names,
                    int years,
                    int base_year,
                    java.lang.String model_title)
Alternate, uglier constructor requires multiple parameters.
See Also:
for an explanation of these parameters.
Method Detail

set_new_labels

public void set_new_labels(Constants c)
Changes just the labels in Statics.

set_factory

public void set_factory(PopulationSizesFactory pop_source)
Sets the factory that will produce initial population sizes.

set_factory

public void set_factory(FertilityFactory fert_source)
Sets the factory that will produce fertility factors.

set_factory

public void set_factory(MortalityFactory mort_source)
Sets the factory that will produce mortality factors.

set_factory

public void set_factory(MigrationFactory migrant_source)
Sets the factory that will produce migration data.

run_model

public void run_model()
Runs the model for all remaining years (0 to end if increment() not invoked). Preconditions: all factories are ready to go. Note: use increment() instead if any factories require alteration between years.

increment_model

public boolean increment_model()
Increments the model one year, until the current year is equal to Statics.years(). Preconditions: all factories are ready to go.
Returns:
true if the model has been incremented (false means all years have been run already)

results

public Results results()
Returns the results (null if model not yet incremented).

reset

public void reset()
Resets the current year to 0, so model can be rerun.

save

public boolean save(java.lang.String filename)
Saves the current model to a new file with the specified filename. Returns true only if completely successful.

load

public static ModelManager load(java.lang.String filename)
Tries to load a new model from the specified file. The old model is no longer available.
Returns:
a new ModelManager object, or null if the load was unsuccessful

has_pop_source

public boolean has_pop_source()
True if the model has a source of initial population sizes.

pop_source

public PopulationSizesFactory pop_source()
Returns initial population sizes factory if one is available; null otherwise.

has_fert_source

public boolean has_fert_source()
True if the model has a source of fertility rates.

has_mort_source

public boolean has_mort_source()
True if the model has a source of mortality rates.

has_migrant_source

public boolean has_migrant_source()
True if the model has a source of migration data.

destroy

public void destroy()
Destroys the current model; necessary to create a new one.