JAL-2629 add basic parameter adjustment to hmmsearch/align
[jalview.git] / src / jalview / renderer / OverviewRenderer.java
index 9291ca6..0f8cda6 100644 (file)
@@ -48,12 +48,14 @@ public class OverviewRenderer
   // raw number of pixels to allocate to each row
   private float pixelsPerSeq;
 
+  // flag to indicate whether to halt drawing
+  private volatile boolean redraw = false;
+
   public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer,
           FeatureRenderer fr, OverviewDimensions od)
-  // FeatureColourFinder colfinder, OverviewDimensions od)
   {
     sr = seqRenderer;
-    finder = new FeatureColourFinder(fr); // colfinder;
+    finder = new FeatureColourFinder(fr);
 
     pixelsPerCol = od.getPixelsPerCol();
     pixelsPerSeq = od.getPixelsPerSeq();
@@ -76,8 +78,14 @@ public class OverviewRenderer
     int rgbcolor = Color.white.getRGB();
     int seqIndex = 0;
     int pixelRow = 0;
+
     for (int alignmentRow : rows)
     {
+      if (redraw)
+      {
+        break;
+      }
+
       // get details of this alignment row
       boolean hidden = rows.isHidden(alignmentRow);
       SequenceI seq = rows.getSequence(alignmentRow);
@@ -90,9 +98,13 @@ public class OverviewRenderer
       int pixelCol = 0;
       for (int alignmentCol : cols)
       {
+        if (redraw)
+        {
+          break;
+        }
+
         // calculate where this column extends to in pixels
-        int endCol = Math.min(
-                Math.round((colIndex + 1) * pixelsPerCol) - 1,
+        int endCol = Math.min(Math.round((colIndex + 1) * pixelsPerCol) - 1,
                 miniMe.getWidth() - 1);
 
         // don't do expensive colour determination if we're not going to use it
@@ -171,14 +183,17 @@ public class OverviewRenderer
     int pixelCol = 0;
     for (int alignmentCol : cols)
     {
+      if (redraw)
+      {
+        break;
+      }
       if (alignmentCol >= annotations.length)
       {
         break; // no more annotations to draw here
       }
       else
       {
-        int endCol = Math.min(
-                Math.round((colIndex + 1) * pixelsPerCol) - 1,
+        int endCol = Math.min(Math.round((colIndex + 1) * pixelsPerCol) - 1,
                 miniMe.getWidth() - 1);
 
         if (annotations[alignmentCol] != null)
@@ -192,7 +207,8 @@ public class OverviewRenderer
             g.setColor(annotations[alignmentCol].colour);
           }
 
-          height = (int) ((annotations[alignmentCol].value / anno.graphMax) * y);
+          height = (int) ((annotations[alignmentCol].value / anno.graphMax)
+                  * y);
           if (height > y)
           {
             height = y;
@@ -205,4 +221,12 @@ public class OverviewRenderer
       }
     }
   }
+
+  public void setRedraw(boolean b)
+  {
+    synchronized (this)
+    {
+      redraw = b;
+    }
+  }
 }