X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=7d4150dc5df54e3d92c849dd6290cc02de344bc7;hb=06de78be50c3934158fa1d35ec92ad86b54e959f;hp=7ead68195f32c7eae5e477fff8f754d45058c0b5;hpb=5e8ec77d921ff2d604811e5e4ba7e9211b0f48de;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 7ead681..7d4150d 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,17 +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()) - { - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - break; - } - } + reveal = av.getAlignment().getHiddenColumns() + .getRegionWithEdgeAtRes(res); repaint(); } @@ -358,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, @@ -449,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); } } } @@ -472,7 +463,16 @@ 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)) + { + // scroll event, repaint panel + repaint(); + } } }