For archive only
authoramwaterhouse <Andrew Waterhouse>
Tue, 4 Apr 2006 09:30:50 +0000 (09:30 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 4 Apr 2006 09:30:50 +0000 (09:30 +0000)
src/jalview/gui/Jalview2XML.java

index 893846c..5a4b03a 100755 (executable)
  */\r
 package jalview.gui;\r
 \r
-import jalview.io.*;\r
 \r
 import jalview.schemes.*;\r
 \r
+import jalview.gui.*;\r
+\r
 import java.io.*;\r
 \r
 import java.net.*;\r
@@ -32,7 +33,11 @@ import java.util.jar.*;
 \r
 import javax.swing.*;\r
 \r
-import jalview.binding.*;\r
+import org.exolab.castor.xml.*;\r
+\r
+import jalview.schemabinding.version2.*;\r
+\r
+\r
 \r
 \r
 /**\r
@@ -44,7 +49,7 @@ import jalview.binding.*;
 public class Jalview2XML\r
 {\r
     // SAVES SEVERAL ALIGNEMENT WINDOWS TO SAME JARFILE\r
-    public static void SaveState(File statefile)\r
+    public void SaveState(File statefile)\r
     {\r
         long creation = System.currentTimeMillis();\r
         JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
@@ -116,7 +121,7 @@ public class Jalview2XML
     }\r
 \r
     // USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW\r
-    public static void SaveAlignment(AlignFrame af, String jarFile,\r
+    public void SaveAlignment(AlignFrame af, String jarFile,\r
         String fileName)\r
     {\r
         try\r
@@ -148,7 +153,7 @@ public class Jalview2XML
      * @param jout DOCUMENT ME!\r
      * @param out DOCUMENT ME!\r
      */\r
-    public static void SaveState(AlignFrame af, long timeStamp,\r
+    public void SaveState(AlignFrame af, long timeStamp,\r
         String fileName, JarOutputStream jout, PrintWriter out)\r
     {\r
         Vector seqids = new Vector();\r
@@ -157,7 +162,7 @@ public class Jalview2XML
         AlignViewport av = af.viewport;\r
 \r
         JalviewModel object = new JalviewModel();\r
-        object.setVamsasModel(new jalview.binding.VamsasModel());\r
+        object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel());\r
 \r
         object.setCreationDate(new java.util.Date(timeStamp));\r
         object.setVersion(jalview.bin.Cache.getProperty("VERSION"));\r
@@ -316,6 +321,9 @@ public class Jalview2XML
                   an.setGraph(true);\r
                   an.setGraphType(aa[i].graph);\r
                 }\r
+                else\r
+                  an.setGraph(false);\r
+\r
                 an.setLabel(aa[i].label);\r
 \r
                 AnnotationElement ae;\r
@@ -461,7 +469,8 @@ public class Jalview2XML
 \r
         if(av.featuresDisplayed!=null)\r
         {\r
-          jalview.binding.FeatureSettings fs = new jalview.binding.FeatureSettings();\r
+          jalview.schemabinding.version2.FeatureSettings fs\r
+              = new jalview.schemabinding.version2.FeatureSettings();\r
 \r
           Enumeration e = af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours.keys();\r
           while (e.hasMoreElements())\r
@@ -508,7 +517,7 @@ public class Jalview2XML
         }\r
     }\r
 \r
-    static String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,\r
+    String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,\r
         Vector userColours, JalviewModelSequence jms)\r
     {\r
         String id = null;\r
@@ -519,12 +528,12 @@ public class Jalview2XML
             userColours.add(ucs);\r
 \r
             java.awt.Color[] colours = ucs.getColours();\r
-            jalview.binding.UserColours uc = new jalview.binding.UserColours();\r
-            jalview.binding.UserColourScheme jbucs = new jalview.binding.UserColourScheme();\r
+            jalview.schemabinding.version2.UserColours uc = new jalview.schemabinding.version2.UserColours();\r
+            jalview.schemabinding.version2.UserColourScheme jbucs = new jalview.schemabinding.version2.UserColourScheme();\r
 \r
             for (int i = 0; i < colours.length; i++)\r
             {\r
-                jalview.binding.Colour col = new jalview.binding.Colour();\r
+                jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();\r
                 col.setRGB(jalview.util.Format.getHexString(colours[i]));\r
                 jbucs.addColour(col);\r
             }\r
@@ -538,7 +547,7 @@ public class Jalview2XML
         return id;\r
     }\r
 \r
-    static jalview.schemes.UserColourScheme GetUserColourScheme(\r
+   jalview.schemes.UserColourScheme GetUserColourScheme(\r
         JalviewModelSequence jms, String id)\r
     {\r
         UserColours[] uc = jms.getUserColours();\r
@@ -571,9 +580,9 @@ public class Jalview2XML
      *\r
      * @param file DOCUMENT ME!\r
      */\r
-    public static AlignFrame LoadJalviewAlign(String file)\r
+    public AlignFrame LoadJalviewAlign(String file)\r
     {\r
-        JalviewModel object = new JalviewModel();\r
+\r
         jalview.gui.AlignFrame af = null;\r
 \r
         try\r
@@ -604,12 +613,28 @@ public class Jalview2XML
                 for (int i = 0; i < entryCount; i++)\r
                 {\r
                     jarentry = jin.getNextJarEntry();\r
-                }\r
+\r
+                  }\r
+\r
+\r
+                  class NoDescIDResolver implements IDResolver\r
+                  {\r
+                    public Object resolve(String idref)\r
+                    {\r
+                      System.out.println(idref+" used");\r
+                      return null;\r
+                    }\r
+                  }\r
+\r
 \r
                 if (jarentry != null)\r
                 {\r
                     InputStreamReader in = new InputStreamReader(jin, "UTF-8");\r
-                    object = (JalviewModel) object.unmarshal(in);\r
+                    JalviewModel object = new JalviewModel();\r
+\r
+                    Unmarshaller unmar = new Unmarshaller(object);\r
+                    object = (JalviewModel) unmar.unmarshal( in );\r
+\r
                     af = LoadFromObject(object);\r
                     entryCount++;\r
                 }\r
@@ -629,6 +654,14 @@ public class Jalview2XML
         }\r
         catch (Exception ex)\r
         {\r
+          //Is Version 1 Jar file?\r
+          af =  new Jalview2XML_V1().LoadJalviewAlign(file);\r
+\r
+          if(af!=null)\r
+          {\r
+            System.out.println("Successfuly loaded archive file");\r
+            return af;\r
+          }\r
           ex.printStackTrace();\r
             System.err.println("Exception whilst loading jalview XML file : " +\r
                 ex + "\n");\r
@@ -642,7 +675,7 @@ public class Jalview2XML
         return af;\r
     }\r
 \r
-    static AlignFrame LoadFromObject(JalviewModel object)\r
+    AlignFrame LoadFromObject(JalviewModel object)\r
     {\r
         Vector seqids = new Vector();\r
         SequenceSet vamsasSet = object.getVamsasModel().getSequenceSet(0);\r
@@ -963,3 +996,4 @@ public class Jalview2XML
         return af;\r
     }\r
 }\r
+\r