public void mouseReleased(MouseEvent evt)
{
mouseDragging = false;
+ ap.getSeqPanel().stopScrolling();
- // todo res calculation should be a method on AlignViewport
- int res = (evt.getX() / av.getCharWidth())
+ int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
-
+ int res = (xCords / av.getCharWidth())
+ av.getRanges().getStartRes();
-
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
mouseDragging = true;
- if ((scrollThread != null) && (scrollThread.isRunning()))
+ if (scrollThread != null)
{
- scrollThread.setEvent(evt);
+ scrollThread.setMousePosition(evt.getPoint());
}
+
+ /*
+ * construct a status message showing the range of the selection
+ */
+ StringBuilder status = new StringBuilder(64);
+ List<SequenceI> seqs = stretchGroup.getSequences();
+ String name = seqs.get(0).getName();
+ if (name.length() > 20)
+ {
+ name = name.substring(0, 20);
+ }
+ status.append(name).append(" - ");
+ name = seqs.get(seqs.size() - 1).getName();
+ if (name.length() > 20)
+ {
+ name = name.substring(0, 20);
+ }
+ status.append(name).append(" ");
+ int startRes = stretchGroup.getStartRes();
+ status.append(" cols ").append(String.valueOf(startRes + 1))
+ .append("-");
+ int endRes = stretchGroup.getEndRes();
+ status.append(String.valueOf(endRes + 1));
+ status.append(" (").append(String.valueOf(seqs.size())).append(" x ")
+ .append(String.valueOf(endRes - startRes + 1)).append(")");
+ ap.alignFrame.setStatus(status.toString());
}
- void scrollCanvas(MouseEvent evt)
+ /**
+ * Stops the scroll thread if it is running
+ */
+ void stopScrolling()
{
- if (evt == null)
+ if (scrollThread != null)
{
- if ((scrollThread != null) && (scrollThread.isRunning()))
- {
- scrollThread.stopScrolling();
- scrollThread = null;
- }
- mouseDragging = false;
+ scrollThread.stopScrolling();
+ scrollThread = null;
}
- else
- {
- if (scrollThread == null)
- {
- scrollThread = new ScrollThread();
- }
+ mouseDragging = false;
+ }
- mouseDragging = true;
- scrollThread.setEvent(evt);
+ /**
+ * Starts a thread to scroll the alignment, towards a given mouse position
+ * outside the panel bounds
+ *
+ * @param mousePos
+ */
+ void startScrolling(Point mousePos)
+ {
+ if (scrollThread == null)
+ {
+ scrollThread = new ScrollThread();
}
+ mouseDragging = true;
+ scrollThread.setMousePosition(mousePos);
}
- // this class allows scrolling off the bottom of the visible alignment
+ /**
+ * Performs scrolling of the visible alignment left, right, up or down
+ */
class ScrollThread extends Thread
{
- MouseEvent evt;
+ private Point mousePos;
private volatile boolean threadRunning = true;