*/\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
vamsasSeq.setId(id + "");\r
vamsasSeq.setName(jal.getSequenceAt(i).getName());\r
vamsasSeq.setSequence(jal.getSequenceAt(i).getSequence());\r
+ vamsasSeq.setDescription(jal.getSequenceAt(i).getDescription());\r
\r
jseq = new JSeq();\r
jseq.setStart(jal.getSequenceAt(i).getStart());\r
\r
if(jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures()!=null)\r
{\r
- Enumeration en = jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures().elements();\r
- while(en.hasMoreElements())\r
+ jalview.datamodel.SequenceFeature[] sf\r
+ = jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures();\r
+ int index = 0;\r
+ while(index < sf.length)\r
{\r
Features features = new Features();\r
- jalview.datamodel.SequenceFeature sf\r
- = (jalview.datamodel.SequenceFeature)en.nextElement();\r
-\r
- features.setBegin(sf.getBegin());\r
- features.setEnd(sf.getEnd());\r
- features.setDescription(sf.getDescription());\r
- features.setStatus(sf.getStatus());\r
- features.setType(sf.getType());\r
+\r
+ features.setBegin(sf[index].getBegin());\r
+ features.setEnd(sf[index].getEnd());\r
+ features.setDescription(sf[index].getDescription());\r
+ features.setStatus(sf[index].getStatus());\r
+ features.setType(sf[index].getType());\r
+ features.setFeatureGroup(sf[index].getFeatureGroup());\r
jseq.addFeatures(features);\r
+ index ++;\r
}\r
}\r
\r
\r
Annotation an = new Annotation();\r
an.setDescription(aa[i].description);\r
- an.setGraph(aa[i].isGraph);\r
+ if(aa[i].graph>0)\r
+ {\r
+ 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
view.setShowText(av.getShowText());\r
view.setWrapAlignment(av.getWrapAlignment());\r
\r
- if(af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed!=null)\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
setting.setColour(\r
af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(type).getRGB()\r
);\r
+\r
setting.setDisplay(\r
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed.contains(type)\r
+ av.featuresDisplayed.containsKey(type)\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("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
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
jseqs[i] = new jalview.datamodel.Sequence(vamsasSeq[i].getName(),\r
vamsasSeq[i].getSequence());\r
+ jseqs[i].setDescription( vamsasSeq[i].getDescription() );\r
\r
jseqs[i].setStart(JSEQ[i].getStart());\r
jseqs[i].setEnd(JSEQ[i].getEnd());\r
Features[] features = JSEQ[i].getFeatures();\r
for (int f = 0; f < features.length; f++)\r
{\r
- //features[f].getBegin()\r
jalview.datamodel.SequenceFeature sf\r
= new jalview.datamodel.SequenceFeature(features[f].getType(),\r
features[f].getDescription(), features[f].getStatus(),\r
- features[f].getBegin(), features[f].getEnd());\r
+ features[f].getBegin(), features[f].getEnd(),\r
+ features[f].getFeatureGroup());\r
+\r
al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);\r
}\r
}\r
\r
}\r
}\r
- /////////////////////////////////\r
+\r
+ /////////////////////////////////\r
//////////////////////////////////\r
//LOAD ANNOTATIONS\r
if (vamsasSet.getAnnotation() != null)\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
if (an[i].getGraph())\r
{\r
jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(),\r
- an[i].getDescription(), anot, 0, 0, 1);\r
+ an[i].getDescription(), anot, 0, 0,\r
+ an[i].getGraphType());\r
}\r
else\r
{\r
}\r
}\r
\r
+\r
/////////////////////////////////\r
// LOAD VIEWPORT\r
Viewport[] views = jms.getViewport();\r
}\r
\r
\r
+\r
af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),\r
view.getHeight());\r
af.viewport.setStartRes(view.getStartRes());\r
\r
if (view.getShowSequenceFeatures())\r
{\r
- af.featureSettings.setEnabled(true);\r
af.viewport.showSequenceFeatures = true;\r
- af.sequenceFeatures.setSelected(true);\r
+ af.showSeqFeatures.setSelected(true);\r
}\r
\r
if(jms.getFeatureSettings()!=null)\r
{\r
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed = new Vector();\r
- // af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed!=null)\r
- // jalview.binding.FeatureSettings fs = new jalview.binding.FeatureSettings();\r
+ af.viewport.featuresDisplayed = new Hashtable();\r
+ String [] renderOrder = new String[jms.getFeatureSettings().getSettingCount()];\r
for(int fs=0; fs<jms.getFeatureSettings().getSettingCount(); fs++)\r
{\r
Setting setting = jms.getFeatureSettings().getSetting(fs);\r
\r
af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(setting.getType(),\r
new java.awt.Color(setting.getColour()));\r
+\r
+ renderOrder[fs] = setting.getType();\r
+\r
if(setting.getDisplay())\r
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed.addElement(setting.getType());\r
+ af.viewport.featuresDisplayed.put(\r
+ setting.getType(), new Integer(setting.getColour()));\r
}\r
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder = renderOrder;\r
}\r
\r
+\r
Desktop.addInternalFrame(af, view.getTitle(),\r
view.getWidth(), view.getHeight());\r
\r
return af;\r
}\r
}\r
+\r