|
|||||||||
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.Environment
This class represents an environment. An environment is defined as a closed biosphere in which a population of organisms exists. The organisms in one environment may not move to another environment, although they may move from a subenvironment to another subenvironment.
Currently this environment doesn't contain any geometric information, but it probably should at sometime in the future, once we decide if geometric information (e.g. locations in an environment) is 2D or 3D.
An object of this class will environmentrate the following simple, non-vector property change events:
EngineProp.ID
,
EngineProp.DELETED
,
EngineProp.HEIGHT
,
EngineProp.LOCKED_STATE
,
EngineProp.NAME
,
EngineProp.TERRAINS
,
EngineProp.WIDTH
,
PropertyChangeListener
, Serialized FormFields 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 | |
Environment(World aWorld,
java.lang.String aName,
int aWidth,
int aHeight)
Creates a new environment with the given name. |
|
Environment(World aWorld,
java.lang.String anElementName,
int anElementID,
com.sun.xml.parser.Parser anXMLParser,
ImportContext importContext)
Create a new environment 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 |
getHeight()
Get the height of the environment |
java.lang.String |
getName()
Return the name of this environment. |
Terrain |
getTerrain(int indexColumn,
int indexRow)
Get the terrain at the given indexes into the terrain array |
int |
getWidth()
Get the width of the environment |
World |
getWorld()
Return the world containing this environment. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable white space character data. |
void |
setHeight(int aHeight)
Set the height of the environment. |
void |
setName(java.lang.String aName)
Set the name of this environment. |
void |
setTerrain(int indexColumn,
int indexRow,
Terrain aTerrain)
Set the terrain at the given indexes into the terrain array. |
void |
setWidth(int aWidth)
Set the width of the environment. |
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 |
Constructor Detail |
public Environment(World aWorld, java.lang.String aName, int aWidth, int aHeight)
aWorld
- World - a world containing this environmentaName
- String - name of this environment, may not be nullaWidth
- int - the width of the environment, must be > 0aHeight
- int - the height of the environment, must be > 0java.lang.IllegalArgumentException
- - input argument(s) illegalpublic Environment(World aWorld, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
aWorld
- World - the enclosing world for this new environmentanElementName
- 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 environmentjava.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 environmentrated for the property named EngineProp.DELETED.
delete
in class EngineObject
public void delete(boolean notifyChange)
public java.lang.String toString()
toString
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 environment, may not be nulljava.lang.IllegalArgumentException
- - input argument illegalpublic World getWorld()
getWorld
in class EngineObject
public int getWidth()
public void setWidth(int aWidth)
When this method is successful, a property change event is fired for the property named EngineProp.WIDTH.
aWidth
- int - a new width, must be >= 0java.lang.IllegalArgumentException
- - bad input argumentpublic int getHeight()
public void setHeight(int aHeight)
When this method is successful, a property change event is fired for the property named EngineProp.HEIGHT.
aHeight
- int - a new height, must be >= 0java.lang.IllegalArgumentException
- - bad input argumentpublic Terrain getTerrain(int indexColumn, int indexRow)
indexColumn
- int - column index, must be validindexRow
- int - row index, must be validjava.lang.IllegalArgumentException
- - invalid indexpublic void setTerrain(int indexColumn, int indexRow, Terrain aTerrain)
indexColumn
- int - column index, must be validindexRow
- int - row index, must be validaTerrain
- Terrain - terrain at given index, may be nulljava.lang.IllegalArgumentException
- - invalid indexpublic 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 libraries
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |