JAL-2349 scaling matrix column to annotation height
authorJim Procter <jprocter@issues.jalview.org>
Sun, 11 Jun 2017 01:03:49 +0000 (11:03 +1000)
committerJim Procter <jprocter@issues.jalview.org>
Sun, 11 Jun 2017 01:03:49 +0000 (11:03 +1000)
src/jalview/renderer/ContactMapRenderer.java

index dac8882..bed54e8 100644 (file)
@@ -72,14 +72,14 @@ public class ContactMapRenderer implements AnnotationRowRendererI
 
       // cell height to render
       double scale = (_aa.graphHeight < contacts.getContactHeight()) ? 1
-              : (((double) _aa.graphHeight) / (double) contacts
-                      .getContactHeight());
+              : ((double) _aa.graphHeight)
+                      / (double) contacts.getContactHeight();
       int cstart, cend = -1;
       for (int ht = y2, eht = y2 - _aa.graphHeight; ht >= eht; ht -= scale)
       {
         cstart = cend + 1;
-        cend = -1
-                + (contacts.getContactHeight() * (ht - eht) / _aa.graphHeight);
+        cend = Math.max(cstart + 1, contacts.getContactHeight()
+                * ((ht - y2) / _aa.graphHeight));
         // TODO show maximum colour for range - sort of done
         // also need a 'getMaxPosForRange(start,end)'
         g.setColor(getColorForRange(min, max, contacts, cstart, cend));