X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FJalview2XML_V1.java;h=331e7381fe9fb1bba731934d16d2c86552658d6e;hb=833fafa77f2f63bea98ce1d6e1e4ee3e46e7bd53;hp=3b6678d1971b1ca056567619f1126848b38bc8df;hpb=21c29b20790ac555b2e2a124a034f6c6b4486270;p=jalview.git
diff --git a/src/jalview/gui/Jalview2XML_V1.java b/src/jalview/gui/Jalview2XML_V1.java
index 3b6678d..331e738 100755
--- a/src/jalview/gui/Jalview2XML_V1.java
+++ b/src/jalview/gui/Jalview2XML_V1.java
@@ -1,33 +1,57 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-
-import javax.swing.*;
-
-import org.exolab.castor.xml.*;
-import jalview.binding.*;
-import jalview.schemes.*;
+import jalview.analysis.Conservation;
+import jalview.binding.Annotation;
+import jalview.binding.AnnotationElement;
+import jalview.binding.Features;
+import jalview.binding.JGroup;
+import jalview.binding.JSeq;
+import jalview.binding.JalviewModel;
+import jalview.binding.JalviewModelSequence;
+import jalview.binding.Pdbids;
+import jalview.binding.Sequence;
+import jalview.binding.SequenceSet;
+import jalview.binding.Setting;
+import jalview.binding.Tree;
+import jalview.binding.UserColours;
+import jalview.binding.Viewport;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceFeature;
+import jalview.io.FileFormat;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.jarInputStreamProvider;
+import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.UnknownHostException;
+import java.util.Hashtable;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
/**
* DOCUMENT ME!
@@ -70,8 +94,8 @@ public class Jalview2XML_V1
for (int i = 0; i < csize; i++)
{
- newColours[i] = new java.awt.Color(Integer.parseInt(colours
- .getUserColourScheme().getColour(i).getRGB(), 16));
+ newColours[i] = new java.awt.Color(Integer.parseInt(
+ colours.getUserColourScheme().getColour(i).getRGB(), 16));
}
return new jalview.schemes.UserColourScheme(newColours);
@@ -103,42 +127,40 @@ public class Jalview2XML_V1
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");
- JalviewModel object = new JalviewModel();
+ entryCount++;
+ if (jarentry.getName().endsWith(".xml"))
+ {
+ Reader in = new InputStreamReader(jin, "UTF-8");
+ JalviewModel object = new JalviewModel();
- object = (JalviewModel) object.unmarshal(in);
+ object = object.unmarshal(in);
- af = LoadFromObject(object, file);
- entryCount++;
+ af = LoadFromObject(object, file);
+ }
}
+ jin.close();
} while (jarentry != null);
- } catch (final java.net.UnknownHostException ex)
+ } catch (final UnknownHostException ex)
{
ex.printStackTrace();
if (raiseGUI)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
- System.err.println("Couldn't locate Jalview XML file : " + ex
- + "\n");
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.formatMessage("label.couldnt_locate", new String[]{file}),
+ System.err.println(
+ "Couldn't locate Jalview XML file : " + ex + "\n");
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.couldnt_locate",
+ new String[]
+ { file }),
MessageManager.getString("label.url_not_found"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
}
});
}
@@ -151,12 +173,17 @@ public class Jalview2XML_V1
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Error loading " + file, "Error loading Jalview file",
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.error_loading_file_params", new String[]
+ { file }),
+ MessageManager
+ .getString("label.error_loading_jalview_file"),
+ JvOptionPane.WARNING_MESSAGE);
}
});
}
@@ -200,11 +227,10 @@ public class Jalview2XML_V1
Features[] features = JSEQ[i].getFeatures();
for (int f = 0; f < features.length; f++)
{
- jalview.datamodel.SequenceFeature sf = new jalview.datamodel.SequenceFeature(
- features[f].getType(), features[f].getDescription(),
- features[f].getStatus(), features[f].getBegin(),
+ SequenceFeature sf = new SequenceFeature(features[f].getType(),
+ features[f].getDescription(), features[f].getBegin(),
features[f].getEnd(), null);
-
+ sf.setStatus(features[f].getStatus());
al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);
}
}
@@ -215,8 +241,21 @@ public class Jalview2XML_V1
{
jalview.datamodel.PDBEntry entry = new jalview.datamodel.PDBEntry();
entry.setId(ids[p].getId());
- entry.setType(ids[p].getType());
+ if (ids[p].getType() != null)
+ {
+ if (ids[p].getType().equalsIgnoreCase("PDB"))
+ {
+ entry.setType(PDBEntry.Type.PDB);
+ }
+ else
+ {
+ entry.setType(PDBEntry.Type.FILE);
+ }
+ }
al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);
+ StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance)
+ .registerPDBEntry(entry);
}
}
@@ -268,12 +307,13 @@ public class Jalview2XML_V1
AlignFrame af = new AlignFrame(al, view.getWidth(), view.getHeight());
- af.setFileName(file, "Jalview");
+ af.setFileName(file, FileFormat.Jalview);
for (int i = 0; i < JSEQ.length; i++)
{
- af.viewport.setSequenceColour(af.viewport.getAlignment()
- .getSequenceAt(i), new java.awt.Color(JSEQ[i].getColour()));
+ af.viewport.setSequenceColour(
+ af.viewport.getAlignment().getSequenceAt(i),
+ new java.awt.Color(JSEQ[i].getColour()));
}
// af.changeColour() );
@@ -295,37 +335,33 @@ public class Jalview2XML_V1
}
else
{
- cs = ColourSchemeProperty.getColour(al, groups[i].getColour());
- }
-
- if (cs != null)
- {
- cs.setThreshold(groups[i].getPidThreshold(), true);
+ cs = ColourSchemeProperty.getColourScheme(al,
+ groups[i].getColour());
}
-
}
+ int pidThreshold = groups[i].getPidThreshold();
Vector seqs = new Vector();
int[] ids = groups[i].getSeq();
for (int s = 0; s < ids.length; s++)
{
- seqs.addElement((jalview.datamodel.SequenceI) seqids
- .elementAt(ids[s]));
+ seqs.addElement(seqids.elementAt(ids[s]));
}
jalview.datamodel.SequenceGroup sg = new jalview.datamodel.SequenceGroup(
seqs, groups[i].getName(), cs, groups[i].getDisplayBoxes(),
groups[i].getDisplayText(), groups[i].getColourText(),
groups[i].getStart(), groups[i].getEnd());
+ sg.getGroupColourScheme().setThreshold(pidThreshold, true);
- sg.setOutlineColour(new java.awt.Color(groups[i].getOutlineColour()));
+ sg.setOutlineColour(
+ new java.awt.Color(groups[i].getOutlineColour()));
if (groups[i].getConsThreshold() != 0)
{
- jalview.analysis.Conservation c = new jalview.analysis.Conservation(
- "All", ResidueProperties.propHash, 3,
- sg.getSequences(null), 0, sg.getWidth() - 1);
+ Conservation c = new Conservation("All", sg.getSequences(null), 0,
+ sg.getWidth() - 1);
c.calculate();
c.verdict(false, 25);
sg.cs.setConservation(c);
@@ -337,22 +373,20 @@ public class Jalview2XML_V1
af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(),
view.getHeight());
- af.viewport.setStartRes(view.getStartRes());
- af.viewport.setStartSeq(view.getStartSeq());
+ af.viewport.getRanges().setStartRes(view.getStartRes());
+ // startSeq set in af.alignPanel.updateLayout below
af.viewport.setShowAnnotation(view.getShowAnnotation());
af.viewport.setAbovePIDThreshold(view.getPidSelected());
af.viewport.setColourText(view.getShowColourText());
af.viewport.setConservationSelected(view.getConservationSelected());
af.viewport.setShowJVSuffix(view.getShowFullId());
- af.viewport.setFont(new java.awt.Font(view.getFontName(), view
- .getFontStyle(), view.getFontSize()));
- af.alignPanel.fontChanged();
+ af.viewport.setFont(new java.awt.Font(view.getFontName(),
+ view.getFontStyle(), view.getFontSize()), true);
af.viewport.setRenderGaps(view.getRenderGaps());
af.viewport.setWrapAlignment(view.getWrapAlignment());
- af.alignPanel.setWrapAlignment(view.getWrapAlignment());
- af.viewport.setShowAnnotation(view.getShowAnnotation());
- af.alignPanel.setAnnotationVisible(view.getShowAnnotation());
+
+ af.viewport.setShowAnnotation(view.isShowAnnotation());
af.viewport.setShowBoxes(view.getShowBoxes());
af.viewport.setShowText(view.getShowText());
@@ -366,48 +400,58 @@ public class Jalview2XML_V1
}
else
{
- cs = ColourSchemeProperty.getColour(al, view.getBgColour());
+ cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour());
}
- if (cs != null)
- {
- cs.setThreshold(view.getPidThreshold(), true);
- cs.setConsensus(af.viewport.getSequenceConsensusHash());
- }
+ // if (cs != null)
+ // {
+ // cs.setThreshold(view.getPidThreshold(), true);
+ // cs.setConsensus(af.viewport.getSequenceConsensusHash());
+ // }
}
- af.viewport.setGlobalColourScheme(cs);
+ af.viewport.getResidueShading().setThreshold(view.getPidThreshold(),
+ true);
+ af.viewport.getResidueShading()
+ .setConsensus(af.viewport.getSequenceConsensusHash());
af.viewport.setColourAppliesToAllGroups(false);
+ af.alignPanel.updateLayout();
af.changeColour(cs);
if (view.getConservationSelected() && cs != null)
{
- cs.setConservationInc(view.getConsThreshold());
+ af.viewport.getResidueShading()
+ .setConservationInc(view.getConsThreshold());
}
af.viewport.setColourAppliesToAllGroups(true);
- af.viewport.showSequenceFeatures = view.getShowSequenceFeatures();
+ af.viewport.setShowSequenceFeatures(view.getShowSequenceFeatures());
if (jms.getFeatureSettings() != null)
{
- af.viewport.featuresDisplayed = new Hashtable();
+ Hashtable featuresDisplayed = new Hashtable();
+ Hashtable featureColours = new Hashtable();
String[] renderOrder = new String[jms.getFeatureSettings()
.getSettingCount()];
- for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
+ for (int fs = 0; fs < jms.getFeatureSettings()
+ .getSettingCount(); fs++)
{
Setting setting = jms.getFeatureSettings().getSetting(fs);
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
- setting.getType(), new java.awt.Color(setting.getColour()));
+ featureColours.put(setting.getType(),
+ new java.awt.Color(setting.getColour()));
renderOrder[fs] = setting.getType();
if (setting.getDisplay())
{
- af.viewport.featuresDisplayed.put(setting.getType(), new Integer(
- setting.getColour()));
+ featuresDisplayed.put(setting.getType(),
+ new Integer(setting.getColour()));
}
}
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().renderOrder = renderOrder;
+ FeatureRendererSettings frs = new FeatureRendererSettings(renderOrder,
+ new Hashtable(), featureColours, 1.0f, null);
+ af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
+ .transferSettings(frs);
}
af.setMenusFromViewport(af.viewport);
@@ -426,7 +470,7 @@ public class Jalview2XML_V1
Tree tree = jms.getTree(t);
- TreePanel tp = af.ShowNewickTree(
+ TreePanel tp = af.showNewickTree(
new jalview.io.NewickFile(tree.getNewick()),
tree.getTitle(), tree.getWidth(), tree.getHeight(),
tree.getXpos(), tree.getYpos());
@@ -436,13 +480,13 @@ public class Jalview2XML_V1
if (tree.getFontName() != null)
{
- tp.setTreeFont(new java.awt.Font(tree.getFontName(), tree
- .getFontStyle(), tree.getFontSize()));
+ tp.setTreeFont(new java.awt.Font(tree.getFontName(),
+ tree.getFontStyle(), tree.getFontSize()));
}
else
{
- tp.setTreeFont(new java.awt.Font(view.getFontName(), view
- .getFontStyle(), tree.getFontSize()));
+ tp.setTreeFont(new java.awt.Font(view.getFontName(),
+ view.getFontStyle(), tree.getFontSize()));
}
tp.showPlaceholders(tree.getMarkUnlinked());