apollo.gui.drawable
Class DrawableFeatureSet

java.lang.Object
  extended by apollo.gui.drawable.DrawableSeqFeature
      extended by apollo.gui.drawable.DrawableFeatureSet
All Implemented Interfaces:
Drawable, DrawableSetI, SelectableI
Direct Known Subclasses:
DrawableEnsemblFeatureSet, DrawableGeneFeatureSet, DrawablePrimerSet, DrawableResultFeatureSet

public class DrawableFeatureSet
extends DrawableSeqFeature
implements DrawableSetI

A drawable for drawing a feature set. It implements FeatureSetI. While this can be convenient, it is also inconvienient because it blurs model and view. When you have a FeatureSetI, you dont know if its in fact a DrawableFeatureSet or a FeatureSet from the datamodel. One has to do instanceof's to figure this out. My suggestion would be to remove DrawableFeatureSet implementing FeatureSetI to have a cleaner split between model and view. Other opinions? It can still retain all the wrapped functions if thats handy, it just wouldnt parade as a FeatureSetI any longer.


Field Summary
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class apollo.gui.drawable.DrawableSeqFeature
boxBounds, DECORATED, draw_level, drawable_parent, feature, flags, HIGHLIGHTED, is_drawn, LABELED, LEFTEDGE, RIGHTEDGE, SELECTED, VISIBLE
 
Constructor Summary
DrawableFeatureSet()
          Since this is not an abstract class, allow it to be used as a visible drawn feature
DrawableFeatureSet(boolean drawn)
           
DrawableFeatureSet(FeatureSetI feature, boolean drawn)
           
 
Method Summary
 void addDrawable(Drawable dsf)
           
 Drawable addFeatureDrawable(SeqFeatureI sf)
          Create a drawable for sf(createDrawable) and add it as a child (addDrawable).
 void addHighlights(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager)
          highlights edges and box around if isHighlighted
 Drawable createDrawable(SeqFeatureI sf)
           
 void deleteDrawable(Drawable sf)
          Default no-op implementation, DrawableSeqFeature doesnt have children, do nothing.
 boolean draw(java.awt.Graphics g, Transformer transformer, TierManagerI manager)
          draw method using the Transformer to do coord conversions.
 boolean draw(java.awt.Graphics g, Transformer transformer, TierManagerI manager, PixelMaskI mask)
          Need to change cached feature property - resynch with feature and synch up descendants
protected  boolean drawDashedLines(java.awt.Graphics g, java.awt.Rectangle boxBounds, Transformer transformer, TierManagerI manager, java.awt.Color color, int y_center)
           
 void drawSelected(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)
           
 Drawable findDrawable(SeqFeatureI sf)
           
 FeatureList findFeaturesByAllNames(java.lang.String name)
           
 FeatureList findFeaturesByAllNames(java.lang.String name, boolean useRegExp)
           
 Drawable getDrawableAt(int i)
          Returns a DrawableSeqFeature (not model SeqFeature)
 java.util.Vector getDrawables()
          A Vector of DrawableSeqFeatures is returned, not model SeqFeatures.
 FeatureSetI getFeatureSet()
          returns the underlying FeatureSetI model.
 void initSet()
          feature holds a reference to the real feature.
 void repairFeatureSet(AnnotationCompoundEvent ace)
          Compound events dig out children
 void repairFeatureSet(FeatureChangeEvent ce)
          this handles several types of repairs.
 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.
 void setLabeled(boolean state)
           
 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.
 int size()
           
 void sort(int sortStrand)
           
 java.lang.String toString_mv()
           
 
Methods inherited from class apollo.gui.drawable.DrawableSeqFeature
accept, addDecorations, contains, drawMissing, drawStartAndStopCodons, feature_draw, fontColorForBackground, getBoxBounds, getCharY, getCodonX, getDisplayLabel, getDrawableColor, getDrawLevel, getEnd, getFeature, getFeatureProperty, getFeatureType, getHigh, getLeft, getLeftmostVisible, getLow, getName, getRefDrawable, getRight, getSize, getStart, getStrand, getTierIndex, getType, getYCentre, getYSpace, intersects, isDecorated, isDrawn, isForwardStrand, isHighlighted, isLabeled, isLeftEdge, isRightEdge, isSelected, isVisible, sameFeature, setBoxBounds, setDrawLevel, setDrawn, setLabeled, setRefDrawable, synchFeatureProperty, wantToDraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface apollo.gui.drawable.Drawable
getBoxBounds, getDisplayLabel, getDrawLevel, getEnd, getFeature, getFeatureProperty, getHigh, getLeft, getLow, getName, getRefDrawable, getRight, getSize, getStart, getStrand, getTierIndex, getType, intersects, isDecorated, isDrawn, isVisible, setBoxBounds, setDrawLevel, setDrawn, setRefDrawable, synchFeatureProperty
 
Methods inherited from interface apollo.gui.SelectableI
isSelected
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

DrawableFeatureSet

public DrawableFeatureSet()
Since this is not an abstract class, allow it to be used as a visible drawn feature


DrawableFeatureSet

public DrawableFeatureSet(boolean drawn)

DrawableFeatureSet

public DrawableFeatureSet(FeatureSetI feature,
                          boolean drawn)
Method Detail

initSet

public void initSet()
feature holds a reference to the real feature. This is used to // generate the tree of DrawableFeatureSets and DrawableSeqFeatures // to represent it. // // Note that by using createDrawableFeature and createDrawableSet // classes inherited from DrawableFeatureSet can generate a correctly // typed tree using the initSet in DrawableFeatureSet. // // createDrawableSet will produce an indirect recursive call to initSet // in the descent of the FeatureSet tree. // // Only features which are to be drawn have their FeatureProperty set.


addFeatureDrawable

public Drawable addFeatureDrawable(SeqFeatureI sf)
Create a drawable for sf(createDrawable) and add it as a child (addDrawable). Added new restriction - only add if dont already have a child drawable for sf. On splits an sf can actually get added twice (for add gene and move trans/exon) this may be ammended in the future. But anyways theres no reason a set should have the same child twice (at least that i can think of) so its not an unreasonable restriction to enforce. the findDrawable really slows things down - especially noticeable for large datasets so this should be fixed up stream in the split not here - taking it out - another alternative would be to have 2 separate methods (or a flag) since the split problem comes from repairFeatSet i think

Specified by:
addFeatureDrawable in interface DrawableSetI

createDrawable

public Drawable createDrawable(SeqFeatureI sf)

addDrawable

public void addDrawable(Drawable dsf)
Specified by:
addDrawable in interface DrawableSetI

sort

public void sort(int sortStrand)

setFeature

public void setFeature(SeqFeatureI feature)
Description copied from class: DrawableSeqFeature
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
Overrides:
setFeature in class DrawableSeqFeature

draw

public boolean draw(java.awt.Graphics g,
                    Transformer transformer,
                    TierManagerI manager,
                    PixelMaskI mask)
Need to change cached feature property - resynch with feature and synch up descendants

Specified by:
draw in interface Drawable
Overrides:
draw in class DrawableSeqFeature

draw

public boolean draw(java.awt.Graphics g,
                    Transformer transformer,
                    TierManagerI manager)
draw method using the Transformer to do coord conversions.

Specified by:
draw in interface Drawable
Overrides:
draw in class DrawableSeqFeature

addHighlights

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

Overrides:
addHighlights in class DrawableSeqFeature

drawSelected

public void drawSelected(java.awt.Graphics g,
                         java.awt.Rectangle boxBounds,
                         Transformer transformer,
                         TierManagerI manager)
Overrides:
drawSelected in class DrawableSeqFeature

drawDashedLines

protected boolean drawDashedLines(java.awt.Graphics g,
                                  java.awt.Rectangle boxBounds,
                                  Transformer transformer,
                                  TierManagerI manager,
                                  java.awt.Color color,
                                  int y_center)

drawUnselected

public void drawUnselected(java.awt.Graphics g,
                           java.awt.Rectangle boxBounds,
                           Transformer transformer,
                           TierManagerI manager)
Overrides:
drawUnselected in class DrawableSeqFeature

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
Overrides:
setSelected in class DrawableSeqFeature

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
Overrides:
setVisible in class DrawableSeqFeature

setLabeled

public void setLabeled(boolean state)
Overrides:
setLabeled in class DrawableSeqFeature

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
Overrides:
setTierIndex in class DrawableSeqFeature

size

public int size()
Specified by:
size in interface DrawableSetI

deleteDrawable

public void deleteDrawable(Drawable sf)
Description copied from class: DrawableSeqFeature
Default no-op implementation, DrawableSeqFeature doesnt have children, do nothing. Overridded by DrawableFeatureSet

Specified by:
deleteDrawable in interface Drawable
Specified by:
deleteDrawable in interface DrawableSetI
Overrides:
deleteDrawable in class DrawableSeqFeature

getDrawableAt

public Drawable getDrawableAt(int i)
Returns a DrawableSeqFeature (not model SeqFeature)

Specified by:
getDrawableAt in interface DrawableSetI

getDrawables

public java.util.Vector getDrawables()
A Vector of DrawableSeqFeatures is returned, not model SeqFeatures. (the DrawableSeqFeatures all point to model of course)

Specified by:
getDrawables in interface DrawableSetI

findFeaturesByAllNames

public FeatureList findFeaturesByAllNames(java.lang.String name)

findFeaturesByAllNames

public FeatureList findFeaturesByAllNames(java.lang.String name,
                                          boolean useRegExp)

findDrawable

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

repairFeatureSet

public void repairFeatureSet(AnnotationCompoundEvent ace)
Compound events dig out children


repairFeatureSet

public void repairFeatureSet(FeatureChangeEvent ce)
this handles several types of repairs. ADD, MERGE, SPLIT, DELETE, LIMITS, and SYNC the purpose of the repairs is to keep the drawables in sync with the additions and deletes coming from the annotation editor Takes in both AnnotationChangeEvents and ResultChangeEvents

Specified by:
repairFeatureSet in interface DrawableSetI

toString_mv

public java.lang.String toString_mv()

setEdgeHighlights

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

setHighlighted

public void setHighlighted(boolean state)
Description copied from class: DrawableSeqFeature
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
Overrides:
setHighlighted in class DrawableSeqFeature

getFeatureSet

public FeatureSetI getFeatureSet()
returns the underlying FeatureSetI model. getFeature returns the underlying FeatureSetI as well but it returns it as a SeqFeatureI. This returns model NOT drawable.

Specified by:
getFeatureSet in interface DrawableSetI