From: amwaterhouse Date: Tue, 4 Apr 2006 09:31:05 +0000 (+0000) Subject: Allows loading of archive XML X-Git-Tag: Release_2_08~87 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dcba450558710d0fb2466616d1d05d02d6a346f7;p=jalview.git Allows loading of archive XML --- diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 556ae41..ede020c 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -423,10 +423,14 @@ public class UserDefinedColours extends GUserDefinedColours InputStreamReader in = new InputStreamReader(new FileInputStream( file), "UTF-8"); - jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours(); - jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in); + jalview.schemabinding.version2.JalviewUserColours jucs + = new jalview.schemabinding.version2.JalviewUserColours(); - newColours = new Color[jucs.getColourCount()]; + org.exolab.castor.xml.Unmarshaller unmar + = new org.exolab.castor.xml.Unmarshaller(jucs); + jucs = (jalview.schemabinding.version2.JalviewUserColours) unmar.unmarshal( in ); + + newColours = new Color[jucs.getColourCount()]; for (int i = 0; i < 24; i++) { @@ -442,9 +446,34 @@ public class UserDefinedColours extends GUserDefinedColours } catch (Exception ex) { - System.out.println("Error loading User ColourFile\n"+ex); - } + //Could be Archive Jalview format + try{ + InputStreamReader in = new InputStreamReader(new FileInputStream( + file), "UTF-8"); + + jalview.binding.JalviewUserColours jucs + = new jalview.binding.JalviewUserColours(); + + jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in); + newColours = new Color[jucs.getColourCount()]; + + for (int i = 0; i < 24; i++) + { + newColours[i] = new Color(Integer.parseInt( + jucs.getColour(i).getRGB(), 16)); + } + if (newColours != null) + { + ucs = new UserColourScheme(newColours); + ucs.setName(jucs.getSchemeName()); + } + }catch(Exception ex2) + { ex2.printStackTrace(); } + + if(newColours==null) + System.out.println("Error loading User ColourFile\n"+ex); + } return ucs; }