X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fproject%2FJalview2XML.java;h=985aece519bf73c7d2b4be10186b7c080fea140d;hb=48a66195bf4aee8b2c479d3bbbf4c1fb8b824f5a;hp=8bbe20c0cb440b49d94d4c11387b002067bb40d9;hpb=7720585dc8cc56cdad2486b330ed37ddd0133531;p=jalview.git diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 8bbe20c..985aece 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -29,7 +29,6 @@ import java.awt.Font; import java.awt.Rectangle; import java.io.BufferedReader; import java.io.ByteArrayInputStream; -import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -55,6 +54,7 @@ import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -134,6 +134,7 @@ import jalview.schemes.UserColourScheme; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.Format; +import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.StringUtils; @@ -758,8 +759,8 @@ public class Jalview2XML // create backupfiles object and get new temp filename destination boolean doBackup = BackupFiles.getEnabled(); BackupFiles backupfiles = doBackup ? new BackupFiles(jarFile) : null; - FileOutputStream fos = new FileOutputStream(doBackup ? - backupfiles.getTempFilePath() : jarFile); + FileOutputStream fos = new FileOutputStream( + doBackup ? backupfiles.getTempFilePath() : jarFile); JarOutputStream jout = new JarOutputStream(fos); List frames = new ArrayList<>(); @@ -913,13 +914,12 @@ public class Jalview2XML } if (jal.getProperties() != null) { - Enumeration en = jal.getProperties().keys(); - while (en.hasMoreElements()) + for (Entry prop : jal.getProperties().entrySet()) { - String key = en.nextElement().toString(); + String key = prop.getKey().toString(); SequenceSetProperties ssp = new SequenceSetProperties(); ssp.setKey(key); - ssp.setValue(jal.getProperties().get(key).toString()); + ssp.setValue(prop.getValue().toString()); // vamsasSet.addSequenceSetProperties(ssp); vamsasSet.getSequenceSetProperties().add(ssp); } @@ -958,7 +958,7 @@ public class Jalview2XML else { vamsasSeq = createVamsasSequence(id, jds); -// vamsasSet.addSequence(vamsasSeq); + // vamsasSet.addSequence(vamsasSeq); vamsasSet.getSequence().add(vamsasSeq); vamsasSetIds.put(id, vamsasSeq); seqRefIds.put(id, jds); @@ -1089,13 +1089,14 @@ public class Jalview2XML if (frames[f] instanceof StructureViewerBase) { StructureViewerBase viewFrame = (StructureViewerBase) frames[f]; - matchedFile = saveStructureState(ap, jds, pdb, entry, viewIds, - matchedFile, viewFrame); + matchedFile = saveStructureViewer(ap, jds, pdb, entry, + viewIds, matchedFile, viewFrame); /* * Only store each structure viewer's state once in the project * jar. First time through only (storeDS==false) */ String viewId = viewFrame.getViewId(); + String viewerType = viewFrame.getViewerType().toString(); if (!storeDS && !viewIds.contains(viewId)) { viewIds.add(viewId); @@ -1103,13 +1104,12 @@ public class Jalview2XML if (viewerState != null) { copyFileToJar(jout, viewerState.getPath(), - getViewerJarEntryName(viewId)); + getViewerJarEntryName(viewId), viewerType); } else { - Cache.log.error("Failed to save viewer state for " - + - viewFrame.getViewerType().toString()); + Cache.log.error( + "Failed to save viewer state for " + viewerType); } } } @@ -1131,7 +1131,7 @@ public class Jalview2XML if (!pdbfiles.contains(pdbId)) { pdbfiles.add(pdbId); - copyFileToJar(jout, matchedFile, pdbId); + copyFileToJar(jout, matchedFile, pdbId, pdbId); } } @@ -1353,9 +1353,8 @@ public class Jalview2XML if (colourScheme instanceof jalview.schemes.UserColourScheme) { - jGroup.setColour( - setUserColourScheme(colourScheme, userColours, - object)); + jGroup.setColour(setUserColourScheme(colourScheme, + userColours, object)); } else { @@ -1401,7 +1400,7 @@ public class Jalview2XML } } - //jms.setJGroup(groups); + // jms.setJGroup(groups); Object group; for (JGroup grp : groups) { @@ -1538,11 +1537,13 @@ public class Jalview2XML * save any filter for the feature type */ FeatureMatcherSetI filter = fr.getFeatureFilter(featureType); - if (filter != null) { - Iterator filters = filter.getMatchers().iterator(); + if (filter != null) + { + Iterator filters = filter.getMatchers() + .iterator(); FeatureMatcherI firstFilter = filters.next(); - setting.setMatcherSet(Jalview2XML.marshalFilter( - firstFilter, filters, filter.isAnded())); + setting.setMatcherSet(Jalview2XML.marshalFilter(firstFilter, + filters, filter.isAnded())); } /* @@ -1591,8 +1592,7 @@ public class Jalview2XML setting.setDisplay( av.getFeaturesDisplayed().isVisible(featureType)); - float rorder = fr - .getOrder(featureType); + float rorder = fr.getOrder(featureType); if (rorder > -1) { setting.setOrder(rorder); @@ -1616,7 +1616,7 @@ public class Jalview2XML Group g = new Group(); g.setName(grp); g.setDisplay(((Boolean) fr.checkGroupVisibility(grp, false)) - .booleanValue()); + .booleanValue()); // fs.addGroup(g); fs.getGroup().add(g); groupsAdded.addElement(grp); @@ -1678,7 +1678,7 @@ public class Jalview2XML // using save and then load try { - fileName = fileName.replace('\\', '/'); + fileName = fileName.replace('\\', '/'); System.out.println("Writing jar entry " + fileName); JarEntry entry = new JarEntry(fileName); jout.putNextEntry(entry); @@ -1979,7 +1979,7 @@ public class Jalview2XML String varnaStateFile = varna.getStateInfo(model.rna); jarEntryName = RNA_PREFIX + viewId + "_" + nextCounter(); - copyFileToJar(jout, varnaStateFile, jarEntryName); + copyFileToJar(jout, varnaStateFile, jarEntryName, "Varna"); rnaSessions.put(model, jarEntryName); } SecondaryStructure ss = new SecondaryStructure(); @@ -2003,16 +2003,19 @@ public class Jalview2XML * @param jout * @param infilePath * @param jarEntryName + * @param msg + * additional identifying info to log to the console */ protected void copyFileToJar(JarOutputStream jout, String infilePath, - String jarEntryName) + String jarEntryName, String msg) { try (InputStream is = new FileInputStream(infilePath)) { File file = new File(infilePath); if (file.exists() && jout != null) { - System.out.println("Writing jar entry " + jarEntryName); + System.out.println( + "Writing jar entry " + jarEntryName + " (" + msg + ")"); jout.putNextEntry(new JarEntry(jarEntryName)); copyAll(is, jout); jout.closeEntry(); @@ -2028,29 +2031,6 @@ public class Jalview2XML } /** - * Write the data to a new entry of given name in the output jar file - * - * @param jout - * @param jarEntryName - * @param data - * @throws IOException - */ - protected void writeJarEntry(JarOutputStream jout, String jarEntryName, - byte[] data) throws IOException - { - if (jout != null) - { - jarEntryName = jarEntryName.replace('\\','/'); - System.out.println("Writing jar entry " + jarEntryName); - jout.putNextEntry(new JarEntry(jarEntryName)); - DataOutputStream dout = new DataOutputStream(jout); - dout.write(data, 0, data.length); - dout.flush(); - jout.closeEntry(); - } - } - - /** * Copies input to output, in 4K buffers; handles any data (text or binary) * * @param in @@ -2081,7 +2061,7 @@ public class Jalview2XML * @param viewFrame * @return */ - protected String saveStructureState(AlignmentPanel ap, SequenceI jds, + protected String saveStructureViewer(AlignmentPanel ap, SequenceI jds, Pdbids pdb, PDBEntry entry, List viewIds, String matchedFile, StructureViewerBase viewFrame) { @@ -2095,9 +2075,9 @@ public class Jalview2XML { final PDBEntry pdbentry = bindingModel.getPdbEntry(peid); final String pdbId = pdbentry.getId(); - if (!pdbId.equals(entry.getId()) - && !(entry.getId().length() > 4 && entry.getId().toLowerCase() - .startsWith(pdbId.toLowerCase()))) + if (!pdbId.equals(entry.getId()) && !(entry.getId().length() > 4 + && entry.getId().toLowerCase(Locale.ROOT) + .startsWith(pdbId.toLowerCase(Locale.ROOT)))) { /* * not interested in a binding to a different PDB entry here @@ -2393,7 +2373,8 @@ public class Jalview2XML { if (calcIdParam.getVersion().equals("1.0")) { - final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]); + final String[] calcIds = calcIdParam.getServiceURL() + .toArray(new String[0]); Jws2Instance service = Jws2Discoverer.getDiscoverer() .getPreferredServiceFor(calcIds); if (service != null) @@ -2548,14 +2529,15 @@ public class Jalview2XML dbref.setSource(ref.getSource()); dbref.setVersion(ref.getVersion()); dbref.setAccessionId(ref.getAccessionId()); + dbref.setCanonical(ref.isCanonical()); if (ref instanceof GeneLocus) { dbref.setLocus(true); } if (ref.hasMap()) { - Mapping mp = createVamsasMapping(ref.getMap(), parentseq, - jds, recurse); + Mapping mp = createVamsasMapping(ref.getMap(), parentseq, jds, + recurse); dbref.setMapping(mp); } vamsasSeq.getDBRef().add(dbref); @@ -2663,7 +2645,7 @@ public class Jalview2XML for (int i = 0; i < colours.length; i++) { Colour col = new Colour(); - col.setName(ResidueProperties.aa[i].toLowerCase()); + col.setName(ResidueProperties.aa[i].toLowerCase(Locale.ROOT)); col.setRGB(jalview.util.Format.getHexString(colours[i])); // jbucs.addColour(col); jbucs.getColour().add(col); @@ -2679,12 +2661,12 @@ public class Jalview2XML return id; } - jalview.schemes.UserColourScheme getUserColourScheme( - JalviewModel jm, String id) + jalview.schemes.UserColourScheme getUserColourScheme(JalviewModel jm, + String id) { List uc = jm.getUserColours(); UserColours colours = null; -/* + /* for (int i = 0; i < uc.length; i++) { if (uc[i].getId().equals(id)) @@ -2693,7 +2675,7 @@ public class Jalview2XML break; } } -*/ + */ for (UserColours c : uc) { if (c.getId().equals(id)) @@ -2721,10 +2703,9 @@ public class Jalview2XML newColours = new java.awt.Color[23]; for (int i = 0; i < 23; i++) { - newColours[i] = new java.awt.Color(Integer.parseInt( - colours.getUserColourScheme().getColour().get(i + 24) - .getRGB(), - 16)); + newColours[i] = new java.awt.Color( + Integer.parseInt(colours.getUserColourScheme().getColour() + .get(i + 24).getRGB(), 16)); } ucs.setLowerCaseColours(newColours); } @@ -2793,52 +2774,69 @@ public class Jalview2XML return af; } - @SuppressWarnings("unused") - private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { + @SuppressWarnings("unused") + private jarInputStreamProvider createjarInputStreamProvider( + final Object ofile) throws MalformedURLException + { - // BH 2018 allow for bytes already attached to File object - try { - String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); + // BH 2018 allow for bytes already attached to File object + try + { + String file = (ofile instanceof File + ? ((File) ofile).getCanonicalPath() + : ofile.toString()); byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile) : null; - URL url = null; - errorMessage = null; - uniqueSetSuffix = null; - seqRefIds = null; - viewportsAdded.clear(); - frefedSequence = null; - - if (file.startsWith("http://")) { - url = new URL(file); - } - final URL _url = url; - return new jarInputStreamProvider() { - - @Override - public JarInputStream getJarInputStream() throws IOException { - if (bytes != null) { -// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); - return new JarInputStream(new ByteArrayInputStream(bytes)); - } - if (_url != null) { -// System.out.println("Jalview2XML: opening url jarInputStream for " + _url); - return new JarInputStream(_url.openStream()); - } else { -// System.out.println("Jalview2XML: opening file jarInputStream for " + file); - return new JarInputStream(new FileInputStream(file)); - } - } - - @Override - public String getFilename() { - return file; - } - }; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } + URL url = null; + errorMessage = null; + uniqueSetSuffix = null; + seqRefIds = null; + viewportsAdded.clear(); + frefedSequence = null; + + if (HttpUtils.startsWithHttpOrHttps(file)) + { + url = new URL(file); + } + final URL _url = url; + return new jarInputStreamProvider() + { + + @Override + public JarInputStream getJarInputStream() throws IOException + { + if (bytes != null) + { + // System.out.println("Jalview2XML: opening byte jarInputStream for + // bytes.length=" + bytes.length); + return new JarInputStream(new ByteArrayInputStream(bytes)); + } + if (_url != null) + { + // System.out.println("Jalview2XML: opening url jarInputStream for " + // + _url); + return new JarInputStream(_url.openStream()); + } + else + { + // System.out.println("Jalview2XML: opening file jarInputStream for + // " + file); + return new JarInputStream(new FileInputStream(file)); + } + } + + @Override + public String getFilename() + { + return file; + } + }; + } catch (IOException e) + { + e.printStackTrace(); + return null; + } + } /** * Recover jalview session from a jalview project archive. Caller may @@ -2885,8 +2883,8 @@ public class Jalview2XML XMLStreamReader streamReader = XMLInputFactory.newInstance() .createXMLStreamReader(jin); javax.xml.bind.Unmarshaller um = jc.createUnmarshaller(); - JAXBElement jbe = um - .unmarshal(streamReader, JalviewModel.class); + JAXBElement jbe = um.unmarshal(streamReader, + JalviewModel.class); JalviewModel object = jbe.getValue(); if (true) // !skipViewport(object)) @@ -2922,6 +2920,7 @@ public class Jalview2XML entryCount++; } } while (jarentry != null); + jin.close(); resolveFrefedSequences(); } catch (IOException ex) { @@ -3274,7 +3273,8 @@ public class Jalview2XML AlignFrame loadFromObject(JalviewModel jalviewModel, String file, boolean loadTreesAndStructures, jarInputStreamProvider jprovider) { - SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0); + SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet() + .get(0); List vamsasSeqs = vamsasSet.getSequence(); // JalviewModelSequence jms = object.getJalviewModelSequence(); @@ -3333,11 +3333,10 @@ public class Jalview2XML if (tmpSeq.getStart() != jseq.getStart() || tmpSeq.getEnd() != jseq.getEnd()) { - System.err.println( - String.format("Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d", - tmpSeq.getName(), tmpSeq.getStart(), - tmpSeq.getEnd(), jseq.getStart(), - jseq.getEnd())); + System.err.println(String.format( + "Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d", + tmpSeq.getName(), tmpSeq.getStart(), tmpSeq.getEnd(), + jseq.getStart(), jseq.getEnd())); } } else @@ -3620,8 +3619,8 @@ public class Jalview2XML else { // defer to later - frefedSequence.add( - newAlcodMapRef(map.getDnasq(), cf, mapping)); + frefedSequence + .add(newAlcodMapRef(map.getDnasq(), cf, mapping)); } } } @@ -3829,8 +3828,7 @@ public class Jalview2XML jaa.setCalcId(annotation.getCalcId()); if (annotation.getProperty().size() > 0) { - for (Annotation.Property prop : annotation - .getProperty()) + for (Annotation.Property prop : annotation.getProperty()) { jaa.setProperty(prop.getName(), prop.getValue()); } @@ -3911,9 +3909,9 @@ public class Jalview2XML sg.setShowNonconserved(safeBoolean(jGroup.isShowUnconserved())); sg.thresholdTextColour = safeInt(jGroup.getTextColThreshold()); // attributes with a default in the schema are never null - sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram()); - sg.setshowSequenceLogo(jGroup.isShowSequenceLogo()); - sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo()); + sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram()); + sg.setshowSequenceLogo(jGroup.isShowSequenceLogo()); + sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo()); sg.setIgnoreGapsConsensus(jGroup.isIgnoreGapsinConsensus()); if (jGroup.getConsThreshold() != null && jGroup.getConsThreshold().intValue() != 0) @@ -3957,8 +3955,9 @@ public class Jalview2XML if (addAnnotSchemeGroup) { // reconstruct the annotation colourscheme - sg.setColourScheme(constructAnnotationColour( - jGroup.getAnnotationColours(), null, al, jalviewModel, false)); + sg.setColourScheme( + constructAnnotationColour(jGroup.getAnnotationColours(), + null, al, jalviewModel, false)); } } } @@ -4164,8 +4163,8 @@ public class Jalview2XML * @param av * @param ap */ - protected void loadTrees(JalviewModel jm, Viewport view, - AlignFrame af, AlignViewport av, AlignmentPanel ap) + protected void loadTrees(JalviewModel jm, Viewport view, AlignFrame af, + AlignViewport av, AlignmentPanel ap) { // TODO result of automated refactoring - are all these parameters needed? try @@ -4273,8 +4272,8 @@ public class Jalview2XML for (int s = 0; s < structureStateCount; s++) { // check to see if we haven't already created this structure view - final StructureState structureState = pdbid - .getStructureState().get(s); + final StructureState structureState = pdbid.getStructureState() + .get(s); String sviewid = (structureState.getViewId() == null) ? null : structureState.getViewId() + uniqueSetSuffix; jalview.datamodel.PDBEntry jpdb = new jalview.datamodel.PDBEntry(); @@ -4342,8 +4341,8 @@ public class Jalview2XML colourByViewer &= structureState.isColourByJmol(); jmoldat.setColourByViewer(colourByViewer); - if (jmoldat.getStateData().length() < structureState - .getValue()/*Content()*/.length()) + if (jmoldat.getStateData().length() < structureState.getValue() + /*Content()*/.length()) { jmoldat.setStateData(structureState.getValue());// Content()); } @@ -4421,8 +4420,7 @@ public class Jalview2XML } catch (IllegalArgumentException | NullPointerException e) { // TODO JAL-3619 show error dialog / offer an alternative viewer - Cache.log.error( - "Invalid structure viewer type: " + type); + Cache.log.error("Invalid structure viewer type: " + type); } } @@ -4622,23 +4620,23 @@ public class Jalview2XML } AlignFrame loadViewport(String file, List JSEQ, - List hiddenSeqs, AlignmentI al, - JalviewModel jm, Viewport view, String uniqueSeqSetId, - String viewId, List autoAlan) + List hiddenSeqs, AlignmentI al, JalviewModel jm, + Viewport view, String uniqueSeqSetId, String viewId, + List autoAlan) { AlignFrame af = null; af = new AlignFrame(al, safeInt(view.getWidth()), - safeInt(view.getHeight()), uniqueSeqSetId, viewId) -// { -// -// @Override -// protected void processKeyEvent(java.awt.event.KeyEvent e) { -// System.out.println("Jalview2XML AF " + e); -// super.processKeyEvent(e); -// -// } -// -// } + safeInt(view.getHeight()), uniqueSeqSetId, viewId) + // { + // + // @Override + // protected void processKeyEvent(java.awt.event.KeyEvent e) { + // System.out.println("Jalview2XML AF " + e); + // super.processKeyEvent(e); + // + // } + // + // } ; af.setFileName(file, FileFormat.Jalview); @@ -4716,9 +4714,8 @@ public class Jalview2XML viewport.setColourText(safeBoolean(view.isShowColourText())); - viewport - .setConservationSelected( - safeBoolean(view.isConservationSelected())); + viewport.setConservationSelected( + safeBoolean(view.isConservationSelected())); viewport.setIncrement(safeInt(view.getConsThreshold())); viewport.setShowJVSuffix(safeBoolean(view.isShowFullId())); viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds())); @@ -4794,9 +4791,8 @@ public class Jalview2XML af.changeColour(cs); viewport.setColourAppliesToAllGroups(true); - viewport - .setShowSequenceFeatures( - safeBoolean(view.isShowSequenceFeatures())); + viewport.setShowSequenceFeatures( + safeBoolean(view.isShowSequenceFeatures())); viewport.setCentreColumnLabels(view.isCentreColumnLabels()); viewport.setIgnoreGapsConsensus(view.isIgnoreGapsinConsensus(), null); @@ -4820,13 +4816,13 @@ public class Jalview2XML .getFeatureRenderer(); FeaturesDisplayed fdi; viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed()); - String[] renderOrder = new String[jm.getFeatureSettings() - .getSetting().size()]; + String[] renderOrder = new String[jm.getFeatureSettings().getSetting() + .size()]; Map featureColours = new Hashtable<>(); Map featureOrder = new Hashtable<>(); - for (int fs = 0; fs < jm.getFeatureSettings() - .getSetting().size(); fs++) + for (int fs = 0; fs < jm.getFeatureSettings().getSetting() + .size(); fs++) { Setting setting = jm.getFeatureSettings().getSetting().get(fs); String featureType = setting.getType(); @@ -4838,8 +4834,8 @@ public class Jalview2XML .getMatcherSet(); if (filters != null) { - FeatureMatcherSetI filter = Jalview2XML - .parseFilter(featureType, filters); + FeatureMatcherSetI filter = Jalview2XML.parseFilter(featureType, + filters); if (!filter.isEmpty()) { fr.setFeatureFilter(featureType, filter); @@ -4871,8 +4867,7 @@ public class Jalview2XML float max = setting.getMax() == null ? 1f : setting.getMax().floatValue(); FeatureColourI gc = new FeatureColour(maxColour, minColour, - maxColour, - noValueColour, min, max); + maxColour, noValueColour, min, max); if (setting.getAttributeName().size() > 0) { gc.setAttributeName(setting.getAttributeName().toArray( @@ -4906,8 +4901,7 @@ public class Jalview2XML } else { - featureColours.put(featureType, - new FeatureColour(maxColour)); + featureColours.put(featureType, new FeatureColour(maxColour)); } renderOrder[fs] = featureType; if (setting.getOrder() != null) @@ -5380,6 +5374,7 @@ public class Jalview2XML } } } + /** * * @param vamsasSeq @@ -5629,6 +5624,7 @@ public class Jalview2XML { entry.setMap(addMapping(dr.getMapping())); } + entry.setCanonical(dr.isCanonical()); datasetSequence.addDBRef(entry); } } @@ -6128,8 +6124,8 @@ public class Jalview2XML * @param af * @param jprovider */ - protected void createStructureViewer( - ViewerType viewerType, final Entry viewerData, + protected void createStructureViewer(ViewerType viewerType, + final Entry viewerData, AlignFrame af, jarInputStreamProvider jprovider) { final StructureViewerModel viewerModel = viewerData.getValue(); @@ -6143,8 +6139,7 @@ public class Jalview2XML { String viewerJarEntryName = getViewerJarEntryName( viewerModel.getViewId()); - sessionFilePath = copyJarEntry(jprovider, - viewerJarEntryName, + sessionFilePath = copyJarEntry(jprovider, viewerJarEntryName, "viewerSession", ".tmp"); } final String sessionPath = sessionFilePath; @@ -6164,8 +6159,7 @@ public class Jalview2XML addNewStructureViewer(sview); } catch (OutOfMemoryError ex) { - new OOMWarning("Restoring structure view for " - + viewerType, + new OOMWarning("Restoring structure view for " + viewerType, (OutOfMemoryError) ex.getCause()); if (sview != null && sview.isVisible()) { @@ -6198,8 +6192,8 @@ public class Jalview2XML String state = svattrib.getStateData(); // Jalview < 2.9 if (state == null || state.isEmpty()) // Jalview >= 2.9 { - state = readJarEntry(jprovider, - getViewerJarEntryName(svattrib.getViewId())); + String jarEntryName = getViewerJarEntryName(svattrib.getViewId()); + state = readJarEntry(jprovider, jarEntryName); } // TODO or simpler? for each key in oldFiles, // replace key.getPath() in state with oldFiles.get(key).getFilePath() @@ -6225,8 +6219,7 @@ public class Jalview2XML String reformatedOldFilename = oldfilenam.replaceAll("/", "\\\\"); filedat = oldFiles.get(new File(reformatedOldFilename)); } - rewritten - .append(Platform.escapeBackslashes(filedat.getFilePath())); + rewritten.append(Platform.escapeBackslashes(filedat.getFilePath())); rewritten.append("\""); cp = ecp + 1; // advance beyond last \" and set cursor so we can // look for next file statement. @@ -6246,8 +6239,7 @@ public class Jalview2XML { // add pdb files that should be present in the viewer StructureData filedat = oldFiles.get(id); - rewritten.append(filedat.getFilePath()).append(" \"") - .append(filedat.getFilePath()).append("\""); + rewritten.append(" \"").append(filedat.getFilePath()).append("\""); } rewritten.append(";"); } @@ -6299,8 +6291,8 @@ public class Jalview2XML * @param fcol * @return */ - public static Colour marshalColour( - String featureType, FeatureColourI fcol) + public static Colour marshalColour(String featureType, + FeatureColourI fcol) { Colour col = new Colour(); if (fcol.isSimpleColour()) @@ -6361,7 +6353,7 @@ public class Jalview2XML boolean and) { jalview.xml.binding.jalview.FeatureMatcherSet result = new jalview.xml.binding.jalview.FeatureMatcherSet(); - + if (filters.hasNext()) { /* @@ -6411,7 +6403,7 @@ public class Jalview2XML } result.setMatchCondition(matcherModel); } - + return result; } @@ -6422,8 +6414,7 @@ public class Jalview2XML * @param matcherSetModel * @return */ - public static FeatureMatcherSetI parseFilter( - String featureType, + public static FeatureMatcherSetI parseFilter(String featureType, jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel) { FeatureMatcherSetI result = new FeatureMatcherSet(); @@ -6438,7 +6429,7 @@ public class Jalview2XML featureType, e.getMessage())); // return as much as was parsed up to the error } - + return result; } @@ -6453,8 +6444,7 @@ public class Jalview2XML * @throws IllegalStateException * if AND and OR conditions are mixed */ - protected static void parseFilterConditions( - FeatureMatcherSetI matcherSet, + protected static void parseFilterConditions(FeatureMatcherSetI matcherSet, jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel, boolean and) { @@ -6476,7 +6466,7 @@ public class Jalview2XML else if (filterBy == FilterBy.BY_SCORE) { matchCondition = FeatureMatcher.byScore(cond, pattern); - + } else if (filterBy == FilterBy.BY_ATTRIBUTE) { @@ -6486,7 +6476,7 @@ public class Jalview2XML matchCondition = FeatureMatcher.byAttribute(cond, pattern, attNames); } - + /* * note this throws IllegalStateException if AND-ing to a * previously OR-ed compound condition, or vice versa @@ -6529,13 +6519,13 @@ public class Jalview2XML public static FeatureColourI parseColour(Colour colourModel) { FeatureColourI colour = null; - + if (colourModel.getMax() != null) { Color mincol = null; Color maxcol = null; Color noValueColour = null; - + try { mincol = new Color(Integer.parseInt(colourModel.getMinRGB(), 16)); @@ -6544,7 +6534,7 @@ public class Jalview2XML { Cache.log.warn("Couldn't parse out graduated feature color.", e); } - + NoValueColour noCol = colourModel.getNoValueColour(); if (noCol == NoValueColour.MIN) { @@ -6554,7 +6544,7 @@ public class Jalview2XML { noValueColour = maxcol; } - + colour = new FeatureColour(maxcol, mincol, maxcol, noValueColour, safeFloat(colourModel.getMin()), safeFloat(colourModel.getMax())); @@ -6593,7 +6583,7 @@ public class Jalview2XML Color color = new Color(Integer.parseInt(colourModel.getRGB(), 16)); colour = new FeatureColour(color); } - + return colour; } }