|
|||||||||
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.SpeciesImage
This class represents an image containing some of the graphics for drawing the organisms of a particular species. Every species must have one or more of these image objects in order to draw its organisms.
All the images for a given species MUST use the same cell size - the width and height of cells in the tables shown in the pictures below. So the image column width and image row height numbers are kept in the Species object, not here. A Species' column width and row height apply to all the SpeciesImage objects in that Species.
Essentially this class maps phenotypes to drawing operations for the species. A species image is a collection of species image cells in rows and columns as shown below. Each row and column has one or more characteristics associated with it. An image cell - the portion of the species image at a given row and column - is the image to be drawn for an organism with the characteristics of that column and row.
For convenience in managing the characteristics associated with each row and column, a SpeciesImage object has a collection of SpeciesImageColumn and another collection SpeciesImageRow objects. These SpeciesImageColumn and SpeciesImageRow objects each represent one column or row in the SpeciesImage and manage the characteristics for that column or row.
<-- Species Image Columns --> +----------+----------+----------+----------+-----> | | | | | ^ | Image | Image | Image | Image | Images --> | | (0,0) | (0,1) | (0,2) | (0,3) | | | | | | | | | | | | S +----------+----------+----------+----------+-----> p | | | | | e | Image | Image | Image | Image | c | (1,0) | (1,1) | (1,2) | (1,3) | i | | | | | e | | | | | s +----------+----------+----------+----------+-----> | | | | | I | Image | | | | m | (2,0) | ... | | | a | | | | | g | | | | | e +----------+----------+----------+----------+-----> | | | | | R | | | | | o | ... | | | | w | | | | | s | | | | | +----------+----------+----------+----------+-----> | | | | | | | | | | | | | | | | | | | | | | | | v | | | | | +----------+----------+----------+----------+-----> | | | | | | | | | | v v v v v Each of the above cells is the same size and contains either a complete image for an organism or a partial image.
For example, for humans, the above SpeciesImage might have only 2 cells - a male image and a female image - and each cell would contain the complete image to be drawn.
Another example, for dragons, a SpeciesImage might have many, many cells where the color characteristics are across the top (e.g. Blue, Brown, Gold, Green, Purple, Yellow) and other characteristics would be down the left side (e.g. Dead, Plain Tail, Fancy Tail, Arrow Tail, etc.) So drawing a dragon means determining the characteristics of the dragon and then picking out and drawing the correct cells from the dragon SpeciesImage's. A second SpeciesImage for dragon might have the head images for the dragon. A third SpeciesImage for dragon might have the wing types, etc.
So a dragon Bodies SpeciesImage might look something like: Blue Brown Green Gold +----------+----------+----------+----------+ D | | | | | e | Blue + | Brown + | Green + | Gold + | a | Dead | Dead | Dead | Dead | d | Dragon | Dragon | Dragon | Dragon | | | | | | +----------+----------+----------+----------+ 4 P | | | | | L l T | Blue + | Brown + | Green + | Gold + | e + a a | Plain | Plain | Plain | Plain | g i i | Tail + | Tail + | Tail + | Tail + | s n l | 4 Legs | 4 Legs | 4 Legs | 4 Legs | +----------+----------+----------+----------+ 4 F | | | | | L a T | Blue + | Brown + | Green + | Gold + | e + n a | Fancy | Fancy | Fancy | Fancy | g c i | Tail + | Tail + | Tail + | Tail + | s y l | 4 Legs | 4 Legs | 4 Legs | 4 Legs | +----------+----------+----------+----------+ 4 A | | | | | L r T | Blue + | Brown + | Green + | Gold + | e + r a | Arrow | Arrow | Arrow | Fancy | g o i | Tail + | Tail + | Tail + | Tail + | s w l | 4 Legs | 4 Legs | 4 Legs | 4 Legs | +----------+----------+----------+----------+ 0 P | | | | | L l T | Blue + | Brown + | Green + | Gold + | e + a a | Plain | Plain | Plain | Plain | g i i | Tail + | Tail + | Tail + | Tail + | s n l | 0 Legs | 0 Legs | 0 Legs | 0 Legs | +----------+----------+----------+----------+ 0 F | | | | | L a T | Blue + | Brown + | Green + | Gold + | e + n a | Fancy | Fancy | Fancy | Fancy | g c i | Tail + | Tail + | Tail + | Tail + | s y l | 0 Legs | 0 Legs | 0 Legs | 0 Legs | +----------+----------+----------+----------+ 0 A | | | | | L r T | Blue + | Brown + | Green + | Gold + | e + r a | Arrow | Arrow | Arrow | Fancy | g o i | Tail + | Tail + | Tail + | Tail + | s w l | 0 Legs | 0 Legs | 0 Legs | 0 Legs | +----------+----------+----------+----------+ 2 P | | | | | L l T | Blue + | Brown + | Green + | Gold + | e + a a | Plain | Plain | Plain | Plain | g i i | Tail + | Tail + | Tail + | Tail + | s n l | 2 Legs | 2 Legs | 2 Legs | 2 Legs | +----------+----------+----------+----------+ 2 F | | | | | L a T | Blue + | Brown + | Green + | Gold + | e + n a | Fancy | Fancy | Fancy | Fancy | g c i | Tail + | Tail + | Tail + | Tail + | s y l | 2 Legs | 2 Legs | 2 Legs | 2 Legs | +----------+----------+----------+----------+ 2 A | | | | | L r T | Blue + | Brown + | Green + | Gold + | e + r a | Arrow | Arrow | Arrow | Fancy | g o i | Tail + | Tail + | Tail + | Tail + | s w l | 2 Legs | 2 Legs | 2 Legs | 2 Legs | +----------+----------+----------+----------+ Drawing a particular dragon organism means drawing 1 or more of the image cells from 1 or more SpeciesImage's. For a dead dragon, we'd draw just one cell from one SpeciesImage (because all dead dragons look the same or all the variations in one SpeciesImage). For a live dragon, we'd draw 4 to 6 cells from multiple SpeciesImage depending on the phenotype of the dragon.
In general, drawing an organism of a species amounts to:
An object of this class will generate the following property change events:
EngineProp.DELETED
,
EngineProp.HOTSPOT_COLOR
,
EngineProp.HOTSPOT_RADIUS
,
EngineProp.ID
,
EngineProp.IMAGE_TYPE
,
EngineProp.LOCKED_STATE
,
EngineProp.NAME
,
EngineProp.SPECIES_IMAGE_COLUMN_ADDED
,
EngineProp.SPECIES_IMAGE_COLUMN_REMOVED
,
EngineProp.SPECIES_IMAGE_ROW_ADDED
,
EngineProp.SPECIES_IMAGE_ROW_REMOVED
,
PropertyChangeListener
, Serialized FormField Summary | |
static int |
HOTSPOT_IMAGE_TYPE
|
static int |
INVISIBLE_IMAGE_TYPE
|
static int |
LARGE_IMAGE_SIZE
|
static int |
MEDIUM_IMAGE_SIZE
|
static int |
NORMAL_IMAGE_TYPE
Possible image types: |
static int |
SCOPE_IMAGE_TYPE
|
static int |
SMALL_IMAGE_SIZE
|
static int |
UNKNOWN_IMAGE_SIZE
Image sizes, generally used as follows: |
static int |
XLARGE_IMAGE_SIZE
|
static int |
XSMALL_IMAGE_SIZE
|
static int |
XXSMALL_IMAGE_SIZE
|
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 | |
SpeciesImage(Species aSpecies,
java.lang.String aName)
Creates a new species image given a species and a name. |
|
SpeciesImage(Species aSpecies,
java.lang.String anElementName,
int anElementID,
com.sun.xml.parser.Parser anXMLParser,
ImportContext importContext)
Create a new species image 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)
|
boolean |
drawDataImage(java.awt.Graphics g,
int sizeID,
int rowIndex,
int columnIndex,
java.awt.Component c)
|
boolean |
drawDataImage(java.awt.Graphics g,
int sizeID,
int rowIndex,
int columnIndex,
int xInit,
int yInit,
java.awt.Component c)
|
boolean |
drawDataImage(int[] pixels,
int worig,
int horig,
int sizeID,
int rowIndex,
int columnIndex)
|
void |
endElement(java.lang.String anElementName)
Handle notification that the parsing of the given element has ended. |
protected java.lang.String |
getDataPathName(java.lang.String name)
|
java.net.URL |
getDataResource(java.lang.String nameResource)
|
java.awt.Image |
getDataSourceImage(int[] pixels,
int worig,
int horig,
int sizeID,
int rowID,
int columnID,
int[] xoffset,
int[] yoffset)
|
java.awt.Image |
getDataSourceImage(int sizeID,
int rowID,
int columnID,
int[] xoffset,
int[] yoffset,
java.awt.Component c)
|
java.awt.Color |
getHotspotColor()
Get the hotspot color of this species image |
int |
getHotspotRadius()
Get the hotspot radius for this species image. |
java.awt.Image |
getImage(int imageSize,
java.awt.Component component)
Get the actual Image object for this species image. |
protected java.lang.String |
getImagePathName(java.lang.String name)
|
int |
getImageType()
Get the image type for this species image. |
java.lang.String |
getName()
Return the name of this species image. |
int |
getNumberOfSpeciesImageColumns()
Get the number of species image columns for this species image. |
int |
getNumberOfSpeciesImageRows()
Get the number of species image columns for this species image. |
java.lang.String |
getSource(int imageSize)
Return the file of this species image in File form. |
Species |
getSpecies()
Return the species of this object. |
java.util.Enumeration |
getSpeciesImageColumns()
Returns an enumeration over the vector of species image columns in this species image. |
SpeciesImageRow |
getSpeciesImageRowAt(int aRowIndex)
Returns a specific species image row, null if invalid row. |
java.util.Enumeration |
getSpeciesImageRows()
Returns an enumeration over the vector of species image columns in this species image. |
World |
getWorld()
Get the world containing this object. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable white space character data. |
protected void |
initializeImageSource(java.lang.String name)
|
void |
initImageDownloading(int sizeID,
java.awt.Component c)
|
boolean |
isDataSourceExist(int imageSize)
|
static boolean |
isImageVisible()
|
void |
preloadSpeciesImageSize(int imageSize)
|
void |
setAutomaticLocked(boolean automaticLocked)
Set or unset the automatic locked state of this object, leaving other components of the locked state untouched. |
void |
setHotspotColor(java.awt.Color aColor)
Set the hotspot color of this species image |
void |
setHotspotRadius(int aHotspotRadius)
Set the hotspot radius of this species image. |
void |
setImageType(int anImageType)
Set the image type of this species image. |
static void |
setImageVisible(boolean 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 species image. |
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. |
void |
updateFilename()
Called by parent species when it's name changes, as this image cares. |
void |
updateOrganismImage(OrganismImage anOrganismImage)
Update an organism image given the current state of this species image, its rows and columns. |
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 UNKNOWN_IMAGE_SIZE
XXSMALL_IMAGE_SIZE - default in population view, often used in pedigree, impossible to discern phenotype XSMALL_IMAGE_SIZE - default in pedigree view, barely possible to discern phenotype SMALL_IMAGE_SIZE - smallest where you can easily discern phenotype MEDIUM_IMAGE_SIZE - used sometimes in multiple and single organism views, may discern phenotype LARGE_IMAGE_SIZE - default size in multiple and single organism views, easily discern phenotype XLARGE_IMAGE_SIZE - extra large size for special circumstances
public static final int XXSMALL_IMAGE_SIZE
public static final int XSMALL_IMAGE_SIZE
public static final int SMALL_IMAGE_SIZE
public static final int MEDIUM_IMAGE_SIZE
public static final int LARGE_IMAGE_SIZE
public static final int XLARGE_IMAGE_SIZE
public static final int NORMAL_IMAGE_TYPE
NORMAL_IMAGE_TYPE - normal, phenotype image type, shown in all cases for an organism HOTSPOT_IMAGE_TYPE - an image shown for the organism when a hotspot is pressed SCOPE_IMAGE_TYPE - an image shown when an organism is clicked on with the scope tool INVISIBLE_IMAGE_TYPE - an image shown when an organism is invisible
public static final int HOTSPOT_IMAGE_TYPE
public static final int SCOPE_IMAGE_TYPE
public static final int INVISIBLE_IMAGE_TYPE
Constructor Detail |
public SpeciesImage(Species aSpecies, java.lang.String aName)
aSpecies
- Species - the species containing this image, may not be nullaName
- String - the species image name, may not be nulljava.lang.IllegalArgumentException
- - input argument(s) illegalpublic SpeciesImage(Species aSpecies, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
aSpecies
- Species - the enclosing species for this new species imageanElementName
- 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 |
protected java.lang.String getImagePathName(java.lang.String name)
protected java.lang.String getDataPathName(java.lang.String name)
protected void initializeImageSource(java.lang.String name)
public java.net.URL getDataResource(java.lang.String nameResource)
public void preloadSpeciesImageSize(int imageSize)
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 successful, a property change event is generated 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 Species getSpecies()
public 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 image, may not be nulljava.lang.IllegalArgumentException
- - input argument illegalObjectDeletedException
- - object is deleted and cannot be modifiedObjectLockedException
- - object is locked and cannot be modifiedpublic void updateFilename()
public java.lang.String getSource(int imageSize)
imageSize
- int - the image size (e.g. XSMALL_IMAGE_SIZE)public java.awt.Image getImage(int imageSize, java.awt.Component component)
imageSize
- int - the image size (e.g. XSMALL_IMAGE_SIZE)component
- Component - the component on whose behalf we'll get image, may not be nullpublic 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.util.Enumeration getSpeciesImageColumns()
public int getNumberOfSpeciesImageColumns()
public java.util.Enumeration getSpeciesImageRows()
public SpeciesImageRow getSpeciesImageRowAt(int aRowIndex)
aRowIndex
- int - a row indexpublic int getNumberOfSpeciesImageRows()
public void updateOrganismImage(OrganismImage anOrganismImage)
anOrganismImage
- OrganismImage - organism image to update, may not be nullpublic static void setImageVisible(boolean visible)
public static boolean isImageVisible()
public int getImageType()
public void setImageType(int anImageType)
anImageType
- int - new image typepublic java.awt.Color getHotspotColor()
public void setHotspotColor(java.awt.Color aColor)
aColor
- Color - the new hotspot colorjava.lang.IllegalArgumentException
- - input color nullpublic int getHotspotRadius()
public void setHotspotRadius(int aHotspotRadius)
aHotspotRadius
- int - new hotspot radiuspublic 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 boolean isDataSourceExist(int imageSize)
public java.awt.Image getDataSourceImage(int sizeID, int rowID, int columnID, int[] xoffset, int[] yoffset, java.awt.Component c)
public java.awt.Image getDataSourceImage(int[] pixels, int worig, int horig, int sizeID, int rowID, int columnID, int[] xoffset, int[] yoffset)
public void initImageDownloading(int sizeID, java.awt.Component c)
public boolean drawDataImage(java.awt.Graphics g, int sizeID, int rowIndex, int columnIndex, java.awt.Component c)
public boolean drawDataImage(java.awt.Graphics g, int sizeID, int rowIndex, int columnIndex, int xInit, int yInit, java.awt.Component c)
public boolean drawDataImage(int[] pixels, int worig, int horig, int sizeID, int rowIndex, int columnIndex)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |