refactor to allow distinct StructureSelectionManager instances for
[jalview.git] / src / jalview / gui / Jalview2XML.java
old mode 100755 (executable)
new mode 100644 (file)
index 147a68d..e639844
@@ -48,7 +48,7 @@ import jalview.util.jarInputStreamProvider;
  * will be :)
  * 
  * @author $author$
- * @version $Revision$
+ * @version $Revision: 1.134 $
  */
 public class Jalview2XML
 {
@@ -624,6 +624,7 @@ public class Jalview2XML
                     state.setAlignwithAlignPanel(jmol.isUsedforaligment(ap));
                     state.setColourwithAlignPanel(jmol
                             .isUsedforcolourby(ap));
+                    state.setColourByJmol(jmol.isColouredByJmol());
                     if (!jmolViewIds.contains(state.getViewId()))
                     {
                       // Make sure we only store a Jmol state once in each XML
@@ -2573,13 +2574,12 @@ public class Jalview2XML
                 { new int[]
                 { x, y, width, height }, "",
                     new Hashtable<String, Object[]>(), new boolean[]
-                    { false, false } });
-                // Legacy->2.7 conversion: if there is no attribute for
-                // colouring with the alignPanel then by default we set the
-                // first encountered view to be the default source of colour
-                // information.
+                    { false, false, true } });
+                // Legacy pre-2.7 conversion JAL-823 : 
+                // do not assume any view has to be linked for colour by sequence
               }
-              // TODO: assemble String[] { pdb files }, String[] { id for each
+              
+              // assemble String[] { pdb files }, String[] { id for each
               // file }, orig_fileloc, SequenceI[][] {{ seqs_file 1 }, {
               // seqs_file 2}, boolean[] {
               // linkAlignPanel,superposeWithAlignpanel}} from hash
@@ -2587,11 +2587,13 @@ public class Jalview2XML
               ((boolean[]) jmoldat[3])[0] |= ids[p].getStructureState(s)
                       .hasAlignwithAlignPanel() ? ids[p].getStructureState(
                       s).getAlignwithAlignPanel() : false;
-              // always colour by linked panel if not specified
+              // never colour by linked panel if not specified
               ((boolean[]) jmoldat[3])[1] |= ids[p].getStructureState(s)
                       .hasColourwithAlignPanel() ? ids[p]
                       .getStructureState(s).getColourwithAlignPanel()
                       : false;
+              // default for pre-2.7 projects is that Jmol colouring is enabled
+              ((boolean[])jmoldat[3])[2] &=ids[p].getStructureState(s).hasColourByJmol() ? ids[p].getStructureState(s).getColourByJmol() : true;
 
               if (((String) jmoldat[1]).length() < ids[p]
                       .getStructureState(s).getContent().length())
@@ -2631,7 +2633,7 @@ public class Jalview2XML
           int[] geom = (int[]) svattrib[0];
           String state = (String) svattrib[1];
           Hashtable<String, Object[]> oldFiles = (Hashtable<String, Object[]>) svattrib[2];
-          final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1];
+          final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1], jmolColouring=((boolean[])svattrib[3])[2];
           int x = geom[0], y = geom[1], width = geom[2], height = geom[3];
           // collate the pdbfile -> sequence mappings from this view
           Vector<String> pdbfilenames = new Vector<String>();
@@ -2787,7 +2789,7 @@ public class Jalview2XML
                     try
                     {
                       sview = new AppJmol(pdbf, id, sq, alf.alignPanel,
-                              useinJmolsuperpos, usetoColourbyseq, fileloc,
+                              useinJmolsuperpos, usetoColourbyseq, jmolColouring, fileloc,
                               rect, vid);
                     } catch (OutOfMemoryError ex)
                     {
@@ -2829,8 +2831,7 @@ public class Jalview2XML
               String pdbFile = (String) filedat[0];
               SequenceI[] seq = (SequenceI[]) ((Vector<SequenceI>) filedat[2])
                       .toArray(new SequenceI[0]);
-              StructureSelectionManager.getStructureSelectionManager()
-                      .setMapping(seq, null, pdbFile,
+              ((AppJmol) comp).jmb.ssm.setMapping(seq, null, pdbFile,
                               jalview.io.AppletFormatAdapter.FILE);
               ((AppJmol) comp).jmb.addSequenceForStructFile(pdbFile, seq);
             }
@@ -2846,7 +2847,7 @@ public class Jalview2XML
             }
             if (usetoColourbyseq)
             {
-              ((AppJmol) comp).useAlignmentPanelForColourbyseq(ap);
+              ((AppJmol) comp).useAlignmentPanelForColourbyseq(ap, !jmolColouring);
             }
             else
             {