org.concord.biologica.engine
Class Characteristic

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--org.concord.biologica.engine.EngineObject
              |
              +--org.concord.biologica.engine.Characteristic
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, java.io.Serializable

public final class Characteristic
extends EngineObject
implements java.io.Serializable

This class represents a characteristic of a trait of a species.

A trait is defined as a specific property of an organism. The term "trait" is a synonym for "characteristic" and "character".

A characteristic is really a characteristic and is a single possible trait value.

Examples of traits are "flower color", "horn type", "tail type", etc. For each trait, there are a set of characteristics for that trait - "purple" and "white" for flower color, "no horns" and "2 horns" for horn type, etc.

An object of this class will generate the following property change events:

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:11 $
Author:
$Author: ed $
See Also:
EngineProp.DELETED, EngineProp.ID, EngineProp.LOCKED_STATE, EngineProp.NAME, EngineProp.PEDIGREE_SYMBOL_TYPE, EngineProp.PEDIGREE_SYMBOL_FIRST_COLOR, EngineProp.PEDIGREE_SYMBOL_SECOND_COLOR, EngineProp.FATAL, PropertyChangeListener, Serialized Form

Field Summary
static int PEDIGREE_SYMBOL_FORWARD_SLASH
           
static java.lang.String PEDIGREE_SYMBOL_FORWARD_SLASH_STRING
           
static int PEDIGREE_SYMBOL_SOLID_COLOR
          Pedigree symbol type values, used to determine how to draw pedigree symbols.
static java.lang.String PEDIGREE_SYMBOL_SOLID_COLOR_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
Characteristic(Trait aTrait, java.lang.String aName, int anImageID)
          Creates a new characteristic with the given name.
Characteristic(Trait aTrait, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new Characteristic 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.
 int getImageID()
          Return the image ID of this characteristic.
 java.lang.String getName()
          Return the name of this characteristic.
 java.awt.Color getPedigreeSymbolFirstColor()
          Get the first pedigree symbol color of this characteristic.
 java.awt.Color getPedigreeSymbolSecondColor()
          Get the second pedigree symbol color of this characteristic.
 int getPedigreeSymbolType()
          Get the pedigree symbol type of this characteristic.
 java.lang.String getPedigreeSymbolTypeAsString()
          Get the pedigree symbol type of this characteristic as a string
 Species getSpecies()
          Get the species containing this object.
 Trait getTrait()
          Return the trait of this characteristic.
 World getWorld()
          Get the world containing this object.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 boolean isFatal()
          Return the fatality of this characteristic.
 void setFatal(boolean aFatal)
          Set the fatality of this characteristic.
 void setImageID(int anImageID)
          Set the image ID of this characteristic.
 void setName(java.lang.String aName)
          Set the name of this characteristic.
 void setPedigreeSymbolFirstColor(java.awt.Color aColor)
          Set the first pedigree symbol color of this characteristic
 void setPedigreeSymbolSecondColor(java.awt.Color aColor)
          Set the second pedigree symbol color of this characteristic
 void setPedigreeSymbolType(int aSymbolType)
          Set the first pedigree symbol type of this characteristic
 void setPedigreeSymbolTypeAsString(java.lang.String aSymbolTypeString)
          Set the first pedigree symbol type of this characteristic, using a string as input.
 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, setAutomaticLocked, setID, setLockedState, setLockedStateAsString, setManualLocked
 
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

PEDIGREE_SYMBOL_SOLID_COLOR

public static final int PEDIGREE_SYMBOL_SOLID_COLOR
Pedigree symbol type values, used to determine how to draw pedigree symbols. PEDIGREE_SYMBOL_SOLID_COLOR means the square or circle is one solid color (pedigreeSymbolFirstColor). PEDIGREE_SYMBOL_FORWARD_SLASH means the square or circle has a diagonal line through its middle with a top color (pedigreeSymbolFirstColor) and a bottom color (pedigreeSymbolSecondColor).


PEDIGREE_SYMBOL_SOLID_COLOR_STRING

public static final java.lang.String PEDIGREE_SYMBOL_SOLID_COLOR_STRING

PEDIGREE_SYMBOL_FORWARD_SLASH

public static final int PEDIGREE_SYMBOL_FORWARD_SLASH

PEDIGREE_SYMBOL_FORWARD_SLASH_STRING

public static final java.lang.String PEDIGREE_SYMBOL_FORWARD_SLASH_STRING
Constructor Detail

Characteristic

public Characteristic(Trait aTrait,
                      java.lang.String aName,
                      int anImageID)
Creates a new characteristic with the given name.

Parameters:
aTrait - Trait - the trait containing this characteristic, may not be null
aName - String - name of this characteristic, may not be null
anImageID - int - id of an image (e.g. a DIB id), may be any int value
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Characteristic

public Characteristic(Trait aTrait,
                      java.lang.String anElementName,
                      int anElementID,
                      com.sun.xml.parser.Parser anXMLParser,
                      ImportContext importContext)
Create a new Characteristic and start handling XML parsing events to set the properties of this object.

Parameters:
aTrait - Trait - the enclosing trait for this new characteristic
anElementName - String - the element name
anElementID - int - the element id
anXMLParser - com.sun.xml.parser.Parser - the element parser
importContext - ImportContext - import context for mapping ids from file to this world
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
Method Detail

startElement

public void startElement(java.lang.String anElementName,
                         org.xml.sax.AttributeList amap)
                  throws org.xml.sax.SAXException
Handle notification that the parser has hit the start of a new element with the given name and attributes.

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.

Overrides:
startElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - name of element
amap - AttributeList - an attribute list

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.
Overrides:
characters in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable white space character data.
Overrides:
ignorableWhitespace in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

endElement

public void endElement(java.lang.String anElementName)
                throws org.xml.sax.SAXException
Handle notification that the parsing of the given element has ended.
Overrides:
endElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - the element name

delete

public void delete()
Delete this object, notifying parent objects and deleting any child objects.

When this method is called, a property change event is generated for the property named EngineProp.DELETED.

Overrides:
delete in class EngineObject

delete

public void delete(boolean notifyChange)

toString

public java.lang.String toString()
Return a string representation of this object, usually the object's name.

Overrides:
toString in class EngineObject
Returns:
String - string representation of object

getTrait

public Trait getTrait()
Return the trait of this characteristic.

Returns:
Trait - trait of this characteristic, never null

getSpecies

public Species getSpecies()
Get the species containing this object.

Returns:
Species - the species containing this object, never null.

getWorld

public World getWorld()
Get the world containing this object.

Overrides:
getWorld in class EngineObject
Returns:
World - the world containing this object, never null.

getName

public java.lang.String getName()
Return the name of this characteristic.

Returns:
String - name of this characteristic, may not be null

setName

public void setName(java.lang.String aName)
Set the name of this characteristic.

When this method is successful, a property change event is fired for the property named EngineProp.NAME.

Parameters:
aName - String - the new name of this characteristic, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal

getImageID

public int getImageID()
Return the image ID of this characteristic.

Returns:
int - id of this characteristic's image

setImageID

public void setImageID(int anImageID)
Set the image ID of this characteristic.

When this method is successful, a property change event is fired for the property named EngineProp.IMAGE_ID.

Parameters:
anImageID - int - the new image ID of this characteristic, may not be null

getPedigreeSymbolType

public int getPedigreeSymbolType()
Get the pedigree symbol type of this characteristic.
Returns:
int - pedigree symbol type of this characteristic
See Also:
PEDIGREE_SYMBOL_SOLID_COLOR, PEDIGREE_SYMBOL_FORWARD_SLASH

getPedigreeSymbolTypeAsString

public java.lang.String getPedigreeSymbolTypeAsString()
Get the pedigree symbol type of this characteristic as a string
Returns:
String - pedigree symbol type of this characteristic as a string
See Also:
PEDIGREE_SYMBOL_SOLID_COLOR_STRING, PEDIGREE_SYMBOL_FORWARD_SLASH_STRING

setPedigreeSymbolType

public void setPedigreeSymbolType(int aSymbolType)
Set the first pedigree symbol type of this characteristic
Parameters:
aSymbolType - int - the new pedigree symbol type of this characteristic
Throws:
java.lang.IllegalArgumentException - - input type unknown

setPedigreeSymbolTypeAsString

public void setPedigreeSymbolTypeAsString(java.lang.String aSymbolTypeString)
Set the first pedigree symbol type of this characteristic, using a string as input.
Parameters:
aSymbolTypeString - String - the new pedigree symbol type of this characteristic
Throws:
java.lang.IllegalArgumentException - - input type unknown

getPedigreeSymbolFirstColor

public java.awt.Color getPedigreeSymbolFirstColor()
Get the first pedigree symbol color of this characteristic.
Returns:
Color - pedigree symbol first color, never null

setPedigreeSymbolFirstColor

public void setPedigreeSymbolFirstColor(java.awt.Color aColor)
Set the first pedigree symbol color of this characteristic
Parameters:
aColor - Color - the new first pedigree symbol color of this characteristic
Throws:
java.lang.IllegalArgumentException - - input color null

getPedigreeSymbolSecondColor

public java.awt.Color getPedigreeSymbolSecondColor()
Get the second pedigree symbol color of this characteristic.
Returns:
Color - pedigree symbol second color, never null

setPedigreeSymbolSecondColor

public void setPedigreeSymbolSecondColor(java.awt.Color aColor)
Set the second pedigree symbol color of this characteristic
Parameters:
aColor - Color - the new second pedigree symbol color of this characteristic
Throws:
java.lang.IllegalArgumentException - - input color null

isFatal

public boolean isFatal()
Return the fatality of this characteristic.

Returns:
boolean - whether or not this characteristic is fatal

setFatal

public void setFatal(boolean aFatal)
Set the fatality of this characteristic.

When this method is successful, a property change event is fired for the property named EngineProp.FATAL.

Parameters:
aFatal - boolean - the new fatality of this characteristic
Throws:
java.lang.IllegalArgumentException - - input argument illegal

writeToStream

public void writeToStream(java.io.PrintWriter stream)
                   throws java.io.IOException
Writes this object to the given stream in XML format. Usually this method is used to write the object to a file for saving it, but that is potentially not the only use.

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.

Overrides:
writeToStream in class EngineObject
Parameters:
stream - PrintWriter - print stream
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
java.io.IOException - - an IO error occurred in java libraries