From 0cad98dc5574937f462867526318fc5a94fc2eea Mon Sep 17 00:00:00 2001 From: hansonr Date: Mon, 29 Jul 2019 15:33:47 -0500 Subject: [PATCH] JAL-3383 JAL-3253-applet ScalePanel bug -- should not have to cause an AlignmentPanel repaint as a result of an Overview range change. --- src/jalview/gui/ScalePanel.java | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index f525100..aa58a88 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -54,6 +54,7 @@ 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. */ +@SuppressWarnings("serial") public class ScalePanel extends JPanel implements MouseMotionListener, MouseListener, ViewportListenerI { @@ -187,7 +188,8 @@ public class ScalePanel extends JPanel }); pop.add(item); - if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions()) + if (av.getAlignment().getHiddenColumns() + .hasMultiHiddenColumnRegions()) { item = new JMenuItem(MessageManager.getString("action.reveal_all")); item.addActionListener(new ActionListener() @@ -287,8 +289,7 @@ public class ScalePanel extends JPanel // todo res calculation should be a method on AlignViewport int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates ViewportRanges ranges = av.getRanges(); - int res = (xCords / av.getCharWidth()) - + ranges.getStartRes(); + int res = (xCords / av.getCharWidth()) + ranges.getStartRes(); res = Math.min(res, ranges.getEndRes()); if (av.hasHiddenColumns()) { @@ -435,7 +436,8 @@ public class ScalePanel extends JPanel @Override public void paintComponent(Graphics g) { - //super.paintComponent(g); // BH 2019 + + // super.paintComponent(g); // BH 2019 /* * shouldn't get called in wrapped mode as the scale above is @@ -523,10 +525,11 @@ public class ScalePanel extends JPanel 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); + { -1 + res * avCharWidth - avCharHeight / 4, + -1 + res * avCharWidth + avCharHeight / 4, + -1 + res * avCharWidth }, + new int[] + { y, y, y + 2 * yOf }, 3); } } } @@ -572,16 +575,26 @@ public class ScalePanel extends JPanel // 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) - || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ) - || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT)) + switch (evt.getPropertyName()) { + case ViewportRanges.STARTRES: + case ViewportRanges.STARTRESANDSEQ: + case ViewportRanges.MOVE_VIEWPORT: // scroll event, repaint panel - - // 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(); + // TODO: check this? + // BH: This is actually quite strange. AlignmentPanel is taking care of + // all of + // this with fast paint, so why indirectly trigger a repaint from the + // ScalePanel? + + // 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(); + System.out.println("ScalePanel propertyChange disabled " + + evt.getPropertyName()); + break; } } -- 1.7.10.2