Merge branch 'develop' into features/JAL-2446NCList
[jalview.git] / src / jalview / ext / jmol / JmolCommands.java
index d5676c5..a809cae 100644 (file)
  */
 package jalview.ext.jmol;
 
+import jalview.api.AlignViewportI;
 import jalview.api.FeatureRenderer;
 import jalview.api.SequenceRenderer;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureMapping;
 import jalview.structure.StructureMappingcommandSet;
@@ -30,6 +32,7 @@ import jalview.structure.StructureSelectionManager;
 
 import java.awt.Color;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Routines for generating Jmol commands for Jalview/Jmol binding another
@@ -51,10 +54,11 @@ public class JmolCommands
   public static StructureMappingcommandSet[] getColourBySequenceCommand(
           StructureSelectionManager ssm, String[] files,
           SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr,
-          AlignmentI alignment)
+          AlignViewportI viewport)
   {
-
-    ArrayList<StructureMappingcommandSet> cset = new ArrayList<StructureMappingcommandSet>();
+    ColumnSelection cs = viewport.getColumnSelection();
+    AlignmentI al = viewport.getAlignment();
+    List<StructureMappingcommandSet> cset = new ArrayList<StructureMappingcommandSet>();
 
     for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
     {
@@ -74,9 +78,9 @@ public class JmolCommands
         for (int sp, m = 0; m < mapping.length; m++)
         {
           if (mapping[m].getSequence() == sequence[pdbfnum][s]
-                  && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1)
+                  && (sp = al.findIndex(sequence[pdbfnum][s])) > -1)
           {
-            SequenceI asp = alignment.getSequenceAt(sp);
+            SequenceI asp = al.getSequenceAt(sp);
             for (int r = 0; r < asp.getLength(); r++)
             {
               // no mapping to gaps in sequence
@@ -99,6 +103,16 @@ public class JmolCommands
               {
                 col = fr.findFeatureColour(col, sequence[pdbfnum][s], r);
               }
+
+              /*
+               * shade hidden regions darker
+               */
+              if (!cs.isVisible(r))
+              {
+                // col = ColorUtils.darkerThan(col);
+                col = Color.GRAY;
+              }
+
               String newSelcom = (mapping[m].getChain() != " " ? ":"
                       + mapping[m].getChain() : "")
                       + "/"