bugfixing for JAL-778
authorjprocter <Jim Procter>
Fri, 18 Feb 2011 17:18:25 +0000 (17:18 +0000)
committerjprocter <Jim Procter>
Fri, 18 Feb 2011 17:18:25 +0000 (17:18 +0000)
src/jalview/gui/Jalview2XML.java

index a93e84c..1fe6bf4 100755 (executable)
@@ -580,7 +580,6 @@ public class Jalview2XML
           {
             if (frames[f] instanceof AppJmol)
             {
-              // TODO: revise schema to allow many:one PDB id binding to viewer
               jmol = (AppJmol) frames[f];
               for (int peid = 0; peid < jmol.jmb.pdbentry.length; peid++)
               {
@@ -621,6 +620,9 @@ public class Jalview2XML
                     state.setWidth(jmol.getWidth());
                     state.setHeight(jmol.getHeight());
                     state.setViewId(jmol.getViewId());
+                    state.setAlignwithAlignPanel(jmol.isUsedforaligment(ap));
+                    state.setColourwithAlignPanel(jmol
+                            .isUsedforcolourby(ap));
                     if (!jmolViewIds.contains(state.getViewId()))
                     {
                       // Make sure we only store a Jmol state once in each XML
@@ -2498,14 +2500,33 @@ public class Jalview2XML
               if (!jmolViewIds.containsKey(sviewid))
               {
                 jmolViewIds.put(sviewid, new Object[]
-                { new int[]
-                { x, y, width, height }, "",
-                    new Hashtable<String, Object[]>() });
+                {
+                    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.
               }
               // TODO: assemble String[] { pdb files }, String[] { id for each
               // file }, orig_fileloc, SequenceI[][] {{ seqs_file 1 }, {
-              // seqs_file 2}} from hash
+              // seqs_file 2}, boolean[] {
+              // linkAlignPanel,superposeWithAlignpanel}} from hash
               Object[] jmoldat = (Object[]) jmolViewIds.get(sviewid);
+              ((boolean[]) jmoldat[3])[0] |= ids[p].getStructureState(s)
+                      .hasAlignwithAlignPanel() ? ids[p].getStructureState(
+                      s).getAlignwithAlignPanel() : false;
+              // always colour by linked panel if not specified
+              ((boolean[]) jmoldat[3])[1] |= ids[p].getStructureState(s)
+                      .hasColourwithAlignPanel() ? ids[p]
+                      .getStructureState(s).getColourwithAlignPanel()
+                      : false;
+
               if (((String) jmoldat[1]).length() < ids[p]
                       .getStructureState(s).getContent().length())
               {
@@ -2544,7 +2565,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];
           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>();
@@ -2700,8 +2721,8 @@ public class Jalview2XML
                     try
                     {
                       sview = new AppJmol(pdbf, id, sq, alf.alignPanel,
+                              useinJmolsuperpos, usetoColourbyseq,
                               fileloc,
-
                               rect, vid);
                     } catch (OutOfMemoryError ex)
                     {
@@ -2748,6 +2769,24 @@ public class Jalview2XML
                               jalview.io.AppletFormatAdapter.FILE);
               ((AppJmol) comp).jmb.addSequenceForStructFile(pdbFile, seq);
             }
+            // and add the AlignmentPanel's reference to the Jmol view
+            ((AppJmol) comp).addAlignmentPanel(ap);
+            if (useinJmolsuperpos)
+            {
+              ((AppJmol) comp).useAlignmentPanelForSuperposition(ap);
+            }
+            else
+            {
+              ((AppJmol) comp).excludeAlignmentPanelForSuperposition(ap);
+            }
+            if (usetoColourbyseq)
+            {
+              ((AppJmol) comp).useAlignmentPanelForColourbyseq(ap);
+            }
+            else
+            {
+              ((AppJmol) comp).excludeAlignmentPanelForColourbyseq(ap);
+            }
           }
         }
       }