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