JAL-2674 2nd attempt to refactor seqcanvas drawing to iterator
[jalview.git] / src / jalview / gui / SeqCanvas.java
index f61c7c6..2c8a5df 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.gui;
 
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.HiddenColumns.VisibleBlocksVisBoundsIterator;
 import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -853,28 +854,33 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
       int screenY = 0;
       final int screenYMax = endRes - startRes;
       int blockStart = startRes;
-      int blockEnd = endRes;
+      int blockEnd = endRes; // equals blockStart + screenYMax - screenY;
 
       HiddenColumns hidden = av.getAlignment().getHiddenColumns();
-      Iterator<int[]> regions = hidden.iterator();
+      VisibleBlocksVisBoundsIterator regions = (VisibleBlocksVisBoundsIterator) hidden
+              .getVisibleBlocksIterator(startRes, endRes, true);// hidden.iterator();
       while (regions.hasNext())
       {
         int[] region = regions.next();
-        int hideStart = region[0];
+        blockEnd = region[1];
+        blockStart = region[0];
+/*        int hideStart = region[0];
         int hideEnd = region[1];
 
         if (hideStart <= blockStart)
         {
-          blockStart += (hideEnd - hideStart) + 1;
+          blockStart += (hideEnd - hideStart) + 1; // convert startRes to an
+                                                   // absolute value
+          blockEnd += (hideEnd - hideStart) + 1;
           continue;
         }
-
+*/
         /*
          * draw up to just before the next hidden region, or the end of
          * the visible region, whichever comes first
          */
-        blockEnd = Math.min(hideStart - 1,
-                blockStart + screenYMax - screenY);
+//        blockEnd = Math.min(hideStart - 1,
+//                blockEnd);
         g1.translate(screenY * charWidth, 0);
 
         draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
@@ -883,7 +889,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
          * draw the downline of the hidden column marker (ScalePanel draws the
          * triangle on top) if we reached it
          */
-        if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1)
+        if (av.getShowHiddenMarkers()
+                && (regions.hasNext() || regions.endsAtHidden()))// blockEnd ==
+                                                           // hideStart - 1)
         {
           g1.setColor(Color.blue);
 
@@ -894,24 +902,25 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
 
         g1.translate(-screenY * charWidth, 0);
         screenY += blockEnd - blockStart + 1;
-        blockStart = hideEnd + 1;
-
+        /*       blockStart = hideEnd + 1;
+        blockEnd = blockStart + screenYMax - screenY;
+        
         if (screenY > screenYMax)
         {
           // already rendered last block
           return;
-        }
+        }*/
       }
 
-      if (screenY <= screenYMax)
+      /*      if (screenY <= screenYMax)
       {
         // remaining visible region to render
         blockEnd = blockStart + screenYMax - screenY;
         g1.translate(screenY * charWidth, 0);
         draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
-
+      
         g1.translate(-screenY * charWidth, 0);
-      }
+      }*/
     }
 
   }