X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=ea32684bb2d9239c9260b6f259fd59a5428af766;hb=0ebbad305e982eeda562a1842362dc415c36cc8d;hp=6c9cb6c4e286dadcfd016abb9e3928379a0e6a05;hpb=60b5bd72afd991cd1f0c0e622f3552552a8b6a93;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 6c9cb6c..ea32684 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -192,21 +192,27 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, renderer = new AnnotationRenderer(); } + /** + * Responds to a mouse wheel movement by scrolling the annotations up or down. + * Annotation labels are scrolled via method adjustmentValueChanged when the + * vertical scrollbar is adjusted. + *

+ * If shift is pressed, then scrolling is left or right instead, and is + * delegated to AlignmentPanel, so that both sequences and annotations are + * scrolled together. + *

+ * This object is a MouseWheelListener to AnnotationLabels, so mouse wheel + * events over the labels are delegated to this method. + *

+ * Note that this method may also be fired by scrolling with a gesture on a + * trackpad. + */ @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isShiftDown()) { - e.consume(); - double wheelRotation = e.getPreciseWheelRotation(); - if (wheelRotation > 0) - { - av.getRanges().scrollRight(true); - } - else if (wheelRotation < 0) - { - av.getRanges().scrollRight(false); - } + ap.getSeqPanel().mouseWheelMoved(e); } else { @@ -633,7 +639,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int yOffset = rowIndex[1]; AlignmentAnnotation[] allAnnotation = av.getAlignment() .getAlignmentAnnotation(); - if (allAnnotation==null || rowIndex[0]<0 || rowIndex[0]>=allAnnotation.length) + if (allAnnotation == null || rowIndex[0] < 0 + || rowIndex[0] >= allAnnotation.length) { return false; } @@ -676,7 +683,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { SequenceI rseq = clicked.sequenceRef; BitSet grp = new BitSet(); - grp.or(matrix.getGroupsFor(currentX)); + grp.or(matrix.getGroupsFor(forCurrentX.getPosition())); // TODO: cXci needs to be mapped to real groups for (int c = fr; c <= to; c++) { @@ -1089,13 +1096,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (forFromX != null && forToX != null) { - // FIXME will need two ContactGeometry objects when handling contact matrices with differing numbers of rows at each + // FIXME will need two ContactGeometry objects when handling contact + // matrices with differing numbers of rows at each // column ContactGeometry xcgeom = new ContactGeometry(forFromX, cma.graphHeight); - ContactGeometry.contactInterval lastXci = xcgeom - .mapFor(rowIndex[1]); - ContactGeometry.contactInterval cXci = xcgeom.mapFor(rowIndex[1] + deltaY); + ContactGeometry.contactInterval lastXci = xcgeom.mapFor(rowIndex[1]); + ContactGeometry.contactInterval cXci = xcgeom + .mapFor(rowIndex[1] + deltaY); // mark rectangular region formed by drag jalview.bin.Console.trace("Matrix Selection from last(" + fromXc @@ -1121,7 +1129,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // } // else { - av.getColumnSelection().addElement(c-1); + av.getColumnSelection().addElement(c - 1); } } } @@ -1233,7 +1241,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { row = i; res[0] = row; - res[1] = yPos-lheight; + res[1] = yPos - lheight; break; } } @@ -1287,7 +1295,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // TODO abstract tooltip generator so different implementations can be built if (ann.graph == AlignmentAnnotation.CONTACT_MAP) { - if (rowAndOffset>=ann.graphHeight) + if (rowAndOffset >= ann.graphHeight) { return null; } @@ -1298,9 +1306,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset); ContactRange cr = clist.getRangeFor(ci.cStart, ci.cEnd); StringBuilder tooltipb = new StringBuilder(); - tooltipb.append("Contact from ") - .append(clist.getPosition()).append(", [").append(ci.cStart).append(" - ").append(ci.cEnd).append("]").append("
Mean:"); - Format.appendPercentage(tooltipb, (float)cr.getMean(),2); + tooltipb.append("Contact from ").append(clist.getPosition()) + .append(", [").append(ci.cStart).append(" - ") + .append(ci.cEnd).append("]").append("
Mean:"); + Format.appendPercentage(tooltipb, (float) cr.getMean(), 2); tooltip = tooltipb.toString(); int col = ann.sequenceRef.findPosition(column); int[][] highlightPos; @@ -1638,7 +1647,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, && (fadedImage == null || fadedImage.getWidth() != imgWidth || fadedImage.getHeight() != image.getHeight())) { - // jalview.bin.Console.errPrintln("redraw faded image ("+(fadedImage==null ? + // jalview.bin.Console.errPrintln("redraw faded image + // ("+(fadedImage==null ? // "null image" : "") + " lastGood="+lastImageGood+")"); fadedImage = new BufferedImage(imgWidth, image.getHeight(), BufferedImage.TYPE_INT_RGB);