apollo.gui.drawable
Class DrawableSeqFeature

java.lang.Object
  extended by apollo.gui.drawable.DrawableSeqFeature
All Implemented Interfaces:
Drawable, SelectableI
Direct Known Subclasses:
DoubleHeadedArrow, DrawableFeatureSet, DrawableGeneSeqFeature, DrawableHalfArrow, DrawableResultSeqFeature, PromoterGlyph, SiteCodon, ThinRectangle, Triangle, Zigzag

public class DrawableSeqFeature
extends java.lang.Object
implements Drawable, SelectableI

A drawable for drawing basic sequence features.


Field Summary
protected  java.awt.Rectangle boxBounds
          Allocate a rectangle to put bounding box in because instantiation // is so slow.
protected static byte DECORATED
           
protected  int draw_level
           
protected  Drawable drawable_parent
           
protected  SeqFeatureI feature
           
protected  byte flags
           
protected static byte HIGHLIGHTED
           
protected  boolean is_drawn
           
protected static byte LABELED
           
protected static byte LEFTEDGE
           
protected static org.apache.log4j.Logger logger
           
protected static byte RIGHTEDGE
           
protected static byte SELECTED
           
protected static byte VISIBLE
           
 
Constructor Summary
DrawableSeqFeature(boolean drawn)
           
DrawableSeqFeature(SeqFeatureI feature, boolean drawn)
           
 
Method Summary
 void accept(Visitor visitor)
          General implementation of Visitor pattern.
protected  void addDecorations(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
          draw in label and codons
 void addHighlights(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
          highlights edges and box around if isHighlighted
 boolean contains(java.awt.Point point, Transformer transformer, TierManagerI manager)
           
 void deleteDrawable(Drawable child)
          Default no-op implementation, DrawableSeqFeature doesnt have children, do nothing.
 boolean draw(java.awt.Graphics g, Transformer transformer, TierManagerI manager)
          This method draws the feature on the Graphics using a Transformer for coordinate transformations.
 boolean draw(java.awt.Graphics g, Transformer transformer, TierManagerI manager, PixelMaskI mask)
          This method draws the feature on the Graphics using a Transformer for coordinate transformations.
protected  void drawMissing(java.awt.Graphics g, java.awt.Rectangle boxBounds, boolean pointRight, int edge, java.awt.Color color, java.awt.Color backgroundColour)
           
 void drawSelected(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
           
 void drawStartAndStopCodons(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
           
 void drawUnselected(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
           
protected  void feature_draw(java.awt.Graphics g, Transformer transformer, TierManagerI manager, java.awt.Rectangle boxBounds)
           
 Drawable findDrawable(SeqFeatureI sf)
           
 java.awt.Color fontColorForBackground(java.awt.Color bgColor)
           
 java.awt.Rectangle getBoxBounds()
           
protected  int getCharY(java.awt.FontMetrics fm, java.awt.Rectangle box)
          Return y value for writing characters in the box passed in,
protected  int getCodonX(Transformer transformer, int x_position)
           
 java.lang.String getDisplayLabel()
           
protected  java.awt.Color getDrawableColor()
           
 int getDrawLevel()
          returns the number of levels in the hierarchy that this will draw
 int getEnd()
           
 SeqFeatureI getFeature()
          each drawable contains the actual datamodel for that feature and must support both setting and getting the actual datamodel
 FeatureProperty getFeatureProperty()
          features FeautureProperty.
protected  FeatureProperty getFeatureType(java.lang.String type)
          Convenience fn.
 int getHigh()
           
 int getLeft(Transformer transformer)
           
protected  int getLeftmostVisible(Transformer transformer)
           
 int getLow()
           
 java.lang.String getName()
           
 Drawable getRefDrawable()
           
 int getRight(Transformer transformer)
           
 int getSize(Transformer transformer, TierManagerI manager)
           
 int getStart()
          these are for ease of use and pass through to the actual datamodel for the feature
 int getStrand()
           
 int getTierIndex(TierManagerI manager)
          This returns the variable called tier_index so i renamed to getTierIndex - hope thats ok.
 java.lang.String getType()
           
 int getYCentre(java.awt.Rectangle boxBounds)
           
 int getYSpace(Transformer transformer, TierManagerI manager)
           
 boolean intersects(java.awt.Rectangle pixrect, Transformer transformer, TierManagerI manager)
           
 boolean isDecorated()
           
 boolean isDrawn()
          returns true if FeatureSetI is really just a holder.
 boolean isForwardStrand()
           
 boolean isHighlighted()
           
 boolean isLabeled()
           
 boolean isLeftEdge()
           
 boolean isRightEdge()
           
 boolean isSelected()
          Determine if this Drawable is currently selected.
 boolean isVisible()
          Determine if this Drawable is to be drawn.
protected  boolean sameFeature(SeqFeatureI one, SeqFeatureI two)
           
 void setBoxBounds(java.awt.Rectangle r)
           
 void setDrawLevel(int level)
           
 void setDrawn(boolean drawn)
           
 void setEdgeHighlights(int[] edges, boolean state, Transformer transformer)
           
 void setFeature(SeqFeatureI feature)
          Part of Drawable interface.
 void setHighlighted(boolean state)
          I believe the RefFeature that is often stored is actually a DrawableFeatureSet as DrawableFeatureSet is a SeqFeatureI so to get your Drawable parent one would cast (DrawableFeatureSet)getRefFeature() My qualm here is drawables and seqFeatureI/models being muddled.
protected  void setLabeled()
           
 void setLabeled(boolean state)
           
 void setRefDrawable(Drawable dfs)
           
 void setSelected(boolean state)
          Set whether this Drawable is currently selected or not.
 void setTierIndex(int index)
          Set the tier on which this Drawable resides
 void setVisible(boolean state)
          Set whether this Drawable is to be drawn or not.
 void synchFeatureProperty()
          Need to change cached feature property - resynch with feature
protected  boolean wantToDraw(java.awt.Graphics g, TierManagerI manager, Transformer transformer, java.awt.Rectangle boxBounds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

VISIBLE

protected static byte VISIBLE

SELECTED

protected static byte SELECTED

HIGHLIGHTED

protected static byte HIGHLIGHTED

LEFTEDGE

protected static byte LEFTEDGE

RIGHTEDGE

protected static byte RIGHTEDGE

LABELED

protected static byte LABELED

DECORATED

protected static byte DECORATED

feature

protected SeqFeatureI feature

drawable_parent

protected Drawable drawable_parent

flags

protected byte flags

boxBounds

protected java.awt.Rectangle boxBounds
Allocate a rectangle to put bounding box in because instantiation // is so slow. But I dont think this boxBounds is used anywhwere, all // the boxBounds are passed in - am i missing something - MG


draw_level

protected int draw_level

is_drawn

protected boolean is_drawn
Constructor Detail

DrawableSeqFeature

public DrawableSeqFeature(boolean drawn)

DrawableSeqFeature

public DrawableSeqFeature(SeqFeatureI feature,
                          boolean drawn)
Method Detail

setDrawn

public void setDrawn(boolean drawn)
Specified by:
setDrawn in interface Drawable

getDrawLevel

public int getDrawLevel()
Description copied from interface: Drawable
returns the number of levels in the hierarchy that this will draw

Specified by:
getDrawLevel in interface Drawable

setDrawLevel

public void setDrawLevel(int level)
Specified by:
setDrawLevel in interface Drawable

getFeature

public SeqFeatureI getFeature()
Description copied from interface: Drawable
each drawable contains the actual datamodel for that feature and must support both setting and getting the actual datamodel

Specified by:
getFeature in interface Drawable

setFeature

public void setFeature(SeqFeatureI feature)
Part of Drawable interface. Currently only called from constructor and DrawableFeatureSet. Is there a scenario where we would publicly change the model of a drawable? It seems like a drawable reason for being comes out of a model object, and ya probably arent going to slip in a new model to a drawable. so im wondering if this needs to be part of drawable interface and perhaps this method should be protected? Subclasses overriding setFeature should call super.setFeature to get featureProperty set

Specified by:
setFeature in interface Drawable

synchFeatureProperty

public void synchFeatureProperty()
Need to change cached feature property - resynch with feature

Specified by:
synchFeatureProperty in interface Drawable

getLeft

public int getLeft(Transformer transformer)
Specified by:
getLeft in interface Drawable

getRight

public int getRight(Transformer transformer)
Specified by:
getRight in interface Drawable

getTierIndex

public int getTierIndex(TierManagerI manager)
This returns the variable called tier_index so i renamed to getTierIndex - hope thats ok. if tier_index == -1 then hasnt got a tier yet. synchDrawablesWithTiers assigns all tiers this happens when doing a find on a feature that has never been in view

Specified by:
getTierIndex in interface Drawable

getBoxBounds

public java.awt.Rectangle getBoxBounds()
Specified by:
getBoxBounds in interface Drawable

setBoxBounds

public void setBoxBounds(java.awt.Rectangle r)
Specified by:
setBoxBounds in interface Drawable

draw

public boolean draw(java.awt.Graphics g,
                    Transformer transformer,
                    TierManagerI manager,
                    PixelMaskI mask)
This method draws the feature on the Graphics using a Transformer for coordinate transformations. There are minimum size limits set the displayed feature so that it is not too small to be seen (3 pixels X and Y).

Specified by:
draw in interface Drawable

draw

public boolean draw(java.awt.Graphics g,
                    Transformer transformer,
                    TierManagerI manager)
This method draws the feature on the Graphics using a Transformer for coordinate transformations. There are minimum size limits set the displayed feature so that it is not too small to be seen (3 pixels X and Y).

Specified by:
draw in interface Drawable

wantToDraw

protected boolean wantToDraw(java.awt.Graphics g,
                             TierManagerI manager,
                             Transformer transformer,
                             java.awt.Rectangle boxBounds)

feature_draw

protected void feature_draw(java.awt.Graphics g,
                            Transformer transformer,
                            TierManagerI manager,
                            java.awt.Rectangle boxBounds)

addHighlights

public void addHighlights(java.awt.Graphics g,
                          java.awt.Rectangle boxBounds,
                          Transformer transformer,
                          TierManagerI manager)
highlights edges and box around if isHighlighted


addDecorations

protected void addDecorations(java.awt.Graphics g,
                              java.awt.Rectangle boxBounds,
                              Transformer transformer,
                              TierManagerI manager)
draw in label and codons


drawStartAndStopCodons

public void drawStartAndStopCodons(java.awt.Graphics g,
                                   java.awt.Rectangle boxBounds,
                                   Transformer transformer,
                                   TierManagerI manager)

getCodonX

protected int getCodonX(Transformer transformer,
                        int x_position)

drawMissing

protected void drawMissing(java.awt.Graphics g,
                           java.awt.Rectangle boxBounds,
                           boolean pointRight,
                           int edge,
                           java.awt.Color color,
                           java.awt.Color backgroundColour)

drawSelected

public void drawSelected(java.awt.Graphics g,
                         java.awt.Rectangle boxBounds,
                         Transformer transformer,
                         TierManagerI manager)

getDrawableColor

protected java.awt.Color getDrawableColor()

drawUnselected

public void drawUnselected(java.awt.Graphics g,
                           java.awt.Rectangle boxBounds,
                           Transformer transformer,
                           TierManagerI manager)

getYSpace

public int getYSpace(Transformer transformer,
                     TierManagerI manager)

getYCentre

public int getYCentre(java.awt.Rectangle boxBounds)

getSize

public int getSize(Transformer transformer,
                   TierManagerI manager)
Specified by:
getSize in interface Drawable

setTierIndex

public void setTierIndex(int index)
Description copied from interface: Drawable
Set the tier on which this Drawable resides

Specified by:
setTierIndex in interface Drawable

setSelected

public void setSelected(boolean state)
Description copied from interface: SelectableI
Set whether this Drawable is currently selected or not.

Specified by:
setSelected in interface SelectableI

isSelected

public boolean isSelected()
Description copied from interface: SelectableI
Determine if this Drawable is currently selected.

Specified by:
isSelected in interface SelectableI

setVisible

public void setVisible(boolean state)
Description copied from interface: Drawable
Set whether this Drawable is to be drawn or not.

Specified by:
setVisible in interface Drawable

isVisible

public boolean isVisible()
Description copied from interface: Drawable
Determine if this Drawable is to be drawn.

Specified by:
isVisible in interface Drawable

getFeatureProperty

public FeatureProperty getFeatureProperty()
features FeautureProperty. For efficiency reasons we store this rather than query the feature for it. querying the feature for it every time causes gui things (like zooming) to slow down. It is set with setFeature

Specified by:
getFeatureProperty in interface Drawable

getFeatureType

protected FeatureProperty getFeatureType(java.lang.String type)
Convenience fn. Queries PropertyScheme for FeatureProperty of type. If type not found prints error msg.


setHighlighted

public void setHighlighted(boolean state)
I believe the RefFeature that is often stored is actually a DrawableFeatureSet as DrawableFeatureSet is a SeqFeatureI so to get your Drawable parent one would cast (DrawableFeatureSet)getRefFeature() My qualm here is drawables and seqFeatureI/models being muddled. It is not obvious that getRefFeature() actually returns a drawable, I figured it out by looking at other snips of code where the casting happens. Its more confused by the fact that getFeature actually returns the model/SeqFeatureI. I propose a refactor where the model and drawables(usually called view) are separated. - MG

Specified by:
setHighlighted in interface Drawable

setLabeled

protected void setLabeled()

setLabeled

public void setLabeled(boolean state)

isHighlighted

public boolean isHighlighted()

isDecorated

public boolean isDecorated()
Specified by:
isDecorated in interface Drawable

isLabeled

public boolean isLabeled()

isLeftEdge

public boolean isLeftEdge()

isRightEdge

public boolean isRightEdge()

setEdgeHighlights

public void setEdgeHighlights(int[] edges,
                              boolean state,
                              Transformer transformer)
Specified by:
setEdgeHighlights in interface Drawable

contains

public boolean contains(java.awt.Point point,
                        Transformer transformer,
                        TierManagerI manager)

intersects

public boolean intersects(java.awt.Rectangle pixrect,
                          Transformer transformer,
                          TierManagerI manager)
Specified by:
intersects in interface Drawable

getDisplayLabel

public java.lang.String getDisplayLabel()
Specified by:
getDisplayLabel in interface Drawable

findDrawable

public Drawable findDrawable(SeqFeatureI sf)
Specified by:
findDrawable in interface Drawable

sameFeature

protected boolean sameFeature(SeqFeatureI one,
                              SeqFeatureI two)

getCharY

protected int getCharY(java.awt.FontMetrics fm,
                       java.awt.Rectangle box)
Return y value for writing characters in the box passed in,

Parameters:
fm - FontMetrics for writing the text
box - Rectangle to draw/write into

getLeftmostVisible

protected int getLeftmostVisible(Transformer transformer)

isDrawn

public boolean isDrawn()
Description copied from interface: Drawable
returns true if FeatureSetI is really just a holder. Its not a "real feature". It cant be drawn. e.g. Gene is not a holder, the FeatureSet that holds all of the Genes is a holder, its sole purpose is to hold all the genes.

Specified by:
isDrawn in interface Drawable

fontColorForBackground

public java.awt.Color fontColorForBackground(java.awt.Color bgColor)

accept

public void accept(Visitor visitor)
General implementation of Visitor pattern. (see apollo.util.Visitor). -- has to be implemented here because I implement SeqFeatureI, but I do not extend SeqFeature. I throw a NotImplementedException right now. Change as necessary.


setRefDrawable

public void setRefDrawable(Drawable dfs)
Specified by:
setRefDrawable in interface Drawable

getRefDrawable

public Drawable getRefDrawable()
Specified by:
getRefDrawable in interface Drawable

getStart

public int getStart()
Description copied from interface: Drawable
these are for ease of use and pass through to the actual datamodel for the feature

Specified by:
getStart in interface Drawable

getEnd

public int getEnd()
Specified by:
getEnd in interface Drawable

getLow

public int getLow()
Specified by:
getLow in interface Drawable

getHigh

public int getHigh()
Specified by:
getHigh in interface Drawable

getStrand

public int getStrand()
Specified by:
getStrand in interface Drawable

isForwardStrand

public boolean isForwardStrand()

getType

public java.lang.String getType()
Specified by:
getType in interface Drawable

getName

public java.lang.String getName()
Specified by:
getName in interface Drawable

deleteDrawable

public void deleteDrawable(Drawable child)
Default no-op implementation, DrawableSeqFeature doesnt have children, do nothing. Overridded by DrawableFeatureSet

Specified by:
deleteDrawable in interface Drawable