X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=1db4051e1841e8648149326d4e72160064392c4a;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=81befd8a361162242b88fcef8949315c36c9218a;hpb=5e8ec77d921ff2d604811e5e4ba7e9211b0f48de;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 81befd8..1db4051 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -29,6 +29,7 @@ import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.FontMetrics; @@ -53,8 +54,8 @@ import javax.swing.ToolTipManager; * The panel containing the sequence ruler (when not in wrapped mode), and * supports a range of mouse operations to select, hide or reveal columns. */ -public class ScalePanel extends JPanel implements MouseMotionListener, - MouseListener, ViewportListenerI +public class ScalePanel extends JPanel + implements MouseMotionListener, MouseListener, ViewportListenerI { protected int offy = 4; @@ -168,10 +169,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener, av.showColumn(reveal[0]); reveal = null; ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } av.sendSelection(); } }); @@ -188,10 +185,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener, av.showAllHiddenColumns(); reveal = null; ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } av.sendSelection(); } }); @@ -209,18 +202,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener, public void actionPerformed(ActionEvent e) { av.hideColumns(res, res); - if (av.getSelectionGroup() != null - && av.getSelectionGroup().getSize() == av.getAlignment() - .getHeight()) + if (av.getSelectionGroup() != null && av.getSelectionGroup() + .getSize() == av.getAlignment().getHeight()) { av.setSelectionGroup(null); } ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } av.sendSelection(); } }); @@ -401,20 +389,15 @@ public class ScalePanel extends JPanel implements MouseMotionListener, int res = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes(); + reveal = av.getAlignment().getHiddenColumns() + .getRegionWithEdgeAtRes(res); + res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); - for (int[] region : av.getAlignment().getHiddenColumns()) - { - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - ToolTipManager.sharedInstance().registerComponent(this); - this.setToolTipText( - MessageManager.getString("label.reveal_hidden_columns")); - repaint(); - return; - } - } + ToolTipManager.sharedInstance().registerComponent(this); + this.setToolTipText( + MessageManager.getString("label.reveal_hidden_columns")); + repaint(); } /** @@ -426,8 +409,15 @@ public class ScalePanel extends JPanel implements MouseMotionListener, @Override public void paintComponent(Graphics g) { - drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(), - getWidth(), getHeight()); + /* + * shouldn't get called in wrapped mode as the scale above is + * drawn instead by SeqCanvas.drawNorthScale + */ + if (!av.getWrapAlignment()) + { + drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(), + getWidth(), getHeight()); + } } // scalewidth will normally be screenwidth, @@ -497,21 +487,23 @@ public class ScalePanel extends JPanel implements MouseMotionListener, if (av.getShowHiddenMarkers()) { - for (int i = 0; i < hidden.getHiddenRegions() - .size(); i++) + List positions = hidden.findHiddenRegionPositions(); + for (int pos : positions) { - res = hidden.findHiddenRegionPosition(i) - - startx; + res = pos - startx; if (res < 0 || res > widthx) { continue; } - gg.fillPolygon(new int[] { - -1 + res * avCharWidth - avCharHeight / 4, - -1 + res * avCharWidth + avCharHeight / 4, - -1 + res * avCharWidth }, new int[] { y, y, y + 2 * yOf }, 3); + gg.fillPolygon( + new int[] + { -1 + res * avCharWidth - avCharHeight / 4, + -1 + res * avCharWidth + avCharHeight / 4, + -1 + res * avCharWidth }, + new int[] + { y, y, y + 2 * yOf }, 3); } } } @@ -552,7 +544,16 @@ public class ScalePanel extends JPanel implements MouseMotionListener, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport change events (e.g. alignment panel was scrolled) - repaint(); + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTRES)) + { + // scroll event, repaint panel + repaint(); + } } }