Merge branch 'develop' into features/JAL-2360colourSchemeApplicability
[jalview.git] / src / jalview / gui / Jalview2XML.java
index fab4113..7057c2a 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -37,6 +37,8 @@ import jalview.datamodel.StructureViewerModel;
 import jalview.datamodel.StructureViewerModel.StructureData;
 import jalview.ext.varna.RnaModel;
 import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
 import jalview.schemabinding.version2.AlcodMap;
 import jalview.schemabinding.version2.AlcodonFrame;
 import jalview.schemabinding.version2.Annotation;
@@ -127,7 +129,6 @@ import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 
 import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
 
 import org.exolab.castor.xml.Marshaller;
@@ -992,17 +993,16 @@ public class Jalview2XML
             }
           }
 
-          if (entry.getProperty() != null && !entry.getProperty().isEmpty())
+          Enumeration<String> props = entry.getProperties();
+          if (props.hasMoreElements())
           {
             PdbentryItem item = new PdbentryItem();
-            Hashtable properties = entry.getProperty();
-            Enumeration en2 = properties.keys();
-            while (en2.hasMoreElements())
+            while (props.hasMoreElements())
             {
               Property prop = new Property();
-              String key = en2.nextElement().toString();
+              String key = props.nextElement();
               prop.setName(key);
-              prop.setValue(properties.get(key).toString());
+              prop.setValue(entry.getProperty(key).toString());
               item.addProperty(prop);
             }
             pdb.addPdbentryItem(item);
@@ -1186,7 +1186,7 @@ public class Jalview2XML
             }
             else
             {
-              jGroup.setColour(ColourSchemeProperty.getColourName(sg.cs));
+              jGroup.setColour(sg.cs.getSchemeName());
             }
           }
           else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient)
@@ -1202,7 +1202,7 @@ public class Jalview2XML
           }
           else
           {
-            jGroup.setColour(ColourSchemeProperty.getColourName(sg.cs));
+            jGroup.setColour(sg.cs.getSchemeName());
           }
 
           jGroup.setPidThreshold(sg.cs.getThreshold());
@@ -1723,8 +1723,7 @@ public class Jalview2XML
     }
     else
     {
-      ac.setColourScheme(ColourSchemeProperty.getColourName(acg
-              .getBaseColour()));
+      ac.setColourScheme(ColourSchemeProperty.getColourName(acg.getBaseColour()));
     }
 
     ac.setMaxColour(acg.getMaxColour().getRGB());
@@ -2637,10 +2636,10 @@ public class Jalview2XML
           @Override
           public void run()
           {
-            JOptionPane.showInternalMessageDialog(Desktop.desktop,
+            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                     finalErrorMessage, "Error "
                             + (saving ? "saving" : "loading")
-                            + " Jalview file", JOptionPane.WARNING_MESSAGE);
+                            + " Jalview file", JvOptionPane.WARNING_MESSAGE);
           }
         });
       }
@@ -3018,7 +3017,8 @@ public class Jalview2XML
                 entry.setType(PDBEntry.Type.FILE);
               }
             }
-            if (ids[p].getFile() != null)
+            // jprovider is null when executing 'New View'
+            if (ids[p].getFile() != null && jprovider != null)
             {
               if (!pdbloaded.containsKey(ids[p].getFile()))
               {
@@ -3032,12 +3032,11 @@ public class Jalview2XML
             }
             if (ids[p].getPdbentryItem() != null)
             {
-              entry.setProperty(new Hashtable());
               for (PdbentryItem item : ids[p].getPdbentryItem())
               {
                 for (Property pr : item.getProperty())
                 {
-                  entry.getProperty().put(pr.getName(), pr.getValue());
+                  entry.setProperty(pr.getName(), pr.getValue());
                 }
               }
             }
@@ -3345,7 +3344,7 @@ public class Jalview2XML
           }
           else
           {
-            cs = ColourSchemeProperty.getColour(al, jGroup.getColour());
+            cs = ColourSchemeProperty.getColourScheme(al, jGroup.getColour());
           }
 
           if (cs != null)
@@ -3402,8 +3401,8 @@ public class Jalview2XML
         }
         if (jGroup.getConsThreshold() != 0)
         {
-          Conservation c = new Conservation("All", 3,
-                  sg.getSequences(null), 0, sg.getWidth() - 1);
+          Conservation c = new Conservation("All", sg.getSequences(null),
+                  0, sg.getWidth() - 1);
           c.calculate();
           c.verdict(false, 25);
           sg.cs.setConservation(c);
@@ -4231,8 +4230,7 @@ public class Jalview2XML
       StructureData filedat = oldFiles.get(id);
       String pdbFile = filedat.getFilePath();
       SequenceI[] seq = filedat.getSeqList().toArray(new SequenceI[0]);
-      binding.getSsm().setMapping(seq, null, pdbFile,
-              jalview.io.AppletFormatAdapter.FILE);
+      binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE);
       binding.addSequenceForStructFile(pdbFile, seq);
     }
     // and add the AlignmentPanel's reference to the view panel
@@ -4347,7 +4345,7 @@ public class Jalview2XML
     af = new AlignFrame(al, view.getWidth(), view.getHeight(),
             uniqueSeqSetId, viewId);
 
-    af.setFileName(file, "Jalview");
+    af.setFileName(file, FileFormat.Jalview);
 
     for (int i = 0; i < JSEQ.length; i++)
     {
@@ -4422,10 +4420,12 @@ public class Jalview2XML
 
     af.viewport.setShowAnnotation(view.getShowAnnotation());
     af.viewport.setAbovePIDThreshold(view.getPidSelected());
+    af.viewport.setThreshold(view.getPidThreshold());
 
     af.viewport.setColourText(view.getShowColourText());
 
     af.viewport.setConservationSelected(view.getConservationSelected());
+    af.viewport.setIncrement(view.getConsThreshold());
     af.viewport.setShowJVSuffix(view.getShowFullId());
     af.viewport.setRightAlignIds(view.getRightAlignIds());
     af.viewport.setFont(
@@ -4470,12 +4470,11 @@ public class Jalview2XML
       }
       else
       {
-        cs = ColourSchemeProperty.getColour(al, view.getBgColour());
+        cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour());
       }
 
       if (cs != null)
       {
-        cs.setThreshold(view.getPidThreshold(), true);
         cs.setConsensus(af.viewport.getSequenceConsensusHash());
       }
     }
@@ -4730,7 +4729,8 @@ public class Jalview2XML
                     );
           }
 
-          if (viewAnnColour.getColourScheme().equals("None"))
+          if (viewAnnColour.getColourScheme().equals(
+                  ResidueColourScheme.NONE))
           {
             cs = new AnnotationColourGradient(
                     annAlignment.getAlignmentAnnotation()[i],
@@ -4750,7 +4750,7 @@ public class Jalview2XML
           {
             cs = new AnnotationColourGradient(
                     annAlignment.getAlignmentAnnotation()[i],
-                    ColourSchemeProperty.getColour(al,
+                    ColourSchemeProperty.getColourScheme(al,
                             viewAnnColour.getColourScheme()),
                     viewAnnColour.getAboveThreshold());
           }
@@ -4778,7 +4778,7 @@ public class Jalview2XML
               }
 
               /*
-               * if (viewAnnColour.getColourScheme().equals("None" )) { sg.cs =
+               * if (viewAnnColour.getColourScheme().equals(ResidueColourScheme.NONE)) { sg.cs =
                * new AnnotationColourGradient(
                * annAlignment.getAlignmentAnnotation()[i], new
                * java.awt.Color(viewAnnColour. getMinColour()), new