|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xml.sax.HandlerBase | +--org.concord.biologica.engine.EngineObject | +--org.concord.biologica.engine.Organism
This class represents an organism. At the moment, all organisms should be modeled using this class - haploid, diploid, plants, mammals, etc. Perhaps in the future we'll create subclasses of this class as necessary.
For now, the name, color and ploidy number of an organism may not be modified during the organism's lifetime. We can relax this if necessary later.
An organism actually has two possible 'states'. In the default state, the organism knows what genes it contains but the actual chromosome and DNA objects embodying those genes are not created. In this default state, the genes are stored directly and chromosomes are not created. This default state is faster, uses less storage and is simpler for most cases, especially the population level. In the non-default, or full, state the organism's chromosome and DNA objects are created and correctly include the genes. This level of detail is only needed when the organism's DNA level is opened.
An object of this class will generate the following property change events:
EngineProp.ALLELES_ALTERABLE
,
EngineProp.ALLELES_VISIBLE
,
EngineProp.CHARACTERISTIC_ADDED
,
EngineProp.CHARACTERISTIC_REMOVED
,
EngineProp.DELETED
,
EngineProp.DNA_ALTERABLE
,
EngineProp.DNA_VISIBLE
,
EngineProp.ID
,
EngineProp.LOCKED_STATE
,
EngineProp.NAME
,
EngineProp.NAME_SUPER_VISIBLE
,
EngineProp.ORGANISM_CHROMOSOME_ADDED
,
EngineProp.ORGANISM_CHROMOSOME_REMOVED
,
EngineProp.ORGANISM_GENOTYPE_AND_NOT_PHENOTYPE
,
EngineProp.ORGANISM_GENOTYPE_AND_PHENOTYPE
,
EngineProp.ORGANISM_IMAGE_ADDED
,
EngineProp.ORGANISM_IMAGE_REMOVED
,
EngineProp.SEX
,
EngineProp.SPECIES
,
EngineProp.VISIBLE
,
PropertyChangeListener
, Serialized FormField Summary | |
static int |
FEMALE
|
static java.lang.String |
FEMALE_STRING
|
static int |
MALE
Sex values |
static java.lang.String |
MALE_STRING
|
static int |
NO_SEX
|
static java.lang.String |
NO_SEX_STRING
|
Fields inherited from class org.concord.biologica.engine.EngineObject |
AUTOMATIC_LOCKED, AUTOMATIC_LOCKED_STRING, changes, deleted, FALSE, id, lockedState, MANUAL_AND_AUTOMATIC_LOCKED, MANUAL_AND_AUTOMATIC_LOCKED_STRING, MANUAL_LOCKED, MANUAL_LOCKED_STRING, NULL_ID, TRUE, UNLOCKED, UNLOCKED_STRING, xmlElementContext |
Constructor Summary | |
Organism(Organism aParentOne,
Organism aParentTwo,
java.lang.String aName)
Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome. |
|
Organism(Organism aParentOne,
Organism aParentTwo,
java.lang.String aName,
boolean crossingOver)
|
|
Organism(Organism aParentOne,
Organism aParentTwo,
java.lang.String aName,
int aSex)
Creates a new organism from 2 parents, randomly choosing the parent chromosome from which to copy alleles for each child chromosome. |
|
Organism(Organism aParentOne,
Organism aParentTwo,
java.lang.String aName,
int aSex,
boolean crossingOver)
|
|
Organism(World aWorld,
int aSex,
java.lang.String aName,
Species aSpecies)
Creates a new organism of the specified sex, randomly choosing the alleles of the chromosomes. |
|
Organism(World aWorld,
java.lang.String anElementName,
int anElementID,
com.sun.xml.parser.Parser anXMLParser,
ImportContext importContext)
Create a new organism and start handling XML parsing events to set the properties of this object. |
|
Organism(World aWorld,
java.lang.String aName,
int aPloidyNumber,
Species aSpecies)
Creates a new organism in the given world from a species definition, randomly choosing the sex and genetic makeup of the organism. |
|
Organism(World aWorld,
java.lang.String aName,
Species aSpecies,
int aSex,
java.lang.String alleles)
Creates a new organism of the specified species using the given allele string to create the correct alleles. |
|
Organism(World aWorld,
java.lang.String aName,
Species aSpecies,
Organism mother,
Organism father,
java.util.Vector chromosomeSpecifications)
Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles. |
|
Organism(World aWorld,
java.lang.String aName,
Species aSpecies,
java.util.Vector chromosomeSpecifications)
Creates a new organism of the specified species using the given ChromosomeSpecification objects to create the correct alleles. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data. |
java.lang.String[] |
compareCharacteristics(Organism organism)
|
boolean |
containsCharacteristic(Characteristic aCharacteristic)
Returns true or false on whether this organism contains the given characteristic. |
boolean |
containsCharacteristic(java.lang.String aCharacteristicName)
Returns true or false on whether this organism contains the a characteristic with the given name. |
boolean |
containsFatalCharacteristic()
Returns true or false on whether this organism contains a fatal characteristic. |
void |
delete()
Delete this object, notifying parent objects and deleting any child objects. |
void |
delete(boolean notifyChange)
|
void |
endElement(java.lang.String anElementName)
Handle notification that the parsing of the given element has ended. |
OrganismAllelePair |
findAllelePair(OrganismAllele allele)
Find an organism allele pair given an organism allele |
OrganismAllele |
findOrganismAllele(java.util.Vector alleles,
java.lang.String alleleText)
|
Characteristic |
getCharacteristicOfTrait(java.lang.String aTraitName)
Returns the characteristic of a trait of the given name for this organism. |
Characteristic |
getCharacteristicOfTrait(Trait aTrait)
Returns the characteristic of a given trait for this organism. |
java.util.Enumeration |
getCharacteristics()
Returns an enumeration over the vector of characteristics of this organism. |
java.util.Enumeration |
getChildFamilies()
Returns an enumeration over the vector of child families in this organism. |
Branch[] |
getChromosomePaintInfo()
|
java.util.Enumeration |
getChromosomes()
Returns an enumeration over the vector of all chromosomes, sex and non-sex, in this organism. |
OrganismAllele |
getGeneOrganismAllele(Gene gene,
java.lang.String alleleText)
Get an organism allele in this organism that has the given gene and with the given allele symbol |
OrganismAllele |
getGeneOrganismAllele(java.lang.String geneName,
java.lang.String alleleText)
Get an organism allele in this organism that has the gene with the given name and with the given allele symbol |
java.util.Vector |
getGeneOrganismAlleles(Gene aGene)
Get a vector of organism alleles in this organism for the given gene. |
java.util.Vector |
getGeneOrganismAlleles(java.lang.String aGeneName)
Get a vector of organism alleles in this organism for the gene with the given name. |
int |
getGeneration()
Get the generation of this organism. |
java.lang.String |
getName()
Return the name of this organism. |
java.util.Enumeration |
getNonSexChromosomes()
Returns an enumeration over the vector of non-sex chromosomes in this organism. |
int |
getNumberOfCharacteristics()
Return the number of characteristics of this organism. |
int |
getNumberOfChildFamilies()
Return the number of child families in this organism. |
int |
getNumberOfChromosomes()
Get the number of chromosomes, both sex and non-sex. |
int |
getNumberOfNonSexChromosomes()
Return the number of non-sex chromosomes in this organism. |
int |
getNumberOfOrganismChromosomePairs()
Get the number of organism chromosome pairs, both sex and non-sex. |
int |
getNumberOfOrganismImages()
Return the number of organism images in this organism. |
int |
getNumberOfSexChromosomes()
Return the number of sex chromosomes in this organism. |
java.util.Enumeration |
getOrganismChromosomePairs()
Returns an enumeration over the vector of all organism chromosome pairs in this organism. |
java.util.Enumeration |
getOrganismImages()
Returns an enumeration over the vector of organism images in this organism. |
Family |
getParentFamily()
Get the parent family for this organism. |
int |
getPloidyNumber()
Returns ploidy number of this organism. |
int |
getSex()
Get the sex of this organism. |
java.lang.String |
getSexAsString()
Get the sex of this organism as a string. |
java.util.Enumeration |
getSexChromosomes()
Returns an enumeration over the vector of sex chromosomes in this organism. |
Species |
getSpecies()
Return the species of this organism, if it is known. |
World |
getWorld()
Return the world containing this organism. |
boolean |
hasCharacteristics(java.lang.String[] characteristics,
java.lang.String[] traits)
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable white space character data. |
boolean |
isAllelesAlterable()
Get whether this organism's alleles are visible. |
boolean |
isAllelesVisible()
Get whether this organism's alleles are visible. |
boolean |
isDNAAlterable()
Get whether this organism's DNA is alterable. |
boolean |
isDNAVisible()
Get whether this organism's DNA is visible. |
boolean |
isNameSuperVisible()
Get whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general. |
boolean |
isParentCrossOver()
|
boolean |
isVisible()
Get whether this organism is visible. |
void |
setAllele(int aChromosomeAorB,
java.lang.String aGeneName,
java.lang.String aNewAlleleTextSymbol)
Set an allele text symbol of an allele of the given gene on the given chromosome. |
void |
setAllelesAlterable(boolean TorF)
Set whether this organism's alleles are alterable. |
void |
setAllelesVisible(boolean TorF)
Set whether this organism's alleles are visible. |
void |
setAutomaticLocked(boolean automaticLocked)
Set or unset the automatic locked state of this object, leaving other components of the locked state untouched. |
void |
setChromosomePaintInfo(Branch[] v)
|
void |
setDNAAlterable(boolean TorF)
Set whether this organism's DNA is visible. |
void |
setDNAVisible(boolean TorF)
Set whether this organism's DNA is visible. |
void |
setLockedState(int aLockedState)
Set the lock state of the object, recursively setting the lock state of children objects. |
void |
setManualLocked(boolean manualLocked)
Set or unset the manual locked state of this object, leaving other components of the locked state untouched. |
void |
setName(java.lang.String aName)
Set the name of this organism. |
void |
setNameSuperVisible(boolean TorF)
Set whether this organism's name is super visible, meaning that the name should be shown even when a view isn't showing names in general. |
void |
setParentCrossOver(boolean bln)
|
void |
setParentFamily(Family aFamily)
Set the parent family for this organism. |
void |
setSpecies(Species aSpecies)
Set the species of this organism. |
void |
setVisible(boolean TorF)
Set whether this organism is visible. |
void |
startElement(java.lang.String anElementName,
org.xml.sax.AttributeList amap)
Handle notification that the parser has hit the start of a new element with the given name and attributes. |
java.lang.String |
toString()
Return a string representation of this object, usually the object's name. |
void |
updateGenotypeAndPhenotype(boolean notify)
Update the genotype and phenotype of this organism. |
void |
writeToStream(java.io.PrintWriter stream)
Writes this object to the given stream in XML format. |
Methods inherited from class org.concord.biologica.engine.EngineObject |
addPropertyChangeListener, getID, getLockedState, getLockedStateAsString, isAutomaticLocked, isDeleted, isLocked, isManualLocked, notifySelected, release, removePropertyChangeListener, setID, setLockedStateAsString |
Methods inherited from class org.xml.sax.HandlerBase |
endDocument, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MALE
public static final java.lang.String MALE_STRING
public static final int FEMALE
public static final java.lang.String FEMALE_STRING
public static final int NO_SEX
public static final java.lang.String NO_SEX_STRING
Constructor Detail |
public Organism(World aWorld, java.lang.String aName, int aPloidyNumber, Species aSpecies)
The new organism will randomly choose a genotype using the species definition.
aWorld
- World - a world containing this speciesaPloidyNumber
- int - ploidy number, must be 1 or 2aSpecies
- Species - species of this organism, may be nullaName
- String - name of this organism, may be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName)
The 2 parents must both be non-null, of opposite sexes of the same species and in the same world. Ploidy number must be two.
aParentOne
- Organism - one of the parents, may not be nullaParentTwo
- Organism - the other of the parents, may not be nullaName
- String - name of this organism, may be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, boolean crossingOver)
public Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, int aSex)
The 2 parents must both be non-null, of opposite sexes of the same species and in the same world. Ploidy number must be two.
This version is different from the above version in that you specify the sex of the child in this version.
aParentOne
- Organism - one of the parents, may not be nullaParentTwo
- Organism - the other of the parents, may not be nullaName
- String - name of this organism, may be nullaSex
- int - sex of organism (MALE or FEMALE)java.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(Organism aParentOne, Organism aParentTwo, java.lang.String aName, int aSex, boolean crossingOver)
public Organism(World aWorld, int aSex, java.lang.String aName, Species aSpecies)
The new organism will randomly choose a genotype using the species definition.
aWorld
- World - a world containing this speciesaSex
- int - either Organism.MALE, Organism.FEMALE or Organism.NO_SEXaName
- String - name of this organism, may be null which will cause one to be assignedaSpecies
- Species - species of this organism, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(World aWorld, java.lang.String aName, Species aSpecies, java.util.Vector chromosomeSpecifications)
No family is created. Use the next constructor if you also want a family to be created.
aWorld
- World - a world containing this speciesaName
- String - name of this organism, may be null which will cause one to be assignedaSpecies
- Species - species of this organism, may not be nullchromosomeSpecifications
- Vector - vector of chromosome specifications, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(World aWorld, java.lang.String aName, Species aSpecies, Organism mother, Organism father, java.util.Vector chromosomeSpecifications)
Also creates a new family, making this organism a child of the input mother and father. If you don't want a family created, use the constructor above.
If either mother or father is null, no family is created.
aWorld
- World - a world containing this speciesaName
- String - name of this organism, may be null which will cause one to be assignedaSpecies
- Species - species of this organism, may not be nullaMother
- Organism - a mother organism for this child organismaFather
- Organism - a father organism for this child organismchromosomeSpecifications
- Vector - vector of chromosome specifications, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(World aWorld, java.lang.String aName, Species aSpecies, int aSex, java.lang.String alleles)
No family is created. Use the next constructor if you also want a family to be created.
aWorld
- World - a world containing this speciesaName
- String - name of this organism, may be null which will cause one to be assignedaSpecies
- Species - species of this organism, may not be nullaSex
- int - the sex of the organismalleles
- String - string of allele symbol specifications, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Organism(World aWorld, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
aWorld
- World - the enclosing world for this new speciesanElementName
- String - the element nameanElementID
- int - the element idanXMLParser
- com.sun.xml.parser.Parser - the element parserimportContext
- ImportContext - import context for mapping ids from file to this worldjava.lang.IllegalArgumentException
- - input arguments illegalMethod Detail |
public void startElement(java.lang.String anElementName, org.xml.sax.AttributeList amap) throws org.xml.sax.SAXException
For internal elements (elements that are non-EngineObject instance variables of this object), call xmlElementContext.startElement() and xmlElementContext will receive the remaining element notifications. For external elements (elements that are EngineObject instance variables of this object), create an object of the appropriate class and that object will receive the remaining element notifications.
startElement
in class org.xml.sax.HandlerBase
anElementName
- String - name of elementamap
- AttributeList - an attribute listpublic void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in class org.xml.sax.HandlerBase
ch
- char[] - charactersstart
- int - start of stringlength
- int - length of stringpublic void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in class org.xml.sax.HandlerBase
ch
- char[] - charactersstart
- int - start of stringlength
- int - length of stringpublic void endElement(java.lang.String anElementName) throws org.xml.sax.SAXException
endElement
in class org.xml.sax.HandlerBase
anElementName
- String - the element namepublic void delete()
When this method is called, a property change event is generated for the property named EngineProp.DELETED.
delete
in class EngineObject
public void delete(boolean notifyChange)
public void setAutomaticLocked(boolean automaticLocked)
When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.
setAutomaticLocked
in class EngineObject
automaticLocked
- boolean - object should be automatic locked (true) or not (false)public void setManualLocked(boolean manualLocked)
When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.
setManualLocked
in class EngineObject
manualLocked
- boolean - object should be manually locked (true) or not (false)public void setLockedState(int aLockedState)
When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.
setLockedState
in class EngineObject
aLockedState
- int - new locked state of this objectjava.lang.IllegalArgumentException
- - new locked state invalidpublic java.lang.String toString()
toString
in class EngineObject
public void updateGenotypeAndPhenotype(boolean notify)
In concrete terms, this means: - Gather all the alleles of this organism in a Vector. - Loop through the species' genotype to phenotype rules determining which rules should fire for this organism. The rules use the alleles gathered in the previous step and produce characteristics for this organism. - Loop through the organismImages of this organism, asking each organismImage to update itself to reflect the current characteristics of this organism. At the end of this process, the organismImage objects for this organism will be updated and all ready to be called when the organism needs to be drawn.
notify
- boolean - notify listeners that genotype and/or phenotype changed?public boolean isVisible()
public void setVisible(boolean TorF)
TorF
- boolean - visible (true) or not visible (false)public boolean isNameSuperVisible()
public void setNameSuperVisible(boolean TorF)
TorF
- boolean - name visible (true) or not visible (false)public boolean isAllelesVisible()
public void setAllelesVisible(boolean TorF)
TorF
- boolean - visible (true) or not visible (false)public boolean isDNAVisible()
public void setDNAVisible(boolean TorF)
TorF
- boolean - visible (true) or not visible (false)public boolean isAllelesAlterable()
public void setAllelesAlterable(boolean TorF)
TorF
- boolean - alterable (true) or not alterable (false)public boolean isDNAAlterable()
public void setDNAAlterable(boolean TorF)
TorF
- boolean - visible (true) or not visible (false)public int getPloidyNumber()
public java.lang.String getName()
public void setName(java.lang.String aName)
When this method is successful, a property change event is fired for the property named EngineProp.NAME.
aName
- String - new name, may not be nulljava.lang.IllegalArgumentException
- - input arguments illegalpublic Species getSpecies()
public void setSpecies(Species aSpecies)
When this method is successful, a property change event is fired for the property named EngineProp.SPECIES.
aSpecies
- Species - the new species of this organism, may be nulljava.lang.IllegalArgumentException
- - input argument illegalpublic World getWorld()
getWorld
in class EngineObject
public int getNumberOfNonSexChromosomes()
public java.util.Enumeration getNonSexChromosomes()
The vector of non-sex chromosomes is cloned and the enumeration is created for the clone, so it is safe to modify the vector of chromosomes (by creating new ones, moving them around, etc.) while using this returned enumeration.
public int getNumberOfSexChromosomes()
public java.util.Enumeration getSexChromosomes()
The vector of sex chromosomes is cloned and the enumeration is created for the clone, so it is safe to modify the vector of chromosomes (by creating new ones, moving them around, etc.) while using this returned enumeration.
public int getNumberOfChromosomes()
public java.util.Enumeration getChromosomes()
public int getNumberOfOrganismChromosomePairs()
public java.util.Enumeration getOrganismChromosomePairs()
public java.util.Vector getGeneOrganismAlleles(Gene aGene)
aGene
- Gene - a gene, if null then an empty vector is returnedpublic java.util.Vector getGeneOrganismAlleles(java.lang.String aGeneName)
aGeneName
- String - a name of a gene, if null then an empty vector is returnedpublic OrganismAllele findOrganismAllele(java.util.Vector alleles, java.lang.String alleleText)
public OrganismAllele getGeneOrganismAllele(java.lang.String geneName, java.lang.String alleleText)
geneName
- String - a name of a gene, if null then null is returnedalleleText
- String - an allele symbol, if null then null returnedpublic OrganismAllele getGeneOrganismAllele(Gene gene, java.lang.String alleleText)
gene
- Gene - a gene, if null then null is returnedalleleText
- String - an allele symbol, if null then null returnedpublic OrganismAllelePair findAllelePair(OrganismAllele allele)
allele
- OrganismAllele - an allele , if null then null returnedpublic boolean hasCharacteristics(java.lang.String[] characteristics, java.lang.String[] traits)
public void setAllele(int aChromosomeAorB, java.lang.String aGeneName, java.lang.String aNewAlleleTextSymbol)
aChromosomeAorB
- int - chromosome (IChromosome.A_CHROMOSOME or IChromosome.B_CHROMOSOME)aGeneName
- String - the gene name (e.g. "Horns"), may not be nullaNewAlleleTextSymbol
- String - new allele text symbol (e.g. "H"), may not be nullpublic int getSex()
public java.lang.String getSexAsString()
public int getNumberOfOrganismImages()
public java.util.Enumeration getOrganismImages()
public boolean containsFatalCharacteristic()
public boolean containsCharacteristic(Characteristic aCharacteristic)
aCharacteristic
- Characteristic - a characteristic to look for, if null then false is returnedpublic boolean containsCharacteristic(java.lang.String aCharacteristicName)
aCharacteristicName
- String - a characteristic name to look for, if null then false is returnedpublic Characteristic getCharacteristicOfTrait(Trait aTrait)
aTrait
- Trait - a trait, if null then null is returnedpublic Characteristic getCharacteristicOfTrait(java.lang.String aTraitName)
aTraitName
- String - a trait name, if null then null is returnedpublic java.util.Enumeration getCharacteristics()
public java.lang.String[] compareCharacteristics(Organism organism)
public int getNumberOfCharacteristics()
public Family getParentFamily()
public void setParentFamily(Family aFamily)
aFamily
- Family - the new parent family of this organism, may be nullpublic int getNumberOfChildFamilies()
public java.util.Enumeration getChildFamilies()
public int getGeneration()
public void writeToStream(java.io.PrintWriter stream) throws java.io.IOException
We could supply a default implementation that knows how to write the id value. But that convenience is not chosen because it's never correct to use just this implementation of these methods, so I'd rather have a compilation fail if a derived class fails to implement this method.
The inverse of this method is a constructor that takes a org.xml.sax.Parser argument and other arguments.
writeToStream
in class EngineObject
stream
- PrintWriter - print streamjava.lang.IllegalArgumentException
- - input arguments illegaljava.io.IOException
- - an IO error occurred in java librariespublic void setParentCrossOver(boolean bln)
public boolean isParentCrossOver()
public void setChromosomePaintInfo(Branch[] v)
public Branch[] getChromosomePaintInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |