X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=87711194a7a9da5b71b9d3c99cb1663f3efb53f7;hb=80e3ac6ebcb27e0d13ce639d1c3105f7cd6f83fe;hp=f772a1f92f4274cb5cbea03775af74b35baa6fc2;hpb=15662a256b76221299688fff94288d9bd37f8453;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index f772a1f..8771119 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -35,6 +35,7 @@ import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -266,29 +267,26 @@ public class ScalePanel extends JPanel } /** - * DOCUMENT ME! + * Action on mouseUp is to set the limit of the current selection group (if + * there is one) and broadcast the selection * * @param evt - * DOCUMENT ME! */ @Override 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()) + av.getRanges().getStartRes(); - if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() .visibleToAbsoluteColumn(res); } - - if (res >= av.getAlignment().getWidth()) - { - res = av.getAlignment().getWidth() - 1; - } + res = Math.min(res, av.getAlignment().getWidth() - 1); if (!stretchingGroup) { @@ -356,16 +354,23 @@ public class ScalePanel extends JPanel { if (mouseDragging) { - ap.getSeqPanel().scrollCanvas(null); + mouseDragging = false; + ap.getSeqPanel().stopScrolling(); } } + /** + * Action on leaving the panel bounds with mouse drag in progress is to start + * scrolling the alignment in the direction of the mouse. To restrict + * scrolling to left-right (not up-down), the y-value of the mouse position is + * replaced with zero. + */ @Override public void mouseExited(MouseEvent evt) { if (mouseDragging) { - ap.getSeqPanel().scrollCanvas(evt); + ap.getSeqPanel().startScrolling(new Point(evt.getX(), 0)); } } @@ -410,6 +415,8 @@ public class ScalePanel extends JPanel @Override public void paintComponent(Graphics g) { + super.paintComponent(g); + /* * shouldn't get called in wrapped mode as the scale above is * drawn instead by SeqCanvas.drawNorthScale @@ -550,7 +557,11 @@ public class ScalePanel extends JPanel || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT)) { // scroll event, repaint panel - repaint(); + + // Call repaint on alignment panel so that repaints from other alignment + // panel components can be aggregated. Otherwise performance of the overview + // window and others may be adversely affected. + av.getAlignPanel().repaint(); } }