X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FScalePanel.java;h=5271da29e15b11f9fb408282e3bbfc437d19b01b;hb=6463d6e0b78c66ca70ebe73c9f0f115185d1e681;hp=f525100c115844192f8feb575553db1aa625ac95;hpb=8f86344f6c23b60a0be5cddef0cce34f9fb049a9;p=jalview.git diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index f525100..5271da2 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,8 +436,6 @@ public class ScalePanel extends JPanel @Override public void paintComponent(Graphics g) { - //super.paintComponent(g); // BH 2019 - /* * shouldn't get called in wrapped mode as the scale above is * drawn instead by SeqCanvas.drawNorthScale @@ -448,7 +447,6 @@ public class ScalePanel extends JPanel } } - // scalewidth will normally be screenwidth, public void drawScale(Graphics g, int startx, int endx, int width, int height) { @@ -523,10 +521,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); } } } @@ -566,26 +565,34 @@ public class ScalePanel extends JPanel @Override public void propertyChange(PropertyChangeEvent evt) { - // Respond to viewport change events (e.g. alignment panel was scrolled) - // 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) - || 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(); + // original comment: + // 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. + + // 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? Where do we see this behavior necessary? + // I have set this to check for a trigger from some other ViewportRanges, + // but I don't actually think that is possible. + + if (evt.getSource() != av.getRanges()) + { + av.getAlignPanel().repaint(); + } + break; } } - public boolean isMouseDragging() + boolean isMouseDragging() { return mouseDragging; }