apollo.gui.genomemap
Class TierView

java.lang.Object
  extended by apollo.gui.genomemap.LinearView
      extended by apollo.gui.genomemap.ManagedView
          extended by apollo.gui.genomemap.TierView
All Implemented Interfaces:
ControlledObjectI, TierManagerListener, DropTargetViewI, ManagedViewI, PickViewI, TierViewI, ViewI, java.awt.event.AdjustmentListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
FeatureView, SiteView

public abstract class TierView
extends ManagedView
implements java.awt.event.AdjustmentListener, ControlledObjectI, DropTargetViewI, PickViewI, TierManagerListener, TierViewI

This class is the base class for FeatureView and SiteView. It is abstract because it doesn't implement getTierData() and would be non functional even if it did because it doesn't create the manager object anywhere. The reason it has been separated from FeatureView is to enable the use of the Scrolling and Tier functionality in the SequenceView, which although different to the FeatureView is basically a TierView where each tier is a piece of the sequence, so we can use the Tier and Scroll functionality and just change the meaning of tiers by creating a new TierManager and changing all the draw methods. Presently scrolling is done by mapping the scroll value to a tier number. Tiers run in opposite directions on forward and reverse strands. The tier number has to be inverted on the forward strand to be consistent with how the reverse strand is scrolled. Also this means that ScrollableTierView has to know about strand, which is a little funny because its subclass SequenceView is unstranded. This makes the code a bit confusing. I think a better way would be to not scroll by tier, but just by y values. A view would set itself according to the y values put out by the scroll bar. Im guessing that one of the reasons to do scrolling by tier was to have a unit of scrolling be a tier, but this can still be achieved with scrolling by y value, it would just round it to the nearest tier. This would be a bit of a work I think so Im putting it off for now. I'm also curious what others think. - MG

See Also:
Serialized Form

Field Summary
protected  Controller controller
           
protected  java.util.Vector dragSources
           
protected  boolean rightSide
           
protected  SelectionManager selectionManager
           
protected  javax.swing.JScrollBar vScroll
           
protected  boolean vscrollable
           
 
Fields inherited from class apollo.gui.genomemap.ManagedView
dropSpaceSize, leadSpaceSize, logger, manager, visibleDrawables
 
Fields inherited from class apollo.gui.genomemap.LinearView
apollo_panel, backgroundColour, debug, foregroundColour, graphics, limitsSet, transformer, transparent, viewBounds, visibilityListeners, visible
 
Constructor Summary
TierView(javax.swing.JComponent ap, java.lang.String name, SelectionManager selectionManager)
           
 
Method Summary
protected  void addScrollBar()
           
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
           
 boolean allowsTierDrags()
          Whether this view allows tier dragging
 boolean beginTierDrag(java.awt.event.MouseEvent evt)
          Start a tier drag
protected  void changeTierHeight(int change)
           
 void clear()
           
 DragViewI createDragView(java.awt.event.MouseEvent evt, Selection view_selection)
          Interface of method required for starting a drag from this TierView
 void decrementTierHeight()
           
protected  java.util.Vector drawablesForDrag(Selection selection)
          Returns a FeatureSet of Drawables/view, not a model FeatureSet.
 void endTierDrag(java.awt.event.MouseEvent evt)
          end a tier drag
 java.util.Vector findDrawables(java.awt.Point pnt)
          CANT do selection here as this is called for mouse over as well!
 java.util.Vector findDrawables(java.awt.Rectangle rect)
          Finds all the sites in rect and creates SiteCodon for them.
protected abstract  java.util.Vector findDrawables(java.awt.Rectangle rect, boolean select_filter)
           
 FeatureList findFeatures(java.awt.Point pnt)
          returns a FeatureList of SeqFeatureI instances that fall beneath the point passed in
 FeatureList findFeatures(java.awt.Rectangle rect)
          returns a FeatureList of SeqFeatureI instances (model not drawables) overlap any of the areas in the Vector of rectangles that is passed in
 FeatureList findFeatures(java.util.Vector rects)
          returns a FeatureList of SeqFeatureI instances that overlap any of the areas in the Vector of rectangles that is passed in
 Selection findFeaturesForSelection(java.awt.Point p, boolean selectParents)
          Find geared to selection.
 Selection findFeaturesForSelection(java.awt.Rectangle rect)
          Same as above for rectangle, no selectParents needed
protected abstract  Selection findFeaturesForSelection(java.awt.Rectangle rect, boolean selectParents)
           
 void fireViewEvent(int type)
           
 Controller getController()
          Gets the Controller for the object
 java.lang.Object getControllerWindow()
          Shouldnt this return Window - would we ever want a non-window?
protected  int getInvertedScrollbarValue()
           
 int getLowestVisibleTier()
          Get the lowest visible tier.
protected  int getMaxScrollbarValue()
           
protected  int getMinScrollbarValue()
           
protected  int getScrollbarValue()
           
abstract  Selection getViewSelection(Selection selection)
          given the entirety of what is currently selected, remove anything that doesn't belong to this view and return the remaining selections.
protected  int getVisibleScrollbarValue()
           
 boolean handleTierManagerEvent(TierManagerEvent evt)
           
 void incrementTierHeight()
           
 boolean interpretDrop(DragViewI dragView, java.awt.event.MouseEvent evt)
           
 boolean interpretDrop(DragViewI dragView, java.awt.event.MouseEvent evt, boolean doFlag, java.lang.StringBuffer action)
           
protected  boolean isDownOrientation()
          Down Orientation happens with reverse strand normal and forward strand in reverse comp (below axis)
protected  boolean isUpOrientation()
          Up orientation happens with forward strand normal and reverse strand in rev comp, its above the axis
 boolean isValidDragSource(TierViewI view)
           
 void moveScrollbarByWheelAmount(int nClick)
           
 boolean needsAutoRemoval()
          If getControllerWindow is non null, and needsAutoRemoval is true then Controller will automatically remove the ControlledObjectI as a listener when its ControllerWindow is closing.
 void paintView()
          Just repaints scrollbars
 void printScrollValues()
           
protected  void putScrollAtStart()
          This is to set a view in its vertical "start" position, which is opposite for the 2 strands.
 void registerDragSource(TierViewI view)
           
 void setController(Controller c)
          Sets the Controller for the object
 void setLowestVisibleTier(long tier)
          Set the lowest visible tier.
protected  void setScrollbarValue(int val)
           
 void setScrollHack(boolean value)
           
 void setScrollSide(int side)
           
 void setScrollValues()
           
 void setScrollVisibility(boolean state)
           
 void setSelectionManager(SelectionManager selectionManager)
           
 void setTierManager(FeatureTierManager ftm)
           
 void setVisible(boolean state)
          Set whether or not a view is visible
 void setVScrollable(boolean state)
           
 void setYOrientation(int direction)
          YOrientation gets flipped with revcomping
protected  void updateManagerHeight()
           
 void updateTierDrag(java.awt.event.MouseEvent evt)
          continue a tier drag
 
Methods inherited from class apollo.gui.genomemap.ManagedView
getDropSpaceSize, getLeadSpaceSize, getTierManager, getVisibleDrawables, getYRange, paintDrawables, setBounds, setDropSpaceSize, setLeadSpaceSize, setTierManager, setXOrientation
 
Methods inherited from class apollo.gui.genomemap.LinearView
addViewListener, addVisibilityListener, areLimitsSet, fireViewEvent, getBackgroundColour, getBounds, getCentre, getComponent, getDrawBounds, getForegroundColour, getGraphics, getLimits, getMaximum, getMinimum, getName, getPreferredSize, getSelectionRectangle, getStrand, getTransform, getVisibleRange, init, isInvalid, isTransparent, isVisible, setBackgroundColour, setCentre, setComponent, setDebug, setDrawBounds, setForegroundColour, setGraphics, setInvalidity, setLimits, setLimitsSet, setMaximum, setMinimum, setName, setStrand, setTransform, setTransparent, setVisible, setZoomFactor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface apollo.gui.genomemap.TierViewI
getVisibleDrawables
 
Methods inherited from interface apollo.gui.genomemap.ManagedViewI
getTierManager, setTierManager
 

Field Detail

vScroll

protected javax.swing.JScrollBar vScroll

vscrollable

protected boolean vscrollable

rightSide

protected boolean rightSide

controller

protected Controller controller

dragSources

protected java.util.Vector dragSources

selectionManager

protected SelectionManager selectionManager
Constructor Detail

TierView

public TierView(javax.swing.JComponent ap,
                java.lang.String name,
                SelectionManager selectionManager)
Method Detail

setSelectionManager

public void setSelectionManager(SelectionManager selectionManager)

setTierManager

public void setTierManager(FeatureTierManager ftm)

updateManagerHeight

protected void updateManagerHeight()
Overrides:
updateManagerHeight in class ManagedView

moveScrollbarByWheelAmount

public void moveScrollbarByWheelAmount(int nClick)

setYOrientation

public void setYOrientation(int direction)
YOrientation gets flipped with revcomping

Overrides:
setYOrientation in class ManagedView

addScrollBar

protected void addScrollBar()

setVisible

public void setVisible(boolean state)
Description copied from interface: ViewI
Set whether or not a view is visible

Specified by:
setVisible in interface ViewI
Overrides:
setVisible in class LinearView

paintView

public void paintView()
Just repaints scrollbars

Specified by:
paintView in interface ViewI
Overrides:
paintView in class ManagedView

setScrollSide

public void setScrollSide(int side)

incrementTierHeight

public void incrementTierHeight()
Specified by:
incrementTierHeight in interface TierViewI

decrementTierHeight

public void decrementTierHeight()
Specified by:
decrementTierHeight in interface TierViewI

changeTierHeight

protected void changeTierHeight(int change)

setLowestVisibleTier

public void setLowestVisibleTier(long tier)
Description copied from interface: TierViewI
Set the lowest visible tier.

Specified by:
setLowestVisibleTier in interface TierViewI

getLowestVisibleTier

public int getLowestVisibleTier()
Description copied from interface: TierViewI
Get the lowest visible tier.

Specified by:
getLowestVisibleTier in interface TierViewI

allowsTierDrags

public boolean allowsTierDrags()
Description copied from interface: TierViewI
Whether this view allows tier dragging

Specified by:
allowsTierDrags in interface TierViewI

beginTierDrag

public boolean beginTierDrag(java.awt.event.MouseEvent evt)
Description copied from interface: TierViewI
Start a tier drag

Specified by:
beginTierDrag in interface TierViewI

updateTierDrag

public void updateTierDrag(java.awt.event.MouseEvent evt)
Description copied from interface: TierViewI
continue a tier drag

Specified by:
updateTierDrag in interface TierViewI

endTierDrag

public void endTierDrag(java.awt.event.MouseEvent evt)
Description copied from interface: TierViewI
end a tier drag

Specified by:
endTierDrag in interface TierViewI

handleTierManagerEvent

public boolean handleTierManagerEvent(TierManagerEvent evt)
Specified by:
handleTierManagerEvent in interface TierManagerListener

interpretDrop

public boolean interpretDrop(DragViewI dragView,
                             java.awt.event.MouseEvent evt)
Specified by:
interpretDrop in interface DropTargetViewI

interpretDrop

public boolean interpretDrop(DragViewI dragView,
                             java.awt.event.MouseEvent evt,
                             boolean doFlag,
                             java.lang.StringBuffer action)
Specified by:
interpretDrop in interface DropTargetViewI

registerDragSource

public void registerDragSource(TierViewI view)
Specified by:
registerDragSource in interface DropTargetViewI

isValidDragSource

public boolean isValidDragSource(TierViewI view)
Specified by:
isValidDragSource in interface DropTargetViewI

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

isDownOrientation

protected boolean isDownOrientation()
Down Orientation happens with reverse strand normal and forward strand in reverse comp (below axis)


isUpOrientation

protected boolean isUpOrientation()
Up orientation happens with forward strand normal and reverse strand in rev comp, its above the axis


putScrollAtStart

protected void putScrollAtStart()
This is to set a view in its vertical "start" position, which is opposite for the 2 strands. This would be true even if we were not tier based.


setScrollbarValue

protected void setScrollbarValue(int val)

getMaxScrollbarValue

protected int getMaxScrollbarValue()

getVisibleScrollbarValue

protected int getVisibleScrollbarValue()

getMinScrollbarValue

protected int getMinScrollbarValue()

getScrollbarValue

protected int getScrollbarValue()

getInvertedScrollbarValue

protected int getInvertedScrollbarValue()

setScrollHack

public void setScrollHack(boolean value)

setVScrollable

public void setVScrollable(boolean state)

fireViewEvent

public void fireViewEvent(int type)

setScrollValues

public void setScrollValues()

printScrollValues

public void printScrollValues()

setScrollVisibility

public void setScrollVisibility(boolean state)

getController

public Controller getController()
Description copied from interface: ControlledObjectI
Gets the Controller for the object

Specified by:
getController in interface ControlledObjectI

getControllerWindow

public java.lang.Object getControllerWindow()
Description copied from interface: ControlledObjectI
Shouldnt this return Window - would we ever want a non-window?

Specified by:
getControllerWindow in interface ControlledObjectI

needsAutoRemoval

public boolean needsAutoRemoval()
Description copied from interface: ControlledObjectI
If getControllerWindow is non null, and needsAutoRemoval is true then Controller will automatically remove the ControlledObjectI as a listener when its ControllerWindow is closing. If getControllerWindow is null needsAutoRemoval is meaningless. Rename this removeAsListenerOnWindowClose?

Specified by:
needsAutoRemoval in interface ControlledObjectI

setController

public void setController(Controller c)
Description copied from interface: ControlledObjectI
Sets the Controller for the object

Specified by:
setController in interface ControlledObjectI

findFeatures

public FeatureList findFeatures(java.awt.Point pnt)
returns a FeatureList of SeqFeatureI instances that fall beneath the point passed in


findFeatures

public FeatureList findFeatures(java.util.Vector rects)
returns a FeatureList of SeqFeatureI instances that overlap any of the areas in the Vector of rectangles that is passed in


findFeatures

public FeatureList findFeatures(java.awt.Rectangle rect)
returns a FeatureList of SeqFeatureI instances (model not drawables) overlap any of the areas in the Vector of rectangles that is passed in


findFeaturesForSelection

public Selection findFeaturesForSelection(java.awt.Point p,
                                          boolean selectParents)
Find geared to selection. The SelectionItems in the Selection are model(SeqFeatureI) but they have the associated drawable attached as a listener, so when the SelectionItem is selected it will tell its drawable listener to select. This achieves 2 goals: 1) Keeps the Selection model based so someones own set of drawables is not being passed around 2) With the drawables attached we dont have to refind them when receiving the feature selection event that came from us, which is rather inefficient and slow part of PickViewI interface. Can not do actual selection here. If part of previous selection it will get deselected after it gets selected.

Specified by:
findFeaturesForSelection in interface PickViewI

findFeaturesForSelection

public Selection findFeaturesForSelection(java.awt.Rectangle rect)
Description copied from interface: PickViewI
Same as above for rectangle, no selectParents needed

Specified by:
findFeaturesForSelection in interface PickViewI

findFeaturesForSelection

protected abstract Selection findFeaturesForSelection(java.awt.Rectangle rect,
                                                      boolean selectParents)

findDrawables

public java.util.Vector findDrawables(java.awt.Point pnt)
CANT do selection here as this is called for mouse over as well!


findDrawables

public java.util.Vector findDrawables(java.awt.Rectangle rect)
Finds all the sites in rect and creates SiteCodon for them. Returns vector of SiteCodons The SiteCodons are not drawn. Sites are notified when a SiteCodon is selected.


findDrawables

protected abstract java.util.Vector findDrawables(java.awt.Rectangle rect,
                                                  boolean select_filter)

clear

public void clear()
Specified by:
clear in interface ViewI
Overrides:
clear in class ManagedView

drawablesForDrag

protected java.util.Vector drawablesForDrag(Selection selection)
Returns a FeatureSet of Drawables/view, not a model FeatureSet. This is what drag view expects which is what this is used for. This could perhaps go in Selection?


getViewSelection

public abstract Selection getViewSelection(Selection selection)
given the entirety of what is currently selected, remove anything that doesn't belong to this view and return the remaining selections. This used to be handled in the Selection class, but it didn't quite work, because the 'source'=='where it was originally selected' which, may or may not be, the same as this view.

Specified by:
getViewSelection in interface TierViewI

createDragView

public DragViewI createDragView(java.awt.event.MouseEvent evt,
                                Selection view_selection)
Description copied from interface: TierViewI
Interface of method required for starting a drag from this TierView

Specified by:
createDragView in interface TierViewI