X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=04fb22bd00207a7d254826e6be9fcba0c278d9aa;hb=4650bd5a0ce2b7ef07bd91baa591fa5d0cadef4c;hp=ec3e2469d8658ebd5b9fbc067233d2dae08b28b2;hpb=c2e5d3d1ebe3b283bdde15637c590721cd6c5637;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index ec3e246..04fb22b 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -27,6 +27,7 @@ import jalview.renderer.ScaleRenderer; import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.util.MessageManager; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.FontMetrics; @@ -43,8 +44,8 @@ import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.util.List; -public class ScalePanel extends Panel implements MouseMotionListener, - MouseListener, ViewportListenerI +public class ScalePanel extends Panel + implements MouseMotionListener, MouseListener, ViewportListenerI { protected int offy = 4; @@ -94,7 +95,8 @@ public class ScalePanel extends Panel implements MouseMotionListener, min = res; max = res; - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ((evt.getModifiers() + & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { rightMouseButtonPressed(evt, res); } @@ -139,7 +141,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, sg.setStartRes(min); sg.setEndRes(max); } - ap.paintAlignment(true); + ap.paintAlignment(false, false); av.sendSelection(); } @@ -156,7 +158,8 @@ public class ScalePanel extends Panel implements MouseMotionListener, PopupMenu pop = new PopupMenu(); if (reveal != null) { - MenuItem item = new MenuItem(MessageManager.getString("label.reveal")); + MenuItem item = new MenuItem( + MessageManager.getString("label.reveal")); item.addActionListener(new ActionListener() { @Override @@ -164,11 +167,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, { av.showColumn(reveal[0]); reveal = null; - ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } + ap.paintAlignment(true, true); av.sendSelection(); } }); @@ -184,11 +183,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, { av.showAllHiddenColumns(); reveal = null; - ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } + ap.paintAlignment(true, true); av.sendSelection(); } }); @@ -207,18 +202,13 @@ public class ScalePanel extends Panel 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(); - } + ap.paintAlignment(true, true); av.sendSelection(); } }); @@ -249,7 +239,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (!stretchingGroup) { - ap.paintAlignment(false); + ap.paintAlignment(false, false); return; } @@ -266,7 +256,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, } stretchingGroup = false; - ap.paintAlignment(false); + ap.paintAlignment(false, false); av.sendSelection(); } @@ -295,7 +285,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, { stretchingGroup = true; cs.stretchGroup(res, sg, min, max); - ap.paintAlignment(false); + ap.paintAlignment(false, false); } } @@ -334,18 +324,8 @@ public class ScalePanel extends Panel implements MouseMotionListener, int res = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes(); - res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); - - reveal = null; - for (int[] region : av.getAlignment().getHiddenColumns() - .getHiddenRegions()) - { - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - break; - } - } + reveal = av.getAlignment().getHiddenColumns() + .getRegionWithEdgeAtRes(res); repaint(); } @@ -359,9 +339,15 @@ public class ScalePanel extends Panel implements MouseMotionListener, @Override public void paint(Graphics g) { - drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(), - getSize().width, - getSize().height); + /* + * 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(), + getSize().width, getSize().height); + } } // scalewidth will normally be screenwidth, @@ -450,20 +436,24 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (av.getShowHiddenMarkers()) { int widthx = 1 + endx - startx; - 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); } } } @@ -473,7 +463,18 @@ public class ScalePanel extends Panel 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) + || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ) + || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT)) + { + // scroll event, repaint panel + repaint(); + } } }