jadex.swing.sequence
Class SequenceLayoutModel

java.lang.Object
  |
  +--jadex.swing.sequence.SequenceLayoutModel

public class SequenceLayoutModel
extends java.lang.Object

This class is used to transform bp coordinate on the chromosome to the graphics coordinate, and the zoom and some layout processing.


Field Summary
protected  java.util.List boxes
           
protected  float distance
           
protected  float height
           
protected  int IS_LOW
           
protected  int IS_UP
           
protected  long totalBP
           
protected  int totalLayers
           
protected  float xPadding
           
protected  float yPadding
           
protected  int ZOOM_STEP
           
 
Constructor Summary
SequenceLayoutModel()
          Creates new SequenceLayoutCalculator
SequenceLayoutModel(int layer, SequenceDisplay display)
          Third constructor with a layer as a argument
SequenceLayoutModel(SequenceDisplay display)
          Second constructor with display as the argument
 
Method Summary
protected  float fromBpToX(long bp)
          Transform from the bp on chromsome to the graphics coordinate system
protected  long fromXtoBp(float x)
          The opposite method of the above method
 java.awt.Rectangle getBounds(org.jdom.Element sequence, int layer, boolean isOdd)
          Calculate the positon of sequence element based on its positions on the chromosome
protected  int getBoxAboveY(float y)
          Get the box just above or containing a given y
protected  int getBoxBelowY(float y)
          Get the box just below or containing a given y
protected  int[] getBoxFromY(float x, float y)
          A helper to get the box number for a point
 org.jdom.Element getClosestElement(int x, int y)
          Get the sequence element by a point coordinate on the graphics
protected  java.util.List getElementsBetween(java.awt.Rectangle rect)
          Get a list of sequence elements in a rectangele
 java.awt.Rectangle getGeneBounds(java.awt.Rectangle rect)
          Get a gene bounds from it parent sequence's bounds
 MapRange getMapRange()
          Get the currently displayed MapRange.
 long getMouseAt()
          Get the current mouse position in bp unit
 java.awt.Rectangle getSequenceAndGeneBounds(org.jdom.Element sequence, int layer, boolean isOdd)
          Calculte a bounds for a sequence elemement containing a gene
 void moveLeft()
          Moving the current range to the left
 void moveRight()
          Moving the current range to the right
protected  void outputSequenceList(java.util.List list)
          An convient method to output a sequence element list
protected  void relayout()
          Do some initialization layout calculation
 void reset()
          Reset the maprange to the whole chromosome
protected  org.jdom.Element searchElement(int[] box, long bp)
          Find an element based on box number and base pain positin on the chromosome.
 void setMapRange(MapRange range)
          Set the displayed MapRange.
 void setMouseAt(long p)
          Set current mouse position in bp unit
 void setTotalBP(long total)
          By setting total bp of chromosome, the rel and offset should be calculated.
 void zoom(java.awt.Rectangle rect)
          Zoom in a specific rectangle
 void zoomIn()
          Do zooming-in in the current range
 void zoomOut()
          Do zooming-out in the current range
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xPadding

protected float xPadding

yPadding

protected float yPadding

distance

protected float distance

height

protected float height

ZOOM_STEP

protected final int ZOOM_STEP

totalLayers

protected int totalLayers

IS_UP

protected int IS_UP

IS_LOW

protected int IS_LOW

totalBP

protected long totalBP

boxes

protected java.util.List boxes
Constructor Detail

SequenceLayoutModel

public SequenceLayoutModel()
Creates new SequenceLayoutCalculator

SequenceLayoutModel

public SequenceLayoutModel(SequenceDisplay display)
Second constructor with display as the argument
Parameters:
display - the container all sequence element should be drawed on

SequenceLayoutModel

public SequenceLayoutModel(int layer,
                           SequenceDisplay display)
Third constructor with a layer as a argument
Parameters:
layer - the total layer number
display - the container all sequence element should be drawn on
Method Detail

relayout

protected void relayout()
Do some initialization layout calculation

setTotalBP

public void setTotalBP(long total)
By setting total bp of chromosome, the rel and offset should be calculated.
Parameters:
total - the total bp of the displayed chromosome.

setMapRange

public void setMapRange(MapRange range)
Set the displayed MapRange.
Parameters:
range - the MapRange to be displayed.

getMapRange

public MapRange getMapRange()
Get the currently displayed MapRange.
Returns:
the displayed MapRange.

getBounds

public java.awt.Rectangle getBounds(org.jdom.Element sequence,
                                    int layer,
                                    boolean isOdd)
Calculate the positon of sequence element based on its positions on the chromosome
Parameters:
sequence - the calculated sequence element, should containing range information
layer - which layer from the root this element is
isOdd - check is the order number of the sequence is odd or even
Returns:
the rectangle of the the sequence element in the graphics coordinate

getSequenceAndGeneBounds

public java.awt.Rectangle getSequenceAndGeneBounds(org.jdom.Element sequence,
                                                   int layer,
                                                   boolean isOdd)
Calculte a bounds for a sequence elemement containing a gene
Parameters:
sequence - a sequence element with a gene element
layer - the layer number, should be on the top

getGeneBounds

public java.awt.Rectangle getGeneBounds(java.awt.Rectangle rect)
Get a gene bounds from it parent sequence's bounds
Parameters:
rect - the sequence, the gene's parent, bounds
Returns:
the gene bounds

fromBpToX

protected float fromBpToX(long bp)
Transform from the bp on chromsome to the graphics coordinate system

fromXtoBp

protected long fromXtoBp(float x)
The opposite method of the above method

getClosestElement

public org.jdom.Element getClosestElement(int x,
                                          int y)
Get the sequence element by a point coordinate on the graphics
Parameters:
x - x-coordinate
y - y-coordinate & @return Element corresponding to the point (x, y)

getElementsBetween

protected java.util.List getElementsBetween(java.awt.Rectangle rect)
Get a list of sequence elements in a rectangele
Parameters:
x1 - the left end
x2 - the right end
box - the number of box to be checked
Returns:
sequence elements in the rect

getBoxFromY

protected int[] getBoxFromY(float x,
                            float y)
A helper to get the box number for a point
Parameters:
y - the y coordinate of the point
Returns:
a two element array: int[0] the box number int[1] is 0 or 1, 0 for the upper half and 1 for the lewer half. int[0] is -1 is no box can be found.

getBoxAboveY

protected int getBoxAboveY(float y)
Get the box just above or containing a given y
Parameters:
y - the y coordinate
Returns:
the box number

getBoxBelowY

protected int getBoxBelowY(float y)
Get the box just below or containing a given y
Parameters:
y - the y coordinate
Returns:
the box number

searchElement

protected org.jdom.Element searchElement(int[] box,
                                         long bp)
Find an element based on box number and base pain positin on the chromosome.
Parameters:
box - the box number
bp - the base pair position on the chromosome
Returns:
the element

zoomIn

public void zoomIn()
Do zooming-in in the current range

zoomOut

public void zoomOut()
Do zooming-out in the current range

moveLeft

public void moveLeft()
Moving the current range to the left

moveRight

public void moveRight()
Moving the current range to the right

reset

public void reset()
Reset the maprange to the whole chromosome

zoom

public void zoom(java.awt.Rectangle rect)
Zoom in a specific rectangle

setMouseAt

public void setMouseAt(long p)
Set current mouse position in bp unit

getMouseAt

public long getMouseAt()
Get the current mouse position in bp unit

outputSequenceList

protected void outputSequenceList(java.util.List list)
An convient method to output a sequence element list