JAL-2774 Fixed merge issues
[jalview.git] / src / jalview / gui / SeqCanvas.java
index adc36f9..58af47b 100755 (executable)
@@ -697,7 +697,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
      * ensuring a part height includes at least one sequence
      */
     ViewportRanges ranges = av.getRanges();
-    int xMax = ranges.getVisibleAlignmentWidth();
     wrappedVisibleWidths = canvasHeight / wrappedRepeatHeightPx;
     int remainder = canvasHeight % wrappedRepeatHeightPx;
     if (remainder >= (wrappedSpaceAboveAlignment + charHeight))
@@ -713,8 +712,10 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
     /*
      *  limit visibleWidths to not exceed width of alignment
      */
-    int maxWidths = (xMax - ranges.getStartRes()) / wrappedWidthInResidues;
-    if (xMax % wrappedWidthInResidues > 0)
+    int xMax = ranges.getVisibleAlignmentWidth();
+    int startToEnd = xMax - ranges.getStartRes();
+    int maxWidths = startToEnd / wrappedWidthInResidues;
+    if (startToEnd % wrappedWidthInResidues > 0)
     {
       maxWidths++;
     }
@@ -837,10 +838,12 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
        * white fill region of scale above and hidden column markers
        * (to support incremental fast paint of image)
        */
+      g.translate(labelWidthWest, 0);
       g.setColor(Color.white);
       g.fillRect(0, ypos - wrappedSpaceAboveAlignment, viewportWidth
               * charWidth + labelWidthWest, wrappedSpaceAboveAlignment);
       g.setColor(Color.black);
+      g.translate(-labelWidthWest, 0);
 
       g.translate(labelWidthWest, 0);
 
@@ -863,6 +866,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
   }
 
   /**
+   * Draws markers (triangles) above hidden column positions between startColumn
+   * and endColumn.
+   * 
    * @param g
    * @param ypos
    * @param startColumn
@@ -881,7 +887,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
     {
       int res = pos - startColumn;
 
-      if (res < 0 || res > endColumn - startColumn)
+      if (res < 0 || res > endColumn - startColumn + 1)
       {
         continue;
       }
@@ -906,9 +912,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
           int canvasWidth,
           int canvasHeight, int startRes)
   {
-       int charHeight = av.getCharHeight();
-       int charWidth = av.getCharWidth();
-         
+    int charHeight = av.getCharHeight();
+    int charWidth = av.getCharWidth();
+      
     // height gap above each panel
     int hgap = charHeight;
     if (av.getScaleAboveWrapped())
@@ -1270,8 +1276,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
   private void drawUnwrappedSelection(Graphics2D g, SequenceGroup group,
           int startRes, int endRes, int startSeq, int endSeq, int offset)
   {
-       int charWidth = av.getCharWidth();
-         
+    int charWidth = av.getCharWidth();
+          
     if (!av.hasHiddenColumns())
     {
       drawPartialGroupOutline(g, group, startRes, endRes, startSeq, endSeq,
@@ -1333,9 +1339,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
           int startRes, int endRes, int startSeq, int endSeq,
           int verticalOffset)
   {
-       int charHeight = av.getCharHeight();
-       int charWidth = av.getCharWidth();
-         
+        int charHeight = av.getCharHeight();
+        int charWidth = av.getCharWidth();
+          
     int visWidth = (endRes - startRes + 1) * charWidth;
 
     int oldY = -1;
@@ -1652,47 +1658,62 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
     {
       fastPaint = true;
       repaint();
+      return;
     }
-    else if (eventName.equals(ViewportRanges.STARTRES))
+
+    int scrollX = 0;
+    if (eventName.equals(ViewportRanges.STARTRES)
+            || eventName.equals(ViewportRanges.STARTRESANDSEQ))
     {
-      int scrollX = 0;
+      // Make sure we're not trying to draw a panel
+      // larger than the visible window
       if (eventName.equals(ViewportRanges.STARTRES))
       {
-        // Make sure we're not trying to draw a panel
-        // larger than the visible window
-        ViewportRanges vpRanges = av.getRanges();
         scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
-        int range = vpRanges.getEndRes() - vpRanges.getStartRes();
-        if (scrollX > range)
-        {
-          scrollX = range;
-        }
-        else if (scrollX < -range)
-        {
-          scrollX = -range;
-        }
+      }
+      else
+      {
+        scrollX = ((int[]) evt.getNewValue())[0]
+                - ((int[]) evt.getOldValue())[0];
+      }
+      ViewportRanges vpRanges = av.getRanges();
 
-        // 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.
-        
-        // scroll - startres and endres both change
-         if (av.getWrapAlignment())
-        {
-          fastPaintWrapped(scrollX);
-        }
-        else
-        {
-          fastPaint(scrollX, 0);
-        }
+      int range = vpRanges.getEndRes() - vpRanges.getStartRes();
+      if (scrollX > range)
+      {
+        scrollX = range;
+      }
+      else if (scrollX < -range)
+      {
+        scrollX = -range;
+      }
+
+      // 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 (eventName.equals(ViewportRanges.STARTRES))
+      {
+         if (av.getWrapAlignment())
+          {
+            fastPaintWrapped(scrollX);
+          }
+          else
+          {
+            fastPaint(scrollX, 0);
+          }
       }
       else if (eventName.equals(ViewportRanges.STARTSEQ))
       {
         // scroll
         fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
       }
+      else if (eventName.equals(ViewportRanges.STARTRESANDSEQ))
+      {
+        fastPaint(scrollX, ((int[]) evt.getNewValue())[1]
+                - ((int[]) evt.getOldValue())[1]);
+      }
     }
   }