JAL-3285 small code changes to AnnotationRenderer not included in merge
[jalview.git] / src / jalview / renderer / AnnotationRenderer.java
index ed67aa6..f1f5fa8 100644 (file)
@@ -36,6 +36,7 @@ import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.ZappoColourScheme;
 import jalview.util.Platform;
+import jalview.workers.InformationThread;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
@@ -71,11 +72,14 @@ public class AnnotationRenderer
 
   private final boolean MAC = Platform.isAMac();
 
-  boolean av_renderHistogram = true, av_renderProfile = true,
-          av_normaliseProfile = false;
+  // todo remove these flags, read from group/viewport where needed
+  boolean av_renderHistogram = true;
 
-  boolean av_renderInformationHistogram = true, av_renderHMMProfile = true,
-          av_normaliseHMMProfile = false, av_infoHeight = false;
+  boolean av_renderProfile = true;
+
+  boolean av_normaliseProfile = false;
+
+  boolean av_infoHeight = false;
 
   ResidueShaderI profcolour = null;
 
@@ -169,7 +173,7 @@ public class AnnotationRenderer
   {
     g.setColor(STEM_COLOUR);
     int sCol = (lastSSX / charWidth)
-            + hiddenColumns.adjustForHiddenColumns(startRes);
+            + hiddenColumns.visibleToAbsoluteColumn(startRes);
     int x1 = lastSSX;
     int x2 = (x * charWidth);
 
@@ -236,7 +240,7 @@ public class AnnotationRenderer
 
     g.setColor(nonCanColor);
     int sCol = (lastSSX / charWidth)
-            + hiddenColumns.adjustForHiddenColumns(startRes);
+            + hiddenColumns.visibleToAbsoluteColumn(startRes);
     int x1 = lastSSX;
     int x2 = (x * charWidth);
 
@@ -332,9 +336,6 @@ public class AnnotationRenderer
     av_renderHistogram = av.isShowConsensusHistogram();
     av_renderProfile = av.isShowSequenceLogo();
     av_normaliseProfile = av.isNormaliseSequenceLogo();
-    av_renderInformationHistogram = av.isShowInformationHistogram();
-    av_renderHMMProfile = av.isShowHMMSequenceLogo();
-    av_normaliseHMMProfile = av.isNormaliseHMMSequenceLogo();
     profcolour = av.getResidueShading();
     if (profcolour == null || profcolour.getColourScheme() == null)
     {
@@ -375,7 +376,7 @@ public class AnnotationRenderer
     // properties/rendering attributes as a global 'alignment group' which holds
     // all vis settings for the alignment as a whole rather than a subset
     //
-    if ("HMM".equals(aa.getCalcId()))
+    if (InformationThread.HMM_CALC_ID.equals(aa.getCalcId()))
     {
       HiddenMarkovModel hmm = aa.sequenceRef.getHMM();
       return AAFrequency.extractHMMProfile(hmm, column,
@@ -387,13 +388,13 @@ public class AnnotationRenderer
                     .startsWith("cDNA Consensus")))
     {
       boolean forComplement = aa.label.startsWith("cDNA Consensus");
-      if (aa.groupRef != null && aa.groupRef.consensusData != null
+      if (aa.groupRef != null && aa.groupRef.getConsensusData() != null
               && aa.groupRef.isShowSequenceLogo())
       {
         // TODO? group consensus for cDNA complement
         return AAFrequency.extractProfile(
-                aa.groupRef.consensusData.get(column),
-                aa.groupRef.getIgnoreGapsConsensus());
+                aa.groupRef.getConsensusData().get(column),
+                aa.groupRef.isIgnoreGapsConsensus());
       }
       // TODO extend annotation row to enable dynamic and static profile data to
       // be stored
@@ -526,11 +527,20 @@ public class AnnotationRenderer
           renderProfile = av_renderProfile;
           normaliseProfile = av_normaliseProfile;
         }
-        else if ("HMM".equals(row.getCalcId()))
+        else if (InformationThread.HMM_CALC_ID.equals(row.getCalcId()))
         {
-          renderHistogram = av_renderInformationHistogram;
-          renderProfile = av_renderHMMProfile;
-          normaliseProfile = av_normaliseHMMProfile;
+          if (row.groupRef != null)
+          {
+            renderHistogram = row.groupRef.isShowInformationHistogram();
+            renderProfile = row.groupRef.isShowHMMSequenceLogo();
+            normaliseProfile = row.groupRef.isNormaliseHMMSequenceLogo();
+          }
+          else
+          {
+            renderHistogram = av.isShowInformationHistogram();
+            renderProfile = av.isShowHMMSequenceLogo();
+            normaliseProfile = av.isNormaliseHMMSequenceLogo();
+          }
         }
         else
         {
@@ -629,7 +639,7 @@ public class AnnotationRenderer
         {
           if (hasHiddenColumns)
           {
-            column = hiddenColumns.adjustForHiddenColumns(startRes + x);
+            column = hiddenColumns.visibleToAbsoluteColumn(startRes + x);
             if (column > row_annotations.length - 1)
             {
               break;
@@ -1177,7 +1187,7 @@ public class AnnotationRenderer
     g.setColor(HELIX_COLOUR);
 
     int sCol = (lastSSX / charWidth)
-            + hiddenColumns.adjustForHiddenColumns(startRes);
+            + hiddenColumns.visibleToAbsoluteColumn(startRes);
     int x1 = lastSSX;
     int x2 = (x * charWidth);
 
@@ -1277,7 +1287,7 @@ public class AnnotationRenderer
       column = sRes + x;
       if (hasHiddenColumns)
       {
-        column = hiddenColumns.adjustForHiddenColumns(column);
+        column = hiddenColumns.visibleToAbsoluteColumn(column);
       }
 
       if (column > aaMax)
@@ -1357,7 +1367,7 @@ public class AnnotationRenderer
       column = sRes + x;
       if (hasHiddenColumns)
       {
-        column = hiddenColumns.adjustForHiddenColumns(column);
+        column = hiddenColumns.visibleToAbsoluteColumn(column);
       }
 
       if (column > aaMax)