/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
*
import jalview.commands.*;
import jalview.datamodel.*;
import jalview.schemes.*;
+import jalview.structure.SelectionSource;
import jalview.structure.SequenceListener;
import jalview.structure.StructureSelectionManager;
seqCanvas.addMouseMotionListener(this);
seqCanvas.addMouseListener(this);
- ssm = StructureSelectionManager.getStructureSelectionManager();
+ ssm = StructureSelectionManager.getStructureSelectionManager(av.applet);
ssm.addStructureViewerListener(this);
seqCanvas.repaint();
sg.addSequence(sequence, false);
av.setSelectionGroup(sg);
}
-
ap.paintAlignment(false);
+ av.sendSelection();
}
void insertGapAtCursor(boolean group)
SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
if (evt.getClickCount() > 1)
{
- if (av.getSelectionGroup().getSize() == 1
+ if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() == 1
&& av.getSelectionGroup().getEndRes()
- av.getSelectionGroup().getStartRes() < 2)
{
{
String tmp = sequence.hashCode() + index + "";
if (lastMessage == null || !lastMessage.equals(tmp))
- ssm.mouseOverSequence(sequence, index, pos);
+ ssm.mouseOverSequence(sequence, index, pos, av);
lastMessage = tmp;
}
public void highlightSequence(SearchResults results)
{
- seqCanvas.highlightSearchResults(results);
if (av.followHighlight)
{
- ap.scrollToPosition(results);
+ if (ap.scrollToPosition(results, true))
+ {
+ ap.alignFrame.repaint();
+ }
}
+ seqCanvas.highlightSearchResults(results);
+
}
public void updateColours(SequenceI seq, int index)
stretchGroup = null;
PaintRefresher.Refresh(ap, av.getSequenceSetId());
ap.paintAlignment(true);
+ av.sendSelection();
}
public void doMouseDraggedDefineMode(MouseEvent evt)
}
}
+ /**
+ * modify current selection according to a received message.
+ */
+ public void selection(SequenceGroup seqsel, ColumnSelection colsel,
+ SelectionSource source)
+ {
+ // TODO: fix this hack - source of messages is align viewport, but SeqPanel
+ // handles selection messages...
+ // TODO: extend config options to allow user to control if selections may be
+ // shared between viewports.
+ if (av != null
+ && (av == source || !av.followSelection || (source instanceof AlignViewport && ((AlignViewport) source)
+ .getSequenceSetId().equals(av.getSequenceSetId()))))
+ {
+ return;
+ }
+ // do we want to thread this ? (contention with seqsel and colsel locks, I
+ // suspect)
+ // rules are: colsel is copied if there is a real intersection between
+ // sequence selection
+ boolean repaint = false, copycolsel = true;
+ if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+ {
+ SequenceGroup sgroup = null;
+ if (seqsel != null && seqsel.getSize()>0)
+ {
+ if (av.alignment == null)
+ {
+ System.out
+ .println("Selection message: alignviewport av SeqSetId="
+ + av.getSequenceSetId() + " ViewId="
+ + av.getViewId()
+ + " 's alignment is NULL! returning immediatly.");
+ return;
+ }
+ sgroup = seqsel.intersect(av.alignment,
+ (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+ if ((sgroup == null || sgroup.getSize() == 0)
+ && (colsel == null || colsel.size() == 0))
+ {
+ // don't copy columns if the region didn't intersect.
+ copycolsel = false;
+ }
+ }
+ if (sgroup != null && sgroup.getSize() > 0)
+ {
+ av.setSelectionGroup(sgroup);
+ }
+ else
+ {
+ av.setSelectionGroup(null);
+ }
+ repaint = av.isSelectionGroupChanged();
+ }
+ if (copycolsel && (av.colSel == null || !av.isColSelChanged()))
+ {
+ // the current selection is unset or from a previous message
+ // so import the new colsel.
+ if (colsel == null || colsel.size() == 0)
+ {
+ if (av.colSel != null)
+ {
+ av.colSel.clear();
+ }
+ }
+ else
+ {
+ // TODO: shift colSel according to the intersecting sequences
+ if (av.colSel == null)
+ {
+ av.colSel = new ColumnSelection(colsel);
+ }
+ else
+ {
+ av.colSel.setElementsFrom(colsel);
+ }
+ }
+ repaint |= av.isColSelChanged();
+ }
+ if (copycolsel && av.hasHiddenColumns
+ && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+ {
+ System.err.println("Bad things");
+ }
+ if (repaint)
+ {
+ ap.scalePanelHolder.repaint();
+ ap.repaint();
+ }
+ }
+
+ /**
+ * scroll to the given row/column - or nearest visible location
+ * @param row
+ * @param column
+ */
+ public void scrollTo(int row, int column)
+ {
+
+ row = row<0 ? ap.av.startSeq : row;
+ column = column<0 ? ap.av.startRes : column;
+ ap.scrollTo(row, row, column, true, true);
+ }
+ /**
+ * scroll to the given row - or nearest visible location
+ * @param row
+ */
+ public void scrollToRow(int row)
+ {
+
+ row = row<0 ? ap.av.startSeq : row;
+ ap.scrollTo(row, row, ap.av.startRes, true, true);
+ }
+ /**
+ * scroll to the given column - or nearest visible location
+ * @param column
+ */
+ public void scrollToColumn(int column)
+ {
+
+ column = column<0 ? ap.av.startRes : column;
+ ap.scrollTo(ap.av.startRes, ap.av.startRes, column, true, true);
+ }
+
}