net.sourceforge.olduvai.accordiondrawer
Class AbstractRangeList

java.lang.Object
  extended by net.sourceforge.olduvai.accordiondrawer.AbstractRangeList
Direct Known Subclasses:
RangeList

public abstract class AbstractRangeList
extends java.lang.Object

This class represents a list of ranges along ONE axis. A range is a set of indices min,max that represent cells in the SplitLine grid.

Author:
hilde, jslack

Field Summary
protected  java.awt.Color color
          The drawing color for this range list, if appropriate.
protected  boolean enabled
          True when this group is active, and will be drawn.
protected  int key
          Unique integer key for this group
protected  java.util.Set ranges
          Resizeable Set of RangeInTree objects.
 
Constructor Summary
AbstractRangeList()
           
 
Method Summary
abstract  AbstractRangeList flipRangeToShrink(int xy, AccordionDrawer ad)
          Reverses the ranges so we may grow the unselected ranges, performing a shrink on the selected ranges.
 java.awt.Color getColor()
          Accessor for the range color, color
 int getKey()
          Accessor for the key value, key
abstract  double[] getSizesOfAllRanges(SplitAxis splitAxis, int frameNum)
          For each range in ranges, store the size in world coordinates
abstract  int[] getSplitIndices(boolean horizontal)
          Application-specific accessor for split line indices that surround this range.
 SplitLine[] getSplitLines(SplitAxis axis)
          Analagous to getSplitIndices(boolean) but returns the list of lines instead.
abstract  double getUnshrinkableTotal(AccordionDrawer ad, SplitAxis splitAxis, int frameNum)
          Return the quantity of world space that may not be shrunk by a stretching operation.
 boolean isEnabled()
          Accessor for the value of enabled
abstract  AbstractRangeList onlyThisAD(AccordionDrawer d)
          Cuts the ranges into a subset of only ranges in the given drawer.
 void setColor(java.awt.Color c)
          Sets the color of the marked ranges.
 void setEnabled(boolean enabled)
          Sets the value of enabled, turning on (true) or off (false) the rendering of the group defined by this abstract range list.
 void setKey(int key)
          Sets the key to the given value.
 int size()
          Accessor for the number of ranges in the set of ranges ranges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

protected java.awt.Color color
The drawing color for this range list, if appropriate.


ranges

protected java.util.Set ranges
Resizeable Set of RangeInTree objects. Usually a treeset but that isn't required.


enabled

protected boolean enabled
True when this group is active, and will be drawn. Setting to false will not draw this group.


key

protected int key
Unique integer key for this group

Constructor Detail

AbstractRangeList

public AbstractRangeList()
Method Detail

getSplitIndices

public abstract int[] getSplitIndices(boolean horizontal)
Application-specific accessor for split line indices that surround this range. In TJ, we use indices in the set of leaves, in SJ it could either be a range of Sequences or a range of Nucleotides.

Parameters:
horizontal - For SJ, horizontal = true for nucleotide ranges, false for sequences
Returns:
Indices to a pair of split lines that surround the range.

getSplitLines

public SplitLine[] getSplitLines(SplitAxis axis)
Analagous to getSplitIndices(boolean) but returns the list of lines instead.

Parameters:
axis - Axis that contains this list of ranges
Returns:
A pair of split lines that surround each range in this list.

getSizesOfAllRanges

public abstract double[] getSizesOfAllRanges(SplitAxis splitAxis,
                                             int frameNum)
For each range in ranges, store the size in world coordinates

Parameters:
splitAxis - The split axis that the range set represents
frameNum - The current frame number
Returns:
An array of range sizes, in world coordinates.

getUnshrinkableTotal

public abstract double getUnshrinkableTotal(AccordionDrawer ad,
                                            SplitAxis splitAxis,
                                            int frameNum)
Return the quantity of world space that may not be shrunk by a stretching operation.

Parameters:
ad - The accordion drawer to use for growing/shrinking
splitAxis - The axis (X or Y) for growing/shrinking
frameNum - Current frame number
Returns:
The total world space that may not be shrunk after stretching.

onlyThisAD

public abstract AbstractRangeList onlyThisAD(AccordionDrawer d)
Cuts the ranges into a subset of only ranges in the given drawer.

Parameters:
d - The drawer we wish to get the ranges in.
Returns:
A new range list populated with only ranges from the given drawer

flipRangeToShrink

public abstract AbstractRangeList flipRangeToShrink(int xy,
                                                    AccordionDrawer ad)
Reverses the ranges so we may grow the unselected ranges, performing a shrink on the selected ranges.

Parameters:
xy - The axis direction for shrinking.
ad - The drawer for shrinking (contains the split axis)
Returns:
The reverse of the ranges, or the list of unselected ranges.

setColor

public void setColor(java.awt.Color c)
Sets the color of the marked ranges.

Parameters:
c - The color to set the ranges, color.

getColor

public java.awt.Color getColor()
Accessor for the range color, color

Returns:
The value of color

getKey

public int getKey()
Accessor for the key value, key

Returns:
The value of key

setKey

public void setKey(int key)
Sets the key to the given value. Also sets the alpha of color to key, so we may later recover the depth of the current color, which we store in the alpha channel.

Parameters:
key - The new value of key, and the new value of the color alpha channel.

size

public int size()
Accessor for the number of ranges in the set of ranges ranges.

Returns:
The number of objects in ranges, which are the selected ranges.

setEnabled

public void setEnabled(boolean enabled)
Sets the value of enabled, turning on (true) or off (false) the rendering of the group defined by this abstract range list.

Parameters:
enabled - The new value of enabled.

isEnabled

public boolean isEnabled()
Accessor for the value of enabled

Returns:
The value of enabled