Reverse order for windows, readin from url
authoramwaterhouse <Andrew Waterhouse>
Thu, 2 Jun 2005 11:06:21 +0000 (11:06 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 2 Jun 2005 11:06:21 +0000 (11:06 +0000)
src/jalview/gui/Jalview2XML.java

index 3eebf5c..fa8e50b 100755 (executable)
@@ -7,6 +7,7 @@ import java.util.jar.*;
 import jalview.binding.*;\r
 import jalview.schemes.*;\r
 import javax.swing.JInternalFrame;\r
+import java.net.URL;\r
 \r
 \r
 public class Jalview2XML\r
@@ -17,6 +18,9 @@ public class Jalview2XML
   {\r
       long creation = System.currentTimeMillis();\r
       JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
+      if(frames==null)\r
+        return;\r
+\r
       try{\r
         FileOutputStream fos = new FileOutputStream(statefile);\r
         JarOutputStream jout = new JarOutputStream(fos);\r
@@ -25,7 +29,8 @@ public class Jalview2XML
         PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, "UTF-8"));\r
 \r
         Vector shortNames = new Vector();\r
-        for (int i = 0; i < frames.length; i++)\r
+        //REVERSE ORDER\r
+        for (int i = frames.length-1; i > -1; i--)\r
         {\r
           if (frames[i] instanceof AlignFrame)\r
           {\r
@@ -33,8 +38,9 @@ public class Jalview2XML
 \r
             String shortName = af.getTitle();\r
 \r
-            shortName = shortName.replace('/', '_');\r
-            shortName = shortName.replace('\\', '_');\r
+            if(shortName.indexOf(File.separatorChar)>-1)\r
+              shortName = shortName.substring(\r
+                    shortName.lastIndexOf(File.separatorChar)+1);\r
 \r
             int count=1;\r
             while( shortNames.contains(shortName) )\r
@@ -331,11 +337,20 @@ public class Jalview2XML
     JalviewModel object = new JalviewModel();\r
     try{\r
       //UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING\r
-      JarInputStream jin = new JarInputStream(new FileInputStream(file));\r
+\r
+      URL url = null;\r
+      if( file.startsWith("http://"))\r
+       url = new URL(file);\r
+\r
+      JarInputStream jin = null;\r
       JarEntry jarentry=null;\r
       int entryCount = 1;\r
       do{\r
-        jin = new JarInputStream(new FileInputStream(file));\r
+        if (url != null)\r
+          jin = new JarInputStream(url.openStream());\r
+        else\r
+          jin = new JarInputStream(new FileInputStream(file));\r
+\r
         for(int i=0; i<entryCount; i++)\r
           jarentry = jin.getNextJarEntry();\r
 \r
@@ -431,15 +446,18 @@ public class Jalview2XML
       for (int i = 0; i < groups.length; i++)\r
       {\r
        ColourSchemeI cs=null;\r
-       if(groups[i].getColour().startsWith("ucs"))\r
-         cs = GetUserColourScheme(jms,groups[i].getColour());\r
-       else\r
-         cs = ColourSchemeProperty.getColour(al, groups[i].getColour() );\r
-\r
-       if (cs instanceof ResidueColourScheme)\r
-         ( (ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
-       else if (cs instanceof ScoreColourScheme)\r
-      ( (ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+       if(groups[i].getColour()!=null)\r
+       {\r
+         if (groups[i].getColour().startsWith("ucs"))\r
+           cs = GetUserColourScheme(jms, groups[i].getColour());\r
+         else\r
+           cs = ColourSchemeProperty.getColour(al, groups[i].getColour());\r
+\r
+         if (cs instanceof ResidueColourScheme)\r
+           ( (ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+         else if (cs instanceof ScoreColourScheme)\r
+           ( (ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+       }\r
 \r
         jalview.datamodel.SequenceGroup sg = new jalview.datamodel.SequenceGroup\r
                 (groups[i].getName(),\r
@@ -504,19 +522,25 @@ public class Jalview2XML
     af.viewport.setShowText( view.getShowText() );\r
 \r
     ColourSchemeI cs=null;\r
-    if (view.getBgColour().startsWith("ucs"))\r
-      cs = GetUserColourScheme(jms, view.getBgColour());\r
-    else\r
-      cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
-    af.viewport.setGlobalColourScheme( cs );\r
+    if(view.getBgColour()!=null)\r
+    {\r
+\r
+      if (view.getBgColour().startsWith("ucs"))\r
+        cs = GetUserColourScheme(jms, view.getBgColour());\r
+      else\r
+        cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
 \r
-    if(cs instanceof ConservationColourScheme)\r
-      ( (ConservationColourScheme) cs).inc = view.getConsThreshold();\r
+      if (cs instanceof ConservationColourScheme)\r
+        ( (ConservationColourScheme) cs).inc = view.getConsThreshold();\r
+\r
+      if (cs instanceof ResidueColourScheme)\r
+        ( (ResidueColourScheme) cs).setThreshold(view.getPidThreshold());\r
+      else if (cs instanceof ScoreColourScheme)\r
+        ( (ScoreColourScheme) cs).setThreshold(view.getPidThreshold());\r
+\r
+    }\r
+    af.viewport.setGlobalColourScheme( cs );\r
 \r
-    if (cs instanceof ResidueColourScheme)\r
-      ( (ResidueColourScheme) cs).setThreshold(view.getPidThreshold());\r
-    else if (cs instanceof ScoreColourScheme)\r
-      ( (ScoreColourScheme) cs).setThreshold(view.getPidThreshold());\r
 \r
     af.viewport.setColourAppliesToAllGroups(false);\r
     af.changeColour(af.viewport.getGlobalColourScheme());\r