*/\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
\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
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
}\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
* @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
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
\r
Annotation an = new Annotation();\r
an.setDescription(aa[i].description);\r
+\r
+ if(aa[i].sequenceRef!=null)\r
+ {\r
+ an.setSequenceRef(aa[i].sequenceRef.getName());\r
+ }\r
+\r
if(aa[i].graph>0)\r
{\r
an.setGraph(true);\r
an.setGraphType(aa[i].graph);\r
+ if(aa[i].getThreshold()!=null)\r
+ {\r
+ ThresholdLine line = new ThresholdLine();\r
+ line.setLabel(aa[i].getThreshold().label);\r
+ line.setValue(aa[i].getThreshold().value);\r
+ line.setColour(aa[i].getThreshold().colour.getRGB());\r
+ an.setThresholdLine(line);\r
+ }\r
}\r
+ else\r
+ an.setGraph(false);\r
+\r
an.setLabel(aa[i].label);\r
\r
AnnotationElement ae;\r
cs));\r
}\r
}\r
+ else if(sg.cs instanceof jalview.schemes.AnnotationColourGradient)\r
+ {\r
+ groups[i].setColour(\r
+ ColourSchemeProperty.getColourName(\r
+ ( (jalview.schemes.AnnotationColourGradient) sg.cs).getBaseColour()));\r
+ }\r
else if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
{\r
groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
view.setBgColour(SetUserColourScheme(av.getGlobalColourScheme(),\r
userColours, jms));\r
}\r
+ else if(av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)\r
+ {\r
+ jalview.schemes.AnnotationColourGradient acg\r
+ = (jalview.schemes.AnnotationColourGradient)av.getGlobalColourScheme();\r
+\r
+ AnnotationColours ac = new AnnotationColours();\r
+ ac.setAboveThreshold(acg.getAboveThreshold());\r
+ ac.setThreshold(acg.getAnnotationThreshold());\r
+ ac.setAnnotation(acg.getAnnotation());\r
+ if(acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)\r
+ ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),\r
+ userColours, jms));\r
+ else\r
+ ac.setColourScheme(ColourSchemeProperty.getColourName(acg.getBaseColour()));\r
+\r
+ ac.setMaxColour(acg.getMaxColour().getRGB());\r
+ ac.setMinColour(acg.getMinColour().getRGB());\r
+ view.setAnnotationColours(ac);\r
+ view.setBgColour("AnnotationColourGradient");\r
+ }\r
else\r
{\r
view.setBgColour(ColourSchemeProperty.getColourName(\r
\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
+ String [] renderOrder =\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder;\r
+ for(int ro=0; ro<renderOrder.length; ro++)\r
{\r
- String type = e.nextElement().toString();\r
Setting setting = new Setting();\r
- setting.setType(type);\r
+ setting.setType(renderOrder[ro]);\r
setting.setColour(\r
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(type).getRGB()\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(renderOrder[ro]).getRGB()\r
);\r
\r
setting.setDisplay(\r
- av.featuresDisplayed.containsKey(type)\r
+ av.featuresDisplayed.containsKey(renderOrder[ro])\r
);\r
\r
fs.addSetting(setting);\r
}\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
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
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
*\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
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
+ unmar.setValidation(false);\r
+ object = (JalviewModel) unmar.unmarshal( in );\r
+\r
af = LoadFromObject(object);\r
entryCount++;\r
}\r
}\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("Successfully loaded archive file");\r
+ return af;\r
+ }\r
ex.printStackTrace();\r
System.err.println("Exception whilst loading jalview XML file : " +\r
ex + "\n");\r
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
{\r
anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa].getDisplayCharacter(),\r
ae[aa].getDescription(),\r
- ae[aa].getSecondaryStructure().charAt(0),\r
+ ae[aa].getSecondaryStructure().length()==0?' ':ae[aa].getSecondaryStructure().charAt(0),\r
ae[aa].getValue());\r
}\r
\r
\r
if (an[i].getGraph())\r
{\r
- jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
- an[i].getDescription(), anot, 0, 0,\r
- an[i].getGraphType());\r
+ jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
+ an[i].getDescription(), anot, 0, 0,\r
+ an[i].getGraphType());\r
+\r
+ if (an[i].getThresholdLine() != null)\r
+ {\r
+ jaa.setThreshold(new jalview.datamodel.GraphLine(\r
+ an[i].getThresholdLine().getValue(),\r
+ an[i].getThresholdLine().getLabel(),\r
+ new java.awt.Color(an[i].getThresholdLine().getColour()))\r
+ );\r
+\r
+ }\r
+\r
}\r
else\r
{\r
an[i].getDescription(), anot);\r
}\r
\r
+ if(an[i].getSequenceRef()!=null)\r
+ {\r
+ jaa.createSequenceMapping(\r
+ al.findName(an[i].getSequenceRef()), 1\r
+ );\r
+ al.findName(an[i].getSequenceRef()).addAlignmentAnnotation(jaa);\r
+ }\r
+\r
al.addAnnotation(jaa);\r
}\r
}\r
groups[i].getColour());\r
}\r
\r
- cs.setThreshold(groups[i].getPidThreshold(), true);\r
+ if(cs!=null)\r
+ cs.setThreshold(groups[i].getPidThreshold(), true);\r
}\r
\r
Vector seqs = new Vector();\r
{\r
cs = GetUserColourScheme(jms, view.getBgColour());\r
}\r
+ else if(view.getBgColour().startsWith("Annotation"))\r
+ {\r
+ //int find annotation\r
+ for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++)\r
+ {\r
+ if (af.viewport.alignment.getAlignmentAnnotation()[i].label.\r
+ equals(view.getAnnotationColours().getAnnotation()))\r
+ {\r
+ if (af.viewport.alignment.getAlignmentAnnotation()[i].\r
+ getThreshold() == null)\r
+ {\r
+ af.viewport.alignment.getAlignmentAnnotation()[i].\r
+ setThreshold(\r
+ new jalview.datamodel.GraphLine(\r
+ view.getAnnotationColours().getThreshold(),\r
+ "Threshold", java.awt.Color.black)\r
+\r
+ );\r
+ }\r
+\r
+\r
+ if (view.getAnnotationColours().getColourScheme().equals(\r
+ "None"))\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMinColour()),\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMaxColour()),\r
+ view.getAnnotationColours().getAboveThreshold());\r
+ }\r
+ else if (view.getAnnotationColours().getColourScheme().\r
+ startsWith("ucs"))\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ GetUserColourScheme(jms, view.getAnnotationColours().\r
+ getColourScheme()),\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+ else\r
+ {\r
+ cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ ColourSchemeProperty.getColour(al,\r
+ view.getAnnotationColours().getColourScheme()),\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+\r
+ // Also use these settings for all the groups\r
+ if (al.getGroups() != null)\r
+ for (int g = 0; g < al.getGroups().size(); g++)\r
+ {\r
+ jalview.datamodel.SequenceGroup sg\r
+ = (jalview.datamodel.SequenceGroup)al.getGroups().elementAt(g);\r
+\r
+ if(sg.cs == null)\r
+ continue;\r
+\r
+\r
+ /* if (view.getAnnotationColours().getColourScheme().equals("None"))\r
+ {\r
+ sg.cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMinColour()),\r
+ new java.awt.Color(view.getAnnotationColours().\r
+ getMaxColour()),\r
+ view.getAnnotationColours().getAboveThreshold());\r
+ }\r
+ else*/\r
+ {\r
+ sg.cs = new AnnotationColourGradient(\r
+ af.viewport.alignment.getAlignmentAnnotation()[i],\r
+ sg.cs,\r
+ view.getAnnotationColours().getAboveThreshold()\r
+ );\r
+ }\r
+\r
+ }\r
+\r
+\r
+ break;\r
+ }\r
+\r
+ }\r
+ }\r
else\r
{\r
cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
return af;\r
}\r
}\r
+\r