Jalview-JS/JAL-3253-applet also comments relating to JAL-3268
[jalview.git] / src / jalview / project / Jalview2XML.java
index 7f550ee..ab4a3eb 100644 (file)
@@ -34,7 +34,6 @@ import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
 import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.bin.Cache;
-import jalview.bin.Instance;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
@@ -83,7 +82,6 @@ import jalview.schemes.ColourSchemeProperty;
 import jalview.schemes.FeatureColour;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureSelectionManager;
 import jalview.structures.models.AAStructureBindingModel;
 import jalview.util.Format;
 import jalview.util.MessageManager;
@@ -802,6 +800,9 @@ public class Jalview2XML
           String fileName, JarOutputStream jout)
   {
 
+    // BH: Question: What is this Dataset for, as it seems to
+    // duplicate the actual XML file data.
+
     for (String dssids : dsses.keySet())
     {
       AlignFrame _af = dsses.get(dssids);
@@ -2380,7 +2381,7 @@ public class Jalview2XML
     if (calcIdParam.getVersion().equals("1.0"))
     {
       final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]);
-      Jws2Instance service = Jws2Discoverer.getDiscoverer()
+      Jws2Instance service = Jws2Discoverer.getInstance()
               .getPreferredServiceFor(calcIds);
       if (service != null)
       {
@@ -2856,8 +2857,12 @@ public class Jalview2XML
         {
           jarentry = jin.getNextJarEntry();
         }
-
-        if (jarentry != null && jarentry.getName().endsWith(".xml"))
+        String name = (jarentry == null ? null : jarentry.getName());
+        if (name != null && name.endsWith(".xml")
+        // The question here is what to do with the two
+        // .xml files in the jvp file. They are identical?
+        // && name.indexOf(" Dataset for ") < 0 // BH 2019.05.21
+        )
         {
           JAXBContext jc = JAXBContext
                   .newInstance("jalview.xml.binding.jalview");
@@ -2916,9 +2921,9 @@ public class Jalview2XML
       {
         // used to attempt to parse as V1 castor-generated xml
       }
-      if (Instance.getDesktop() != null)
+      if (Desktop.getInstance() != null)
       {
-        Instance.getDesktop().stopLoading();
+        Desktop.getInstance().stopLoading();
       }
       if (af != null)
       {
@@ -2946,7 +2951,7 @@ public class Jalview2XML
      */
     for (AlignFrame fr : gatherToThisFrame.values())
     {
-      Instance.getDesktop().gatherViews(fr);
+      Desktop.getInstance().gatherViews(fr);
     }
 
     restoreSplitFrames();
@@ -2954,8 +2959,7 @@ public class Jalview2XML
     {
       if (ds.getCodonFrames() != null)
       {
-        StructureSelectionManager
-                .getStructureSelectionManager(Instance.getDesktop())
+        Desktop.getInstance().getStructureSelectionManager()
                 .registerMappings(ds.getCodonFrames());
       }
     }
@@ -2964,9 +2968,9 @@ public class Jalview2XML
       reportErrors();
     }
 
-    if (Instance.getDesktop() != null)
+    if (Desktop.getInstance() != null)
     {
-      Instance.getDesktop().stopLoading();
+      Desktop.getInstance().stopLoading();
     }
 
     return af;
@@ -3047,7 +3051,7 @@ public class Jalview2XML
      */
     for (SplitFrame sf : gatherTo)
     {
-      Instance.getDesktop().gatherViews(sf);
+      Desktop.getInstance().gatherViews(sf);
     }
 
     splitFrameCandidates.clear();
@@ -3576,8 +3580,7 @@ public class Jalview2XML
             {
               entry.setProperty(prop.getName(), prop.getValue());
             }
-            StructureSelectionManager
-                    .getStructureSelectionManager(Instance.getDesktop())
+            Desktop.getInstance().getStructureSelectionManager()
                     .registerPDBEntry(entry);
             // adds PDBEntry to datasequence's set (since Jalview 2.10)
             if (al.getSequenceAt(i).getDatasetSequence() != null)
@@ -4977,8 +4980,18 @@ public class Jalview2XML
       viewport.setViewName(view.getViewName());
       af.setInitialTabVisible();
     }
-    af.setBounds(safeInt(view.getXpos()), safeInt(view.getYpos()),
-            safeInt(view.getWidth()), safeInt(view.getHeight()));
+    int x = safeInt(view.getXpos());
+    int y = safeInt(view.getYpos());
+    int w = safeInt(view.getWidth());
+    int h = safeInt(view.getHeight());
+    // // BH we cannot let the title bar go off the top
+    // if (Platform.isJS())
+    // {
+    // x = Math.max(50 - w, x);
+    // y = Math.max(0, y);
+    // }
+
+    af.setBounds(x, y, w, h);
     // startSeq set in af.alignPanel.updateLayout below
     af.alignPanel.updateLayout();
     ColourSchemeI cs = null;