X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FScalePanel.java;h=d3f4a699a35405f86f6138c0335491d50a2fccca;hb=e1a435a213f105bac3ea0258c6fe26f11df2a392;hp=1737c012cb31830b0f173776c9e12b35068d6680;hpb=a41b74d63832baaf00daac0a176118dc751c3b24;p=jalview.git diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 1737c01..d3f4a69 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -42,10 +42,11 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; +import java.util.Iterator; 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; @@ -86,7 +87,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (av.hasHiddenColumns()) { - res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x); + res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x); } else { @@ -95,7 +96,8 @@ public class ScalePanel extends Panel implements MouseMotionListener, min = res; max = res; - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ((evt.getModifiersEx() + & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { rightMouseButtonPressed(evt, res); } @@ -140,7 +142,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, sg.setStartRes(min); sg.setEndRes(max); } - ap.paintAlignment(true); + ap.paintAlignment(false, false); av.sendSelection(); } @@ -157,7 +159,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 @@ -165,17 +168,13 @@ 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(); } }); pop.add(item); - if (av.getAlignment().getHiddenColumns().hasManyHiddenColumns()) + if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions()) { item = new MenuItem(MessageManager.getString("action.reveal_all")); item.addActionListener(new ActionListener() @@ -185,11 +184,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(); } }); @@ -208,18 +203,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(); } }); @@ -245,12 +235,12 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(res); + .visibleToAbsoluteColumn(res); } if (!stretchingGroup) { - ap.paintAlignment(false); + ap.paintAlignment(false, false); return; } @@ -267,7 +257,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, } stretchingGroup = false; - ap.paintAlignment(false); + ap.paintAlignment(false, false); av.sendSelection(); } @@ -286,7 +276,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, int res = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes(); res = Math.max(0, res); - res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); + res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res); res = Math.min(res, av.getAlignment().getWidth() - 1); min = Math.min(res, min); max = Math.max(res, max); @@ -296,7 +286,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, { stretchingGroup = true; cs.stretchGroup(res, sg, min, max); - ap.paintAlignment(false); + ap.paintAlignment(false, false); } } @@ -350,9 +340,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, @@ -382,7 +378,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, { if (hidden.isVisible(sel)) { - sel = hidden.findColumnPosition(sel); + sel = hidden.absoluteToVisibleColumn(sel); } else { @@ -441,21 +437,17 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (av.getShowHiddenMarkers()) { int widthx = 1 + endx - startx; - List positions = hidden.findHiddenRegionPositions(); - for (int pos : positions) + Iterator it = hidden.getStartRegionIterator(startx, + startx + widthx + 1); + while (it.hasNext()) { + res = it.next() - 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); } } } @@ -470,7 +462,9 @@ public class ScalePanel extends Panel implements MouseMotionListener, // 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)) + if (evt.getPropertyName().equals(ViewportRanges.STARTRES) + || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ) + || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT)) { // scroll event, repaint panel repaint();