else if (evt.getSource() == this.centreColumnLabelFlag)
{
centreColumnLabelFlag_stateChanged();
+ } else if (evt.getSource() == this.followMouseOverFlag)
+ {
+ mouseOverFlag_stateChanged();
}
alignPanel.paintAlignment(true);
}
+ private void mouseOverFlag_stateChanged()
+ {
+ viewport.followHighlight = followMouseOverFlag.getState();
+ // TODO: could kick the scrollTo mechanism to reset view for current searchresults.
+ }
+
private void centreColumnLabelFlag_stateChanged()
{
viewport.centreColumnLabels = centreColumnLabelFlag.getState();
CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
+ CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
+
private void jbInit() throws Exception
{
inputText.addActionListener(this);
centreColumnLabelFlag.setLabel("Centre column labels");
centreColumnLabelFlag.addItemListener(this);
-
+ followMouseOverFlag.setLabel("Automatic Scrolling");
+ followMouseOverFlag.addItemListener(this);
helpMenu.setLabel("Help");
documentation.setLabel("Documentation");
documentation.addActionListener(this);
viewMenu.add(menu1);
viewMenu.add(menu2);
viewMenu.addSeparator();
+ viewMenu.add(followMouseOverFlag);
viewMenu.add(annotationPanelMenuItem);
viewMenu.addSeparator();
viewMenu.add(sequenceFeatures);
boolean centreColumnLabels;
+
public boolean getCentreColumnLabels()
{
return centreColumnLabels;
}
}
}
-
+ public boolean followHighlight=false;
+ public boolean getFollowHighlight() {
+ return followHighlight;
+ }
}
public void highlightSearchResults(SearchResults results)
{
seqPanel.seqCanvas.highlightSearchResults(results);
-
+ }
+ /**
+ * scroll the view to show the position of the highlighted
+ * region in results (if any)
+ * @param results
+ */
+ public void scrollToPosition(SearchResults results)
+ {
// do we need to scroll the panel?
- if (results != null)
+ if (results != null && results.getSize()>0)
{
- SequenceI seq = results.getResultSequence(0);
- int seqIndex = av.alignment.findIndex(seq);
- int start = seq.findIndex(results.getResultStart(0)) - 1;
- int end = seq.findIndex(results.getResultEnd(0)) - 1;
-
+ int seqIndex = av.alignment.findIndex(results);
+ if (seqIndex==-1)
+ {
+ return;
+ }
+ SequenceI seq = av.alignment.getSequenceAt(seqIndex);
+ int [] r = results.getResults(seq, seq.getStart(), seq.getEnd());
+ if (r==null)
+ {
+ return;
+ }
+ int start = r[0];
+ int end = r[1];
+ if (start<0)
+ {
+ return;
+ }
+ if (end==seq.getEnd())
+ {
+ return;
+ }
if (!av.wrapAlignment)
{
if ((av.getStartRes() > end)
public void highlightSequence(SearchResults results)
{
seqCanvas.highlightSearchResults(results);
+ if (av.followHighlight)
+ {
+ ap.scrollToPosition(results);
+ }
}
public void updateColours(SequenceI seq, int index)