SORTIE Java Interface  1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
sortie.data.funcgroups.TreePopulation Class Reference

This holds all data relating to the tree population. More...

Inheritance diagram for sortie.data.funcgroups.TreePopulation:
sortie.data.funcgroups.BehaviorTypeBase

Public Member Functions

 TreePopulation (GUIManager oManager) throws ModelException
 Constructor. More...
 
int getNumberOfSpecies ()
 Returns the number of species. More...
 
ArrayList< TreegetTrees ()
 Gets the list of trees. More...
 
void clearTreeMapParseSettings ()
 Clears any tree map parse settings that may be in place. More...
 
int getSpeciesCodeFromName (String sName)
 When passed the name of a species, will give back the corresponding species number code. More...
 
void addTabDelimTreeMapFile (javax.swing.JFrame oWindow, String sFileName) throws ModelException
 Adds the trees from a tab-delimited text tree map file. More...
 
int getNumberOfSizeClasses ()
 Returns the number of size classes. More...
 
Float getSizeClass (int iIndex)
 Returns the size class at a specific index. More...
 
void setSpeciesNames (String[] p_sVals) throws ModelException
 Sets the species name list. More...
 
void changeOfSpecies (int iOldNumSpecies, int[] p_iIndexer, String[] p_sNewSpecies) throws ModelException
 Deletes all trees. More...
 
String getSpeciesNameFromCode (int iSpecies)
 For a given species code, returns its name. More...
 
void writeBehaviorNodes (BufferedWriter out, TreePopulation oPop) throws ModelException
 
TreeBehavior getTreeBehavior ()
 
void validateData (TreePopulation oPop) throws ModelException
 This makes sure all data is valid and can be used to run the model. More...
 
void writeSpeciesList (BufferedWriter jOut) throws IOException
 Writes the species list. More...
 
void writeTreeMap (BufferedWriter jOut) throws ModelException
 Writes an XML tree map if there are any trees to write. More...
 
int getFloatDataCode (String sDataMember, int iSpecies, int iType) throws ModelException
 Gets the data code for accessing a float tree data member. More...
 
int getIntDataCode (String sDataMember, int iSpecies, int iType) throws ModelException
 Gets the data code for accessing an int tree data member. More...
 
int getBoolDataCode (String sDataMember, int iSpecies, int iType) throws ModelException
 Gets the data code for accessing a bool tree data member. More...
 
int getCharDataCode (String sDataMember, int iSpecies, int iType) throws ModelException
 Gets the data code for accessing a float tree data member. More...
 
void clearTrees ()
 Clears all trees. More...
 
boolean readTreeMapSettings (String sXMLTag, Attributes oAttributes, Object oData) throws ModelException
 Reads tree map settings from XML parsing. More...
 
void readSpecies (Attributes oAttributes) throws ModelException
 Reads tree species from XML parsing. More...
 
void readTreeSettings (Attributes oAttributes) throws ModelException
 Reads tree settings from XML parsing. More...
 
void readTreeParent (Attributes oAttributes) throws ModelException
 Reads tree parent from XML parsing. More...
 
void changeSpeciesName (String sOldSpecies, String sNewSpecies) throws ModelException
 Changes the name of a species. More...
 
void doCopySpecies (String sCopyFrom, String sCopyTo) throws ModelException
 Makes one species exactly like another. More...
 
Allometry getAllometry ()
 Gets the allometry object. More...
 
Behavior getBehaviorByXMLParametersParentTag (String sXMLTag, int iPos)
 Overridden to ignore position. More...
 
Behavior createBehaviorFromParameterFileTag (String sParameterFileTag) throws ModelException
 Overridden to not create. More...
 
void doSetup (TreePopulation oPop) throws ModelException
 Overridden to let allometry do setup. More...
 
- Public Member Functions inherited from sortie.data.funcgroups.BehaviorTypeBase
 BehaviorTypeBase (GUIManager oManager, String sName)
 Constructor. More...
 
boolean anyBehaviorsEnabled ()
 Determines if any of the child behaviors are currently enabled. More...
 
void validateData (TreePopulation oPop) throws ModelException
 Implements data checking. More...
 
Behavior createBehaviorFromParameterFileTag (String sParameterFileTag) throws ModelException
 Creates a new behavior from an XML parameter file name tag and inserts it into the child behaviors list. More...
 
void sortBehaviors ()
 Sorts the behaviors by list position. More...
 
boolean canBehaviorBeDuplicated (String sParameterFileTag) throws ModelException
 Whether or not a behavior of a certain class can be duplicated in a run. More...
 
boolean doesBehaviorNeedTrees (String sParameterFileTag) throws ModelException
 Whether or not a behavior of a certain class can be duplicated in a run. More...
 
ArrayList< BehaviorInstantiatorgetAllPossibleBehaviors ()
 Gets all possible behaviors. More...
 
Behavior getBehaviorByXMLParametersParentTag (String sXMLTag, int iPos)
 Finds a behavior by its XML parameters parent tag. More...
 
String getDescriptor (String sParameterFileTag)
 Gets the descriptor for a behavior based on its parameter file tag. More...
 
Grid [] getEnabledGridObjects () throws ModelException
 Gets the list of grid objects which the currently enabled behaviors would be expected to create - and thus would be available to output, etc. More...
 
ArrayList< BehaviorgetAllInstantiatedBehaviors ()
 Get the list of child behaviors currently selected for the run. More...
 
void writeBehaviorNodes (BufferedWriter out, TreePopulation oPop) throws ModelException
 Writes behavior tags to the parameter file. More...
 
ArrayList< BehaviorgetBehaviorByDisplayName (String sDescriptor)
 Convenience method for getting an instantiated behavior. More...
 
ArrayList< BehaviorgetBehaviorByParameterFileTag (String sParameterFileTag)
 Finds an instantiated behavior by its XML parameter file tag. More...
 
void changeOfSpecies (int iOldNumSpecies, int[] p_iIndexer, String[] p_sNewSpecies) throws ModelException
 Triggered when there is a change in the species list. More...
 
void copySpecies (int iSpeciesCopyFrom, int iSpeciesCopyTo) throws ModelException
 Copies one species to another. More...
 
void endOfParameterFileRead ()
 Allows child behaviors to do end-of-parameter-file tasks. More...
 
void changeOfSpeciesName (String sOldSpecies, String sNewSpecies) throws ModelException
 Performs any necessary tasks associated with changing the name of a species. More...
 
GUIManager getGUIManager ()
 
void writeXML (BufferedWriter jOut, TreePopulation oPop) throws ModelException
 Writes the XML data to a parameter file for the behaviors owned by this object. More...
 
void removeBehavior (Behavior oBeh)
 Removes a behavior from the instantiated list. More...
 
String getName ()
 Returns the user-acceptable name for this object. More...
 
void changeOfPlotResolution (float fOldX, float fOldY, float fNewX, float fNewY) throws ModelException
 Allows instantiated behaviors to perform any tasks associated with a change of plot resolution. More...
 
void doSetup (TreePopulation oPop) throws ModelException
 Does any needed setup once the tree population object has data. More...
 

Static Public Member Functions

static int getNumberOfTypes ()
 Get the total number of tree types (life history stages). More...
 
static String getTypeNameFromCode (int iType)
 For a given type code, returns its name. More...
 
static int getTypeCodeFromName (String sName)
 For a given type name, returns its code. More...
 
- Static Public Member Functions inherited from sortie.data.funcgroups.BehaviorTypeBase
static boolean [] mergeBooleans (boolean[] p_oMergeOne, boolean[] p_oMergeTwo)
 Merges two boolean arrays and returns an array where there is a true in each array bucket where EITHER array is true. More...
 

Public Attributes

ArrayList< Treemp_oTrees = new ArrayList<Tree>(0)
 Holds Tree objects to be written to a tree map. More...
 
ArrayList< ArrayList< ArrayList< String > > > mp_sTreeIntDataMembers
 Tree integer data members. More...
 

Static Public Attributes

static final int SEED = 0
 Seed tree life history stage - matches definition in C++. More...
 
static final int SEEDLING = 1
 Seedling tree life history stage - matches definition in C++. More...
 
static final int SAPLING = 2
 Sapling tree life history stage - matches definition in C++. More...
 
static final int ADULT = 3
 Adult tree life history stage - matches definition in C++. More...
 
static final int STUMP = 4
 Stump tree life history stage - matches definition in C++. More...
 
static final int SNAG = 5
 Snag tree life history stage - matches definition in C++. More...
 
static final int WOODY_DEBRIS = 6
 Woody debris tree life history stage - matches definition in C++. More...
 

Protected Member Functions

int getCodeForDataMember (ArrayList< String > p_oMemberList, String sDataMember)
 Gets the data member code for a data member label. More...
 

Protected Attributes

ArrayList< ArrayList< ArrayList< Integer > > > mp_iTreeIntTransforms
 Index positions for tree integer data members. More...
 
int [] mp_iSpeciesTransforms
 When parsing tree maps, this will convert in case the species list is in a different order. More...
 
int m_iSpeciesCounter
 Counter for tree map species list when parsing tree map files. More...
 
int m_iCurrentTreeType
 When parsing tree map settings, the current tree type. More...
 
- Protected Attributes inherited from sortie.data.funcgroups.BehaviorTypeBase
ArrayList< Behaviormp_oInstantiatedBehaviors
 List of child behaviors currently selected for the run. More...
 
ArrayList< BehaviorInstantiatormp_oAvailableBehaviors
 List of possible behaviors that can be created. More...
 
GUIManager m_oManager
 GUIManager object. More...
 
String m_sName
 User-consumable name for this object. More...
 

Private Member Functions

void updateTreeDataMembers () throws ModelException
 Update the tree data members for the currently enabled behaviors. More...
 

Private Attributes

ModelVector mp_sSpeciesNames
 List of species names - ignore XML tags since this data can't use the automated XML read-write system. More...
 

Detailed Description

This holds all data relating to the tree population.

It also manages the windows necessary to display and retrieve information about the trees. Copyright: Copyright (c) Charles D. Canham 2003 Company: Cary Institute of Ecosystem Studies

Author
Lora E. Murphy
Version
1.1


Edit history:
---------------—
December 8, 2011: Wiped the slate clean for version 7 (LEM)

Constructor & Destructor Documentation

◆ TreePopulation()

sortie.data.funcgroups.TreePopulation.TreePopulation ( GUIManager  oManager) throws ModelException

Constructor.

Parameters
oManagerGUIManager object

Member Function Documentation

◆ addTabDelimTreeMapFile()

void sortie.data.funcgroups.TreePopulation.addTabDelimTreeMapFile ( javax.swing.JFrame  oWindow,
String  sFileName 
) throws ModelException

Adds the trees from a tab-delimited text tree map file.

Parameters
sFileNameThe file name of the tree map file.
oWindowWindow to which to display messages
Exceptions
ModelExceptionif:
  • There is an unrecognized species
  • There is an unrecognized life history stage
  • There is a negative diameter
  • There is a negative height

◆ changeOfSpecies()

void sortie.data.funcgroups.TreePopulation.changeOfSpecies ( int  iOldNumSpecies,
int []  p_iIndexer,
String []  p_sNewSpecies 
) throws ModelException

Deletes all trees.

Parameters
iOldNumSpeciessays how many species there used to be.
p_iIndexeris an array, sized to the new number of species. For each bucket (representing the index number of a species on the new list), the value is either the index of that same species in the old species list, or -1 if the species is new.
p_sNewSpeciesThe new species list.
Exceptions
ModelExceptionif anything goes wrong.

◆ changeSpeciesName()

void sortie.data.funcgroups.TreePopulation.changeSpeciesName ( String  sOldSpecies,
String  sNewSpecies 
) throws ModelException

Changes the name of a species.

Everything about the species remains the same except for the name. This is an easier process than actually changing the species list.

Parameters
sOldSpeciesString Old name of the species
sNewSpeciesString New name of the species
Exceptions
ModelExceptionif there is a problem.

◆ clearTreeMapParseSettings()

void sortie.data.funcgroups.TreePopulation.clearTreeMapParseSettings ( )

Clears any tree map parse settings that may be in place.

This ensures that grid values do not go to trees.

◆ clearTrees()

void sortie.data.funcgroups.TreePopulation.clearTrees ( )

Clears all trees.

◆ createBehaviorFromParameterFileTag()

Behavior sortie.data.funcgroups.TreePopulation.createBehaviorFromParameterFileTag ( String  sParameterFileTag) throws ModelException

Overridden to not create.

◆ doCopySpecies()

void sortie.data.funcgroups.TreePopulation.doCopySpecies ( String  sCopyFrom,
String  sCopyTo 
) throws ModelException

Makes one species exactly like another.

Any difference from the target species is obliterated. Both species names must already exist (i.e. add a new species before making it into a copy of another). This triggers the change through the other GUI objects.

Parameters
sCopyFromString Name of species to copy.
sCopyToString Name of species that is the copy.
Exceptions
ModelException

◆ doSetup()

void sortie.data.funcgroups.TreePopulation.doSetup ( TreePopulation  oPop) throws ModelException

Overridden to let allometry do setup.

◆ getAllometry()

Allometry sortie.data.funcgroups.TreePopulation.getAllometry ( )

Gets the allometry object.

Returns
Allometry object, or null if none exists.

◆ getBehaviorByXMLParametersParentTag()

Behavior sortie.data.funcgroups.TreePopulation.getBehaviorByXMLParametersParentTag ( String  sXMLTag,
int  iPos 
)

Overridden to ignore position.

◆ getBoolDataCode()

int sortie.data.funcgroups.TreePopulation.getBoolDataCode ( String  sDataMember,
int  iSpecies,
int  iType 
) throws ModelException

Gets the data code for accessing a bool tree data member.

You can use the return code to get the data from a Tree class object. If the data member does not belong to the tree population, it will search enabled behaviors for the data.

Parameters
sDataMemberName of data member.
iSpeciesTree species.
iTypeTree type.
Returns
Data code, or -1 if the data member name is unrecognized.

◆ getCharDataCode()

int sortie.data.funcgroups.TreePopulation.getCharDataCode ( String  sDataMember,
int  iSpecies,
int  iType 
) throws ModelException

Gets the data code for accessing a float tree data member.

You can use the return code to get the data from a Tree class object. If the data member does not belong to the tree population, it will search enabled behaviors for the data.

Parameters
sDataMemberName of data member.
iSpeciesTree species.
iTypeTree type.
Returns
Data code, or -1 if the data member name is unrecognized.

◆ getCodeForDataMember()

int sortie.data.funcgroups.TreePopulation.getCodeForDataMember ( ArrayList< String >  p_oMemberList,
String  sDataMember 
)
protected

Gets the data member code for a data member label.

If this is not a currently listed data member, it will be added.

Parameters
p_oMemberListList of data members.
sDataMemberData member name.
Returns
Data member code.

◆ getFloatDataCode()

int sortie.data.funcgroups.TreePopulation.getFloatDataCode ( String  sDataMember,
int  iSpecies,
int  iType 
) throws ModelException

Gets the data code for accessing a float tree data member.

You can use the return code to get the data from a Tree class object. If the data member does not belong to the tree population, it will search enabled behaviors for the data.

Parameters
sDataMemberName of data member.
iSpeciesTree species.
iTypeTree type.
Returns
Data code, or -1 if the data member name is unrecognized.

◆ getIntDataCode()

int sortie.data.funcgroups.TreePopulation.getIntDataCode ( String  sDataMember,
int  iSpecies,
int  iType 
) throws ModelException

Gets the data code for accessing an int tree data member.

You can use the return code to get the data from a Tree class object. If the data member does not belong to the tree population, it will search enabled behaviors for the data.

Parameters
sDataMemberName of data member.
iSpeciesTree species.
iTypeTree type.
Returns
Data code, or -1 if the data member name is unrecognized.

◆ getNumberOfSizeClasses()

int sortie.data.funcgroups.TreePopulation.getNumberOfSizeClasses ( )

Returns the number of size classes.

Returns
Number of size classes

◆ getNumberOfSpecies()

int sortie.data.funcgroups.TreePopulation.getNumberOfSpecies ( )

Returns the number of species.

Returns
Number of species

◆ getNumberOfTypes()

static int sortie.data.funcgroups.TreePopulation.getNumberOfTypes ( )
static

Get the total number of tree types (life history stages).

Returns
Total number of tree types

◆ getSizeClass()

Float sortie.data.funcgroups.TreePopulation.getSizeClass ( int  iIndex)

Returns the size class at a specific index.

Parameters
iIndexIndex of size class to return.
Returns
Upper limit of size class.

◆ getSpeciesCodeFromName()

int sortie.data.funcgroups.TreePopulation.getSpeciesCodeFromName ( String  sName)

When passed the name of a species, will give back the corresponding species number code.

If there are spaces in the name, they should be replaced with underscores BEFORE being passed.

Parameters
sNameThe name of the species.
Returns
The code, or -1 if the name is not recognized.

◆ getSpeciesNameFromCode()

String sortie.data.funcgroups.TreePopulation.getSpeciesNameFromCode ( int  iSpecies)

For a given species code, returns its name.

If this name is for display, a replace should be done on underscores to spaces.

Parameters
iSpeciesThe species code.
Returns
The species name.

◆ getTreeBehavior()

TreeBehavior sortie.data.funcgroups.TreePopulation.getTreeBehavior ( )

◆ getTrees()

ArrayList<Tree> sortie.data.funcgroups.TreePopulation.getTrees ( )

Gets the list of trees.

Returns
A vector of Tree objects.

◆ getTypeCodeFromName()

static int sortie.data.funcgroups.TreePopulation.getTypeCodeFromName ( String  sName)
static

For a given type name, returns its code.

Parameters
sNameThe type name.
Returns
The type code, or -1 if the name is invalid.

◆ getTypeNameFromCode()

static String sortie.data.funcgroups.TreePopulation.getTypeNameFromCode ( int  iType)
static

For a given type code, returns its name.

Parameters
iTypeThe type code.
Returns
The type name, or an empty string if the code isn't recognized.

◆ readSpecies()

void sortie.data.funcgroups.TreePopulation.readSpecies ( Attributes  oAttributes) throws ModelException

Reads tree species from XML parsing.

Parameters
oAttributesThe attributes of this object.
Exceptions
ModelExceptionif there is a problem reading this data.

◆ readTreeMapSettings()

boolean sortie.data.funcgroups.TreePopulation.readTreeMapSettings ( String  sXMLTag,
Attributes  oAttributes,
Object  oData 
) throws ModelException

Reads tree map settings from XML parsing.

This method is looking for tm_floatCode, tm_intCode, tm_charCode, tm_boolCode, fl, int, ch, and bl. For the last four, they are only set if m_iCurrentSpecies and m_iCurrentTreeType are greater than -1 but will return true in either case. This is so missing values will be ignored without consequence. This depends on grids being read first!

Parameters
sXMLTagXML tag of data object whose value is to be set.
oAttributesThe attributes of this object.
oDataData value appropriate to the data type
Returns
true if the value was set successfully; false if the value could not be found. (This would not be an error, because I need a way to cycle through the objects until one of the objects comes up with a match.)
Exceptions
ModelExceptionif there is a problem reading this data.

◆ readTreeParent()

void sortie.data.funcgroups.TreePopulation.readTreeParent ( Attributes  oAttributes) throws ModelException

Reads tree parent from XML parsing.

Parameters
oAttributesThe attributes of this object.
Exceptions
ModelExceptionif there is a problem reading this data.

◆ readTreeSettings()

void sortie.data.funcgroups.TreePopulation.readTreeSettings ( Attributes  oAttributes) throws ModelException

Reads tree settings from XML parsing.

Parameters
oAttributesThe attributes of this object.
Exceptions
ModelExceptionif there is a problem reading this data.

◆ setSpeciesNames()

void sortie.data.funcgroups.TreePopulation.setSpeciesNames ( String []  p_sVals) throws ModelException

Sets the species name list.

The species vector will be sized to match the array of Strings passed. All spaces in the species names are replaced with underscores.

If there are species currently defined, this calls ChangeOfSpecies() for all objects.

This calls the GUIManager::DoSetup() method so that behavior groups can adjust for the new species list if species were already defined.

This function also declares certain arrays, since this is the first opportunity to know how many species there are.

Parameters
p_sValsA String array of species names.
Exceptions
ModelExceptionif there is a problem setting the species names.

◆ updateTreeDataMembers()

void sortie.data.funcgroups.TreePopulation.updateTreeDataMembers ( ) throws ModelException
private

Update the tree data members for the currently enabled behaviors.

Remove any that no longer apply.

◆ validateData()

void sortie.data.funcgroups.TreePopulation.validateData ( TreePopulation  oPop) throws ModelException

This makes sure all data is valid and can be used to run the model.

Parameters
oPopNot used.
Exceptions
ModelExceptionif there are no species defined.

◆ writeBehaviorNodes()

void sortie.data.funcgroups.TreePopulation.writeBehaviorNodes ( BufferedWriter  out,
TreePopulation  oPop 
) throws ModelException

◆ writeSpeciesList()

void sortie.data.funcgroups.TreePopulation.writeSpeciesList ( BufferedWriter  jOut) throws IOException

Writes the species list.

Parameters
jOutThe XML file to write to.
Exceptions
IOExceptionIf anything goes wrong

◆ writeTreeMap()

void sortie.data.funcgroups.TreePopulation.writeTreeMap ( BufferedWriter  jOut) throws ModelException

Writes an XML tree map if there are any trees to write.

Parameters
jOutThe XML file to write to.
Exceptions
ModelExceptionIf anything goes wrong. This could wrap another exception.
Todo:
subplot support

Member Data Documentation

◆ ADULT

final int sortie.data.funcgroups.TreePopulation.ADULT = 3
static

Adult tree life history stage - matches definition in C++.

◆ m_iCurrentTreeType

int sortie.data.funcgroups.TreePopulation.m_iCurrentTreeType
protected

When parsing tree map settings, the current tree type.

◆ m_iSpeciesCounter

int sortie.data.funcgroups.TreePopulation.m_iSpeciesCounter
protected

Counter for tree map species list when parsing tree map files.

◆ mp_iSpeciesTransforms

int [] sortie.data.funcgroups.TreePopulation.mp_iSpeciesTransforms
protected

When parsing tree maps, this will convert in case the species list is in a different order.

The array index is the code to convert; the value in the array at that point is the corresponding old species number.

◆ mp_iTreeIntTransforms

ArrayList<ArrayList<ArrayList<Integer> > > sortie.data.funcgroups.TreePopulation.mp_iTreeIntTransforms
protected

Index positions for tree integer data members.

The current tree map being read may have different data member indexes, and this will help translate to mp_sTreeIntDataMembers. First index is species, second is type. Vector position equals the data member position in the map being read, and vector value is the position in mp_sTreeIntDataMembers of the data member (and thus the tree index).

◆ mp_oTrees

ArrayList<Tree> sortie.data.funcgroups.TreePopulation.mp_oTrees = new ArrayList<Tree>(0)

Holds Tree objects to be written to a tree map.

◆ mp_sSpeciesNames

ModelVector sortie.data.funcgroups.TreePopulation.mp_sSpeciesNames
private
Initial value:
= new ModelVector("Species names", "", "", 0,
ModelVector.STRING)

List of species names - ignore XML tags since this data can't use the automated XML read-write system.

◆ mp_sTreeIntDataMembers

ArrayList<ArrayList<ArrayList<String> > > sortie.data.funcgroups.TreePopulation.mp_sTreeIntDataMembers

Tree integer data members.

First array index is species, second is type. The vector is a set of strings with the data member names. The position of the String in the vector corresponds to the data member code in the tree map.

◆ SAPLING

final int sortie.data.funcgroups.TreePopulation.SAPLING = 2
static

Sapling tree life history stage - matches definition in C++.

◆ SEED

final int sortie.data.funcgroups.TreePopulation.SEED = 0
static

Seed tree life history stage - matches definition in C++.

◆ SEEDLING

final int sortie.data.funcgroups.TreePopulation.SEEDLING = 1
static

Seedling tree life history stage - matches definition in C++.

◆ SNAG

final int sortie.data.funcgroups.TreePopulation.SNAG = 5
static

Snag tree life history stage - matches definition in C++.

◆ STUMP

final int sortie.data.funcgroups.TreePopulation.STUMP = 4
static

Stump tree life history stage - matches definition in C++.

◆ WOODY_DEBRIS

final int sortie.data.funcgroups.TreePopulation.WOODY_DEBRIS = 6
static

Woody debris tree life history stage - matches definition in C++.


The documentation for this class was generated from the following file: