|
|||||||||
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.Species
This class represents a species.
The ploidy number of a species may not be changed during the species' lifetime.
The name of a species may be changed, although be careful as no notification is done for this change - at least not yet.
An object of this class will generate the following property change events:
EngineProp.DELETED
,
EngineProp.DESCRIPTION
,
EngineProp.DIPLOID_TYPE
,
EngineProp.ID
,
EngineProp.GENOTYPE_TO_PHENOTYPE_RULE_ADDED
,
EngineProp.GENOTYPE_TO_PHENOTYPE_RULE_MOVED
,
EngineProp.GENOTYPE_TO_PHENOTYPE_RULE_REMOVED
,
EngineProp.LOCKED_STATE
,
EngineProp.NAME
,
EngineProp.SPECIES_CHROMOSOME_ADDED
,
EngineProp.SPECIES_CHROMOSOME_REMOVED
,
EngineProp.SPECIES_IMAGE_ADDED
,
EngineProp.SPECIES_IMAGE_REMOVED
,
EngineProp.TRAIT_ADDED
,
EngineProp.TRAIT_REMOVED
,
EngineProp.XXSMALL_IMAGE_COLUMN_WIDTH
,
EngineProp.XXSMALL_IMAGE_ROW_HEIGHT
,
EngineProp.XSMALL_IMAGE_COLUMN_WIDTH
,
EngineProp.XSMALL_IMAGE_ROW_HEIGHT
,
EngineProp.SMALL_IMAGE_COLUMN_WIDTH
,
EngineProp.SMALL_IMAGE_ROW_HEIGHT
,
EngineProp.MEDIUM_IMAGE_COLUMN_WIDTH
,
EngineProp.MEDIUM_IMAGE_ROW_HEIGHT
,
EngineProp.LARGE_IMAGE_COLUMN_WIDTH
,
EngineProp.LARGE_IMAGE_ROW_HEIGHT
,
EngineProp.XLARGE_IMAGE_COLUMN_WIDTH
,
EngineProp.XLARGE_IMAGE_ROW_HEIGHT
,
PropertyChangeListener
, Serialized FormField Summary | |
static int |
DIPLOID_TYPE_NO_SEX_CHROMOSOMES
Third type of diploid species - no sex chromosomes (e.g. |
static java.lang.String |
DIPLOID_TYPE_NO_SEX_CHROMOSOMES_STRING
|
static int |
DIPLOID_TYPE_XX_FEMALE_XY_MALE
One type of diploid species - XX female, XY male (e.g. |
static java.lang.String |
DIPLOID_TYPE_XX_FEMALE_XY_MALE_STRING
|
static int |
DIPLOID_TYPE_XY_FEMALE_XX_MALE
Second type of diploid species - XY female, XX male (e.g. |
static java.lang.String |
DIPLOID_TYPE_XY_FEMALE_XX_MALE_STRING
|
static int |
FEMALE_AND_MALE
Gender values used in defining genotype to phenotype rules, species image columns and species image rows. |
static java.lang.String |
FEMALE_AND_MALE_STRING
|
static int |
FEMALE_ONLY
|
static java.lang.String |
FEMALE_ONLY_STRING
|
static int |
MALE_ONLY
|
static java.lang.String |
MALE_ONLY_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 | |
Species(World aWorld,
java.io.File aFile)
Creates a new species given a world and a species file. |
|
Species(World aWorld,
int aPloidyNumber,
java.lang.String aName)
Creates a new species given a world, ploidy number and name. |
|
Species(World aWorld,
java.lang.String anElementName,
int anElementID,
com.sun.xml.parser.Parser anXMLParser,
ImportContext importContext)
Create a new species and start handling XML parsing events to set the properties of this object. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data. |
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. |
void |
exportTo(java.io.File aFile)
Export this species to a species file. |
java.util.Vector |
getCharacteristicsVector()
Returns a vector of the Characteristics in this species. |
java.lang.String |
getDescription()
Return the description of this species. |
int |
getDiploidType()
Returns diploid type of this species, which may either be DIPLOID_TYPE_XX_FEMALE_XY_MALE, DIPLOID_TYPE_XY_FEMALE_XX_MALE or DIPLOID_TYPE_NO_SEX_CHROMOSOMES. |
java.lang.String |
getDiploidTypeAsString()
Returns diploid type of this species, which may either be DIPLOID_TYPE_XX_FEMALE_XY_MALE, DIPLOID_TYPE_XY_FEMALE_XX_MALE or DIPLOID_TYPE_NO_SEX_CHROMOSOMES. |
Gene |
getGene(java.lang.String aGeneName)
Returns the gene of this species with the given name. |
java.util.Enumeration |
getGenotypeToPhenotypeRules()
Returns an enumeration over the vector of genotype to phenotype rules in this species. |
int |
getImageColumnWidth(int imageSize)
Returns image column width of this species. |
int |
getImageRowHeight(int imageSize)
Returns image row height of this species. |
int |
getIndexOfGenotypeToPhenotypeRule(GenotypeToPhenotypeRule aRule)
Get index of the given genotype to phenotype rule in this species |
java.lang.String |
getName()
Return the name of this species. |
java.util.Enumeration |
getNonSexChromosomes()
Returns an enumeration over the vector of non-sex chromosomes in this species. |
int |
getNumberOfChromosomes()
Return the number of sex and non-sex chromosomes in this species. |
int |
getNumberOfGenes()
Return the number of genes in this species. |
int |
getNumberOfGenotypeToPhenotypeRules()
Return the number of genotype to phenotype rules in this species. |
int |
getNumberOfNonSexChromosomes()
Return the number of non-sex chromosomes in this species. |
int |
getNumberOfSexChromosomes()
Return the number of sex chromosomes in this species. |
int |
getNumberOfSpeciesImages()
Get the number of species images for this species. |
int |
getNumberOfTraits()
Return the number of traits in this species. |
int |
getPloidyNumber()
Returns ploidy number of this species, which may either be 1 (haploid), 2 (diploid) or 3 (haploid and diploid - e.g. |
java.util.Enumeration |
getSexChromosomes()
Returns an enumeration over the vector of sex chromosomes in this species. |
java.util.Vector |
getSpeciesAllelesVector()
Returns a vector of the SpeciesAlleles in this species. |
java.util.Enumeration |
getSpeciesImages()
Returns an enumeration over the vector of species images in this species. |
java.util.Enumeration |
getTraits()
Returns an enumeration over the vector of traits in this species. |
World |
getWorld()
Return the world containing this species. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable white space character data. |
void |
moveGenotypeToPhenotypeRuleAfter(GenotypeToPhenotypeRule aRuleToMove,
GenotypeToPhenotypeRule aRuleAfter)
Move the given genotype to phenotype rule immediately after the second rule. |
void |
moveGenotypeToPhenotypeRuleDown(GenotypeToPhenotypeRule aRule)
Move the given genotype to phenotype rule down one position in the list of rules for this species. |
void |
moveGenotypeToPhenotypeRuleUp(GenotypeToPhenotypeRule aRule)
Move the given genotype to phenotype rule up one position in the list of rules for this species. |
java.util.Vector |
parseAlleleString(int sex,
java.lang.String allelesString)
Parse an allele string to create a ChromosomeSpecification |
void |
propertyChange(java.beans.PropertyChangeEvent event)
Handle property change events |
void |
setAutomaticLocked(boolean automaticLocked)
Set or unset the automatic locked state of this object, leaving other components of the locked state untouched. |
void |
setDescription(java.lang.String aDescription)
Set the description of this species. |
void |
setDiploidType(int aDiploidType)
Set the diploid type of this species, which may either be DIPLOID_TYPE_XX_FEMALE_XY_MALE, DIPLOID_TYPE_XY_FEMALE_XX_MALE or DIPLOID_TYPE_NO_SEX_CHROMOSOMES. |
void |
setDiploidTypeAsString(java.lang.String aDiploidTypeString)
Set the diploid type of this species, which may either be DIPLOID_TYPE_XX_FEMALE_XY_MALE, DIPLOID_TYPE_XY_FEMALE_XX_MALE or DIPLOID_TYPE_NO_SEX_CHROMOSOMES. |
void |
setImageColumnWidth(int imageSize,
int anImageColumnWidth)
Set the image column width of a particular image size for this species. |
void |
setImageRowHeight(int imageSize,
int anImageRowHeight)
Set the image row height of a particular image size for this species. |
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 species. |
void |
setPloidyNumber(int newPloidyNumber)
Set the ploidy number, which must be 1 or 2. |
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 |
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 DIPLOID_TYPE_XX_FEMALE_XY_MALE
public static final java.lang.String DIPLOID_TYPE_XX_FEMALE_XY_MALE_STRING
public static final int DIPLOID_TYPE_XY_FEMALE_XX_MALE
public static final java.lang.String DIPLOID_TYPE_XY_FEMALE_XX_MALE_STRING
public static final int DIPLOID_TYPE_NO_SEX_CHROMOSOMES
public static final java.lang.String DIPLOID_TYPE_NO_SEX_CHROMOSOMES_STRING
public static final int FEMALE_AND_MALE
public static final java.lang.String FEMALE_AND_MALE_STRING
public static final int FEMALE_ONLY
public static final java.lang.String FEMALE_ONLY_STRING
public static final int MALE_ONLY
public static final java.lang.String MALE_ONLY_STRING
Constructor Detail |
public Species(World aWorld, int aPloidyNumber, java.lang.String aName)
A species is initially created with no genes. Genes can be added by creating genes and specifying the species in the gene.
aWorld
- World - a world containing this speciesaPloidyNumber
- int - ploidy number, must be 1 or 2aName
- String - name of this organism, may not be nullanImageColumnWidth
- int - width of image columns, must be >= 0anImageRowHeight
- int - height of image rows, must be >= 0java.lang.IllegalArgumentException
- - input argument(s) illegalpublic Species(World aWorld, java.io.File aFile)
aWorld
- World - a world containing this speciesaFile
- File - a species filejava.lang.IllegalArgumentException
- - input argument(s) illegalpublic Species(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 java.util.Vector parseAlleleString(int sex, java.lang.String allelesString)
The allele string contains sequences like "a:H,b:h,b:W" where the "a" or "b" on the left side of the colon specifies which of the chromosome pair is affected and the string on the right side of the colon specifies the allele. Spaces are significant in allele names, so there should be no spaces anywhere in the specification string except for in the name, if necessary.
For sex chromosomes, the "a" and "b" on the left sides of the colon are significant only when there are 2 X chromosomes. Otherwise "a" must be used for both X and Y chromosome alleles. "b" will be ignored if there is only one X and one Y chromosome.
Finally, when there are X and Y chromosomes, the chromosome that is created first is always random and cannot be specified.
sex
- int - specifies sex, overrides string if inconsistentallelesString
- String - string specification of the allelesjava.lang.IllegalArgumentException
- - input argument(s) illegalpublic void delete()
When this method is called, a property change event is generated for the property named EngineProp.DELETED.
delete
in class EngineObject
ObjectLockedException
- - object is locked and cannot be deletedpublic void delete(boolean notifyChange)
public void exportTo(java.io.File aFile)
aFile
- File - a species filepublic java.lang.String toString()
toString
in class EngineObject
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 int getPloidyNumber()
public void setPloidyNumber(int newPloidyNumber)
Once a species has chromosomes, its ploidy number may not be changed.
newPloidyNumber
- int - new ploidy number (1 or 2)InternalEngineException
- - ploidy number illegal or species ploidy cannot be changedObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be deletedpublic int getDiploidType()
public final java.lang.String getDiploidTypeAsString()
public void setDiploidType(int aDiploidType)
aDiploidType
- int - new diploid typeInternalEngineException
- - diploid type illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be deletedpublic void setDiploidTypeAsString(java.lang.String aDiploidTypeString)
aDiploidTypeString
- String - new diploid type as a stringInternalEngineException
- - diploid type illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be deletedpublic int getImageColumnWidth(int imageSize)
imageSize
- int - image size (e.g. SMALL_IMAGE_SIZE, etc.)public void setImageColumnWidth(int imageSize, int anImageColumnWidth)
imageSize
- - the image size being set (e.g. SpeciesImage.XSMALL_IMAGE_SIZE)anImageColumnWidth
- int - the new image column width of species, must be >= 0InternalEngineException
- - diploid type illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be deletedpublic int getImageRowHeight(int imageSize)
imageSize
- int - image size (e.g. SMALL_IMAGE_SIZE, etc.)public void setImageRowHeight(int imageSize, int anImageRowHeight)
imageSize
- - the image size being set (e.g. XSMALL_IMAGE_SIZE)anImageRowHeight
- int - the new image row height of species, must be >= 0InternalEngineException
- - diploid type illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be deletedpublic World getWorld()
getWorld
in class EngineObject
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 - the new name of this species, may not be nulljava.lang.IllegalArgumentException
- - input argument illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be modifiedpublic java.lang.String getDescription()
public void setDescription(java.lang.String aDescription)
When this method is successful, a property change event is fired for the property named EngineProp.DESCRIPTION.
aDescription
- String - the new description of this species, may not be nulljava.lang.IllegalArgumentException
- - input argument illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be modifiedpublic 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 getNumberOfNonSexChromosomes()
public java.util.Enumeration getSexChromosomes()
public int getNumberOfSexChromosomes()
public int getNumberOfChromosomes()
public Gene getGene(java.lang.String aGeneName)
aGeneName
- String - the name of the gene to find, if null then this method returns nullpublic java.util.Enumeration getTraits()
The vector of traits is cloned and the enumeration is created for the clone, so it is safe to modify the vector of traits (by creating new ones, moving them around, etc.) while using this returned enumeration.
public int getNumberOfTraits()
public void moveGenotypeToPhenotypeRuleAfter(GenotypeToPhenotypeRule aRuleToMove, GenotypeToPhenotypeRule aRuleAfter)
aRuleToMove
- GenotypeToPhenotypeRule - the rule to moveaRuleAfter
- GenotypeToPhenotypeRule - the rule to move the first rule immediately afterjava.lang.IllegalArgumentException
- - input rule nullpublic void moveGenotypeToPhenotypeRuleUp(GenotypeToPhenotypeRule aRule)
aRule
- GenotypeToPhenotypeRule - the rule to move up onejava.lang.IllegalArgumentException
- - input rule nullpublic void moveGenotypeToPhenotypeRuleDown(GenotypeToPhenotypeRule aRule)
aRule
- GenotypeToPhenotypeRule - the rule to move down onejava.lang.IllegalArgumentException
- - input rule nullpublic int getIndexOfGenotypeToPhenotypeRule(GenotypeToPhenotypeRule aRule)
aRule
- GenotypeToPhenotypeRule - the given genotype to phenotype rulejava.lang.IllegalArgumentException
- - input rule nullpublic java.util.Enumeration getGenotypeToPhenotypeRules()
The vector of rules is cloned and the enumeration is created for the clone, so it is safe to modify the vector of rules (by creating new ones, moving them around, etc.) while using this returned enumeration.
public int getNumberOfGenotypeToPhenotypeRules()
public java.util.Enumeration getSpeciesImages()
public int getNumberOfSpeciesImages()
public int getNumberOfGenes()
This is a convenience routine, as the genes are actually not stored directly in the species, but instead off of their chromosomes. So all this method does is walk through the chromosomes adding up their genes to arrive at a total count.
public java.util.Vector getCharacteristicsVector()
This is a convenience routine, as anyone could also create this vector themselves by getting all the traits in this species and then asking each trait for its characteristics, etc.
public java.util.Vector getSpeciesAllelesVector()
This is a convenience routine, as anyone could also create this vector themselves by getting all the Chromosomes, Genes and then Alleles in this species, etc.
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 propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- PropertyChangeEvent - the property change event
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |