From 2e5a121ab28df0fea66fb62f7432b6b957bd1333 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 2 May 2014 10:35:12 +0100 Subject: [PATCH] formatting --- src/jalview/gui/Jalview2XML.java | 130 +++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 57 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 3bca941..da81945 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -279,7 +279,7 @@ public class Jalview2XML return; } - Hashtable dsses = new Hashtable(); + Hashtable dsses = new Hashtable(); try { @@ -348,7 +348,8 @@ public class Jalview2XML SaveState(apanel, fileName, jout); - String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset()); + String dssid = getDatasetIdRef(af.getViewport().getAlignment() + .getDataset()); if (!dsses.containsKey(dssid)) { dsses.put(dssid, af); @@ -358,8 +359,9 @@ public class Jalview2XML } } - writeDatasetFor(dsses, ""+jout.hashCode()+" "+uniqueSetSuffix, jout); - + writeDatasetFor(dsses, "" + jout.hashCode() + " " + uniqueSetSuffix, + jout); + try { jout.flush(); @@ -389,7 +391,7 @@ public class Jalview2XML int ap, apSize = af.alignPanels.size(); FileOutputStream fos = new FileOutputStream(jarFile); JarOutputStream jout = new JarOutputStream(fos); - Hashtable dsses = new Hashtable(); + Hashtable dsses = new Hashtable(); for (ap = 0; ap < apSize; ap++) { AlignmentPanel apanel = (AlignmentPanel) af.alignPanels @@ -400,7 +402,8 @@ public class Jalview2XML jfileName = jfileName + ".xml"; } SaveState(apanel, jfileName, jout); - String dssid = getDatasetIdRef(af.getViewport().getAlignment().getDataset()); + String dssid = getDatasetIdRef(af.getViewport().getAlignment() + .getDataset()); if (!dsses.containsKey(dssid)) { dsses.put(dssid, af); @@ -428,10 +431,10 @@ public class Jalview2XML String fileName, JarOutputStream jout) { - for (String dssids:dsses.keySet()) + for (String dssids : dsses.keySet()) { AlignFrame _af = dsses.get(dssids); - String jfileName = fileName + " Dataset for "+ _af.getTitle(); + String jfileName = fileName + " Dataset for " + _af.getTitle(); if (!jfileName.endsWith(".xml")) { jfileName = jfileName + ".xml"; @@ -456,25 +459,27 @@ public class Jalview2XML public JalviewModel SaveState(AlignmentPanel ap, String fileName, JarOutputStream jout) { - return SaveState(ap, fileName, false,jout); + return SaveState(ap, fileName, false, jout); } + /** - * create a JalviewModel from an algnment view and marshall it to a - * JarOutputStream - * - * @param ap - * panel to create jalview model for - * @param fileName - * name of alignment panel written to output stream - * @param storeDS - * when true, only write the dataset for the alignment, not the data associated with the view. - * @param jout - * jar output stream - * @param out - * jar entry name - */ - public JalviewModel SaveState(AlignmentPanel ap, String fileName, boolean storeDS, - JarOutputStream jout) + * create a JalviewModel from an algnment view and marshall it to a + * JarOutputStream + * + * @param ap + * panel to create jalview model for + * @param fileName + * name of alignment panel written to output stream + * @param storeDS + * when true, only write the dataset for the alignment, not the data + * associated with the view. + * @param jout + * jar output stream + * @param out + * jar entry name + */ + public JalviewModel SaveState(AlignmentPanel ap, String fileName, + boolean storeDS, JarOutputStream jout) { initSeqRefs(); Vector jmolViewIds = new Vector(); // @@ -486,7 +491,8 @@ public class Jalview2XML object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel()); object.setCreationDate(new java.util.Date(System.currentTimeMillis())); - object.setVersion(jalview.bin.Cache.getDefault("VERSION","Development Build")); + object.setVersion(jalview.bin.Cache.getDefault("VERSION", + "Development Build")); jalview.datamodel.AlignmentI jal = av.getAlignment(); @@ -529,11 +535,12 @@ public class Jalview2XML // SAVE SEQUENCES String id = ""; - jalview.datamodel.SequenceI jds,jdatasq; + jalview.datamodel.SequenceI jds, jdatasq; for (int i = 0; i < jal.getHeight(); i++) { jds = jal.getSequenceAt(i); - jdatasq=jds.getDatasetSequence() == null ? jds : jds.getDatasetSequence(); + jdatasq = jds.getDatasetSequence() == null ? jds : jds + .getDatasetSequence(); id = seqHash(jds); if (seqRefIds.get(id) != null) @@ -877,17 +884,19 @@ public class Jalview2XML IdentityHashMap groupRefs = new IdentityHashMap(); if (storeDS) { - for (SequenceI sq:jal.getSequences()) + for (SequenceI sq : jal.getSequences()) + { + // Store annotation on dataset sequences only + jalview.datamodel.AlignmentAnnotation[] aa = sq.getAnnotation(); + if (aa != null && aa.length > 0) { - // Store annotation on dataset sequences only - jalview.datamodel.AlignmentAnnotation[] aa = sq.getAnnotation(); - if (aa!=null && aa.length>0) - { - storeAlignmentAnnotation(aa, groupRefs, av, calcIdSet, storeDS, - vamsasSet); - } + storeAlignmentAnnotation(aa, groupRefs, av, calcIdSet, storeDS, + vamsasSet); } - } else { + } + } + else + { if (jal.getAlignmentAnnotation() != null) { // Store the annotation shown on the alignment. @@ -1382,11 +1391,12 @@ public class Jalview2XML } if (!storeDS || (storeDS && !aa[i].autoCalculated)) { - // skip autocalculated annotation - these are only provided for alignments + // skip autocalculated annotation - these are only provided for + // alignments vamsasSet.addAnnotation(an); } } - + } private CalcIdParam createCalcIdParam(String calcId, AlignViewport av) @@ -1772,7 +1782,7 @@ public class Jalview2XML try { // create list to store references for any new Jmol viewers created - newStructureViewers=new Vector(); + newStructureViewers = new Vector(); // UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING // Workaround is to make sure caller implements the JarInputStreamProvider // interface @@ -1780,13 +1790,13 @@ public class Jalview2XML jarInputStreamProvider jprovider = createjarInputStreamProvider(file); af = LoadJalviewAlign(jprovider); - + } catch (MalformedURLException e) { errorMessage = "Invalid URL format for '" + file + "'"; reportErrors(); - } - finally { + } finally + { try { SwingUtilities.invokeAndWait(new Runnable() @@ -1872,7 +1882,7 @@ public class Jalview2XML frefedSequence = new Vector(); } - jalview.gui.AlignFrame af= null,_af = null; + jalview.gui.AlignFrame af = null, _af = null; Hashtable gatherToThisFrame = new Hashtable(); final String file = jprovider.getFilename(); try @@ -2130,8 +2140,9 @@ public class Jalview2XML JalviewModelSequence jms = object.getJalviewModelSequence(); - Viewport view = (jms.getViewportCount()>0) ? jms.getViewport(0) : null; - + Viewport view = (jms.getViewportCount() > 0) ? jms.getViewport(0) + : null; + // //////////////////////////////// // LOAD SEQUENCES @@ -2537,7 +2548,6 @@ public class Jalview2XML } } } - // /////////////////////// // LOAD GROUPS // Create alignment markup and styles for this view @@ -2656,7 +2666,7 @@ public class Jalview2XML } } - if (view==null) + if (view == null) { // only dataset in this model, so just return. return null; @@ -3171,22 +3181,23 @@ public class Jalview2XML Vector newStructureViewers=null; protected void addNewStructureViewer(AppJmol sview) { - if (newStructureViewers!=null) + if (newStructureViewers != null) { sview.jmb.setFinishedLoadingFromArchive(false); newStructureViewers.add(sview); } } + protected void setLoadingFinishedForNewStructureViewers() { - if (newStructureViewers!=null) + if (newStructureViewers != null) { - for (AppJmol sview:newStructureViewers) + for (AppJmol sview : newStructureViewers) { sview.jmb.setFinishedLoadingFromArchive(true); } newStructureViewers.clear(); - newStructureViewers=null; + newStructureViewers = null; } } @@ -3847,14 +3858,18 @@ public class Jalview2XML { // make this dataset sequence sq's dataset sequence sq.setDatasetSequence(dsq); // and update the current dataset alignment - if (ds==null) { - if (dseqs!=null) { + if (ds == null) + { + if (dseqs != null) + { if (!dseqs.contains(dsq)) { dseqs.add(dsq); } - } else { - if (ds.findIndex(dsq)<0) + } + else + { + if (ds.findIndex(dsq) < 0) { ds.addSequence(dsq); } @@ -3890,7 +3905,8 @@ public class Jalview2XML } // TODO: merges will never happen if we 'know' we have the real dataset // sequence - this should be detected when id==dssid - System.err.println("DEBUG Notice: Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // (" + System.err + .println("DEBUG Notice: Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // (" // + (pre ? "prepended" : "") + " " // + (post ? "appended" : "")); } -- 1.7.10.2