org.concord.biologica.ui
Class MeiosisModel

java.lang.Object
  |
  +--org.concord.biologica.ui.MeiosisModel
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public final class MeiosisModel
extends java.lang.Object
implements java.beans.PropertyChangeListener

MeiosisModel contains the data describing the meiosis process state for a given organism. It does not contain the code for drawing the animation as that is in the view objects that show meiosis.

This model and its associated chromosome models assume a display space of 0 to 1000 by 0 to 1000 and all locations are within that range. This means a user of these model classes must scale locations appropriately from this coordinate system to their own in order to draw the chromosomes.

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

Version:
$Revision: 1.2 $ $Date: 2002/03/28 17:43:17 $
Author:
$Author: qliao $
See Also:
UIProp.MEIOSIS_STARTED, UIProp.MEIOSIS_STEP, UIProp.MOVED_GAMETE, UIProp.ORGANISM, UIProp.SELECTED_GAMETE, PropertyChangeListener

Field Summary
static int BOTTOM_LEFT_GAMETE
           
static int BOTTOM_RIGHT_GAMETE
           
protected  java.beans.PropertyChangeSupport changes
          Utility object which manages property change events and listeners.
static int NO_GAMETE
          Gamete identifiers
static int TOP_LEFT_GAMETE
           
static int TOP_RIGHT_GAMETE
           
 
Constructor Summary
MeiosisModel()
          Creates a new instance of MeiosisModel with no organism.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Add a property change listener for properties.
 int decrementStep()
          Decrement the current step of the meiosis, returning the new current step value.
 void delete()
          Deletes this model and associated models
 java.util.Enumeration getBottomLeftGameteChromosomeModels()
          Return an enumeration of the bottom left gamete chromosome models.
 java.util.Enumeration getBottomRightGameteChromosomeModels()
          Return an enumeration of the bottom right gamete chromosome models.
 java.util.Vector[] getBranchs()
           
 java.util.Vector getCellBoundaries()
          Get CellArc and CellLine enumeration to use when drawing boundaries and spindles of cell(s).
 java.util.Vector getChromosomeModelEnumerations()
          Get vector of the appropriate enumerations of chromosome models in this meiosis model.
 MeiosisChromosomeModel getCrossoverChromosomeModel(MeiosisChromosomeModel aMeiosisChromosomeModel)
          Get the chromosome model for the chromosome that can crossover with the given chromosome model chromosome.
 java.util.Enumeration getGameteChromosomeModels(int aGamete)
          Return an enumeration of the appropriate gamete chromosome models.
 int getMovedGamete()
          Get the moved gamete
 java.util.Vector getMovedGameteChromosomeModels()
          Get the moved gamete's chromosome models
 int getNumberOfVisibleChromosomePairs()
          Returns the number of chromosome pairs to be aligned vertically in a cell during Metaphase 1 and Metaphase 2 during meiosis.
 Organism getOrganism()
          Get the organism for this model, may be null.
 int getPhase(int aStep)
          Get the phase of the meiosis at the given step.
 int getSelectedGamete()
          Get the selected gamete
 int getStep()
          Get the current step of the meiosis.
 java.util.Enumeration getTopLeftGameteChromosomeModels()
          Return an enumeration of the top left gamete chromosome models.
 java.util.Enumeration getTopRightGameteChromosomeModels()
          Return an enumeration of the top right gamete chromosome models.
 int incrementStep()
          Increment the current step of the meiosis
 boolean isCrossOverHappened()
           
 boolean isReplicated()
          Returns whether the current step of meiosis represents a step in which chromosome are replicated.
 void moveGamete()
          Move the gamete currently selected into fertilization.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle property change events
 void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Remove a property change listener for properties.
 void selectGamete(int xMouse, int yMouse)
          Select the gamete closest to the given x, y coordinates.
 void setBranchs(java.util.Vector[] arr)
           
 void setCrossOverHappened(boolean bln)
           
 void setEnclosingViewRectangle(java.awt.Rectangle aRectangle)
          Set the rectangle within which the meiosis model must confine itself and its chromosomes.
 int setStep(int aStep)
          Set the current step of the meiosis.
 void switchHorizontalAlignment(int iChromosome)
          Switch horizontal alignment of 2 chromosomes at step 33 and beyond in meiosis.
 void switchVerticalAlignment(int iChromosome)
          Switch vertical alignment of 2 chromosomes at step 73 and beyond in meiosis.
 void unmoveGamete()
          Unmove gamete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_GAMETE

public static final int NO_GAMETE
Gamete identifiers

TOP_LEFT_GAMETE

public static final int TOP_LEFT_GAMETE

BOTTOM_LEFT_GAMETE

public static final int BOTTOM_LEFT_GAMETE

TOP_RIGHT_GAMETE

public static final int TOP_RIGHT_GAMETE

BOTTOM_RIGHT_GAMETE

public static final int BOTTOM_RIGHT_GAMETE

changes

protected transient java.beans.PropertyChangeSupport changes
Utility object which manages property change events and listeners.
Constructor Detail

MeiosisModel

public MeiosisModel()
Creates a new instance of MeiosisModel with no organism.
Method Detail

delete

public void delete()
Deletes this model and associated models

getOrganism

public Organism getOrganism()
Get the organism for this model, may be null.
Returns:
Organism - organism for this model, may be null

decrementStep

public int decrementStep()
Decrement the current step of the meiosis, returning the new current step value.
Returns:
int - new current step value of meiosis

incrementStep

public int incrementStep()
Increment the current step of the meiosis
Returns:
int - new current step value of meiosis

getStep

public int getStep()
Get the current step of the meiosis.
Returns:
int - new current step

setStep

public int setStep(int aStep)
Set the current step of the meiosis.
Parameters:
aStep - int - new proposed current step
Returns:
int - new current step

getPhase

public int getPhase(int aStep)
Get the phase of the meiosis at the given step.

Parameters:
aStep - int - the step of meiosis
Returns:
int - current phase

getGameteChromosomeModels

public java.util.Enumeration getGameteChromosomeModels(int aGamete)
Return an enumeration of the appropriate gamete chromosome models.

Parameters:
aGamete - int - the gamete (TOP_LEFT_GAMETE, etc.)
Returns:
Enumeration - an enumeration over the top left gamete chromosome models, null if illegal gamete value

getTopLeftGameteChromosomeModels

public java.util.Enumeration getTopLeftGameteChromosomeModels()
Return an enumeration of the top left gamete chromosome models.

Returns:
Enumeration - an enumeration over the top left gamete chromosome models.

getBottomLeftGameteChromosomeModels

public java.util.Enumeration getBottomLeftGameteChromosomeModels()
Return an enumeration of the bottom left gamete chromosome models.

Returns:
Enumeration - an enumeration over the bottom left gamete chromosome models.

getTopRightGameteChromosomeModels

public java.util.Enumeration getTopRightGameteChromosomeModels()
Return an enumeration of the top right gamete chromosome models.

Returns:
Enumeration - an enumeration over the top right gamete chromosome models.

getBottomRightGameteChromosomeModels

public java.util.Enumeration getBottomRightGameteChromosomeModels()
Return an enumeration of the bottom right gamete chromosome models.

Returns:
Enumeration - an enumeration over the bottom right gamete chromosome models.

getChromosomeModelEnumerations

public java.util.Vector getChromosomeModelEnumerations()
Get vector of the appropriate enumerations of chromosome models in this meiosis model.

In other words, if the current step is 0 to 30, a Vector holding a single Enumeration over the chromosome models of the original cell will be returned.

If the current step is 31 to 70, a Vector holding two Enumerations will be returned with the first Enumeration over the chromosome models of the left daughter cell and the second Enumeration over the chromosome models of the right daughter cell.v

If the current step is 71 to 100, a Vector holding four Enumerations will be returned with the first Enumeration over the chromosome models of the top left gamete, second over the bottom left gamete, third over the top right gamete and fourth over the bottom right gamete.

Returns:
Enumeration - an enumeration over all chromosomes models in this meiosis model

getCellBoundaries

public java.util.Vector getCellBoundaries()
Get CellArc and CellLine enumeration to use when drawing boundaries and spindles of cell(s).

Returns:
Vector of CellArc and CellLine objects.

setEnclosingViewRectangle

public void setEnclosingViewRectangle(java.awt.Rectangle aRectangle)
Set the rectangle within which the meiosis model must confine itself and its chromosomes. Buttons should be outside of this area whenever possible. This method should be called when the enclosing view is resized, giving the model data a chance to scale itself appropriately.
Parameters:
aRectangle - Rectangle - the enclosing rectangle

getNumberOfVisibleChromosomePairs

public int getNumberOfVisibleChromosomePairs()
Returns the number of chromosome pairs to be aligned vertically in a cell during Metaphase 1 and Metaphase 2 during meiosis. In most cases, this is the number of chromosome pairs.
Returns:
numberOfVisibleChromosomePairs int - number of chromosome pairs

getCrossoverChromosomeModel

public MeiosisChromosomeModel getCrossoverChromosomeModel(MeiosisChromosomeModel aMeiosisChromosomeModel)
Get the chromosome model for the chromosome that can crossover with the given chromosome model chromosome. If there is no crossover chromosome, usually because the given chromosome is an X or Y and the other sex chromosome is the opposite, then null is returned.

Parameters:
aMeiosisChromosomeModel - MeiosisChromosomeModel - the given meiosis chromosome model
Returns:
MeiosisChromosomeModel - the crossover chromosome model

isReplicated

public boolean isReplicated()
Returns whether the current step of meiosis represents a step in which chromosome are replicated. In other words, should second strands be drawn?
Returns:
boolean - are the chromosomes replicated at the current meiosis step?

switchHorizontalAlignment

public void switchHorizontalAlignment(int iChromosome)
Switch horizontal alignment of 2 chromosomes at step 33 and beyond in meiosis.
Parameters:
iChromosome - int - number of chromosome (1-based number)

switchVerticalAlignment

public void switchVerticalAlignment(int iChromosome)
Switch vertical alignment of 2 chromosomes at step 73 and beyond in meiosis.
Parameters:
iChromosome - int - number of chromosome (1-based number)

selectGamete

public void selectGamete(int xMouse,
                         int yMouse)
Select the gamete closest to the given x, y coordinates.

Usually this method is called from SmallMeiosisView.mousePressed()

Parameters:
xMouse - int - mouse x coordinate
yMouse - int - mouse y coordinate

getSelectedGamete

public int getSelectedGamete()
Get the selected gamete

getMovedGameteChromosomeModels

public java.util.Vector getMovedGameteChromosomeModels()
Get the moved gamete's chromosome models
Returns:
Vector of meiosis chromosome models of moved gamete, null if no gamete moved

moveGamete

public void moveGamete()
Move the gamete currently selected into fertilization.

Usually this method is called when the user clicks on the move into fertilization button in the sex view.

If there is already a moved gamete, this call is ignored. The user must move the old moved gamete back into the meiosis view first.

If no gamete is selected, this call is ignored. The user must select a gamete first.


getMovedGamete

public int getMovedGamete()
Get the moved gamete

unmoveGamete

public void unmoveGamete()
Unmove gamete. In other words, retrieve the moved gamete from the fertilization view. Leave the selected gamete alone.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
Add a property change listener for properties.
Parameters:
aListener - PropertyChangeListener - a new listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
Remove a property change listener for properties.
Parameters:
aListener - PropertyChangeListener - a listener to remove

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle property change events
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - PropertyChangeEvent - the property change event

setBranchs

public void setBranchs(java.util.Vector[] arr)

getBranchs

public java.util.Vector[] getBranchs()

setCrossOverHappened

public void setCrossOverHappened(boolean bln)

isCrossOverHappened

public boolean isCrossOverHappened()