X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJalview2XML.java;h=3b90bf6a9068cba2f963f14092d022d2229ad3cd;hb=7a1a7eea9501cd9e3841e996f4926cf1686be76a;hp=be562920d0aae16b6307c9b5329d6bfe51f93579;hpb=fddf3084802b37e5cee17829e32692a4aac3e60d;p=jalview.git diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index be56292..3b90bf6 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -676,8 +676,7 @@ public class Jalview2XML { final SequenceI jds = jal.getSequenceAt(i); final SequenceI jdatasq = jds.getDatasetSequence() == null ? jds - : jds - .getDatasetSequence(); + : jds.getDatasetSequence(); String id = seqHash(jds); if (seqRefIds.get(id) != null) @@ -736,8 +735,7 @@ public class Jalview2XML if (jds.getSequenceFeatures() != null) { - jalview.datamodel.SequenceFeature[] sf = jds - .getSequenceFeatures(); + jalview.datamodel.SequenceFeature[] sf = jds.getSequenceFeatures(); int index = 0; while (index < sf.length) { @@ -900,36 +898,36 @@ public class Jalview2XML } } -// { -// AlcodonFrame alc = new AlcodonFrame(); -// vamsasSet.addAlcodonFrame(alc); -// for (int p = 0; p < acf.aaWidth; p++) -// { -// Alcodon cmap = new Alcodon(); -// if (acf.codons[p] != null) -// { -// // Null codons indicate a gapped column in the translated peptide -// // alignment. -// cmap.setPos1(acf.codons[p][0]); -// cmap.setPos2(acf.codons[p][1]); -// cmap.setPos3(acf.codons[p][2]); -// } -// alc.addAlcodon(cmap); -// } -// if (acf.getProtMappings() != null -// && acf.getProtMappings().length > 0) -// { -// SequenceI[] dnas = acf.getdnaSeqs(); -// jalview.datamodel.Mapping[] pmaps = acf.getProtMappings(); -// for (int m = 0; m < pmaps.length; m++) -// { -// AlcodMap alcmap = new AlcodMap(); -// alcmap.setDnasq(seqHash(dnas[m])); -// alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null, -// false)); -// alc.addAlcodMap(alcmap); -// } -// } + // { + // AlcodonFrame alc = new AlcodonFrame(); + // vamsasSet.addAlcodonFrame(alc); + // for (int p = 0; p < acf.aaWidth; p++) + // { + // Alcodon cmap = new Alcodon(); + // if (acf.codons[p] != null) + // { + // // Null codons indicate a gapped column in the translated peptide + // // alignment. + // cmap.setPos1(acf.codons[p][0]); + // cmap.setPos2(acf.codons[p][1]); + // cmap.setPos3(acf.codons[p][2]); + // } + // alc.addAlcodon(cmap); + // } + // if (acf.getProtMappings() != null + // && acf.getProtMappings().length > 0) + // { + // SequenceI[] dnas = acf.getdnaSeqs(); + // jalview.datamodel.Mapping[] pmaps = acf.getProtMappings(); + // for (int m = 0; m < pmaps.length; m++) + // { + // AlcodMap alcmap = new AlcodMap(); + // alcmap.setDnasq(seqHash(dnas[m])); + // alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null, + // false)); + // alc.addAlcodMap(alcmap); + // } + // } } } @@ -1032,13 +1030,11 @@ public class Jalview2XML if (sg.cs instanceof jalview.schemes.UserColourScheme) { - jGroup.setColour(setUserColourScheme(sg.cs, userColours, - jms)); + jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms)); } else { - jGroup - .setColour(ColourSchemeProperty.getColourName(sg.cs)); + jGroup.setColour(ColourSchemeProperty.getColourName(sg.cs)); } } else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient) @@ -1050,8 +1046,7 @@ public class Jalview2XML } else if (sg.cs instanceof jalview.schemes.UserColourScheme) { - jGroup - .setColour(setUserColourScheme(sg.cs, userColours, jms)); + jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms)); } else { @@ -1211,8 +1206,8 @@ public class Jalview2XML else { setting.setColour(ap.getSeqPanel().seqCanvas - .getFeatureRenderer() - .getColour(renderOrder[ro]).getRGB()); + .getFeatureRenderer().getColour(renderOrder[ro]) + .getRGB()); } setting.setDisplay(av.getFeaturesDisplayed().isVisible( @@ -1372,6 +1367,10 @@ public class Jalview2XML final SequenceI jds, List viewIds, AlignmentPanel ap, boolean storeDataset) { + if (Desktop.desktop == null) + { + return; + } JInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int f = frames.length - 1; f > -1; f--) { @@ -1420,8 +1419,7 @@ public class Jalview2XML { String varnaStateFile = varna.getStateInfo(model.rna); - jarEntryName = RNA_PREFIX + viewId + "_" - + nextCounter(); + jarEntryName = RNA_PREFIX + viewId + "_" + nextCounter(); copyFileToJar(jout, varnaStateFile, jarEntryName); rnaSessions.put(model, jarEntryName); } @@ -1604,8 +1602,8 @@ public class Jalview2XML private void storeAlignmentAnnotation(AlignmentAnnotation[] aa, IdentityHashMap groupRefs, - AlignmentViewport av, - Set calcIdSet, boolean storeDS, SequenceSet vamsasSet) + AlignmentViewport av, Set calcIdSet, boolean storeDS, + SequenceSet vamsasSet) { for (int i = 0; i < aa.length; i++) @@ -1635,9 +1633,11 @@ public class Jalview2XML if (groupIdr == null) { // make a locally unique String - groupRefs.put(annotation.groupRef, + groupRefs.put( + annotation.groupRef, groupIdr = ("" + System.currentTimeMillis() - + annotation.groupRef.getName() + groupRefs.size())); + + annotation.groupRef.getName() + groupRefs + .size())); } an.setGroupRef(groupIdr.toString()); } @@ -2415,7 +2415,8 @@ public class Jalview2XML .entrySet()) { AlignFrame af = candidate.getValue(); - if (!addedToSplitFrames.contains(af)) { + if (!addedToSplitFrames.contains(af)) + { Viewport view = candidate.getKey(); Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(), view.getHeight()); @@ -2888,8 +2889,7 @@ public class Jalview2XML // set visiblity for other annotation in this view String annotationId = annotation.getId(); - if (annotationId != null - && annotationIds.containsKey(annotationId)) + if (annotationId != null && annotationIds.containsKey(annotationId)) { AlignmentAnnotation jda = annotationIds.get(annotationId); // in principle Visible should always be true for annotation displayed @@ -3123,8 +3123,7 @@ public class Jalview2XML SequenceGroup sg = new SequenceGroup(seqs, jGroup.getName(), cs, jGroup.getDisplayBoxes(), jGroup.getDisplayText(), - jGroup.getColourText(), jGroup.getStart(), - jGroup.getEnd()); + jGroup.getColourText(), jGroup.getStart(), jGroup.getEnd()); sg.setOutlineColour(new java.awt.Color(jGroup.getOutlineColour())); @@ -3163,8 +3162,8 @@ public class Jalview2XML if (jGroup.getId() != null && groupAnnotRefs.size() > 0) { // re-instate unique group/annotation row reference - List jaal = groupAnnotRefs - .get(jGroup.getId()); + List jaal = groupAnnotRefs.get(jGroup + .getId()); if (jaal != null) { for (AlignmentAnnotation jaa : jaal) @@ -3192,8 +3191,8 @@ public class Jalview2XML if (addAnnotSchemeGroup) { // reconstruct the annotation colourscheme - sg.cs = constructAnnotationColour( - jGroup.getAnnotationColours(), null, al, jms, false); + sg.cs = constructAnnotationColour(jGroup.getAnnotationColours(), + null, al, jms, false); } } } @@ -3325,8 +3324,8 @@ public class Jalview2XML for (int i = 0; i < jseq.getRnaViewerCount(); i++) { RnaViewer viewer = jseq.getRnaViewer(i); - AppVarna appVarna = findOrCreateVarnaViewer(viewer, uniqueSetSuffix, - ap); + AppVarna appVarna = findOrCreateVarnaViewer(viewer, + uniqueSetSuffix, ap); for (int j = 0; j < viewer.getSecondaryStructureCount(); j++) { @@ -3388,8 +3387,8 @@ public class Jalview2XML * viewer not found - make it */ RnaViewerModel model = new RnaViewerModel(postLoadId, - viewer.getTitle(), viewer.getXpos(), - viewer.getYpos(), viewer.getWidth(), viewer.getHeight(), + viewer.getTitle(), viewer.getXpos(), viewer.getYpos(), + viewer.getWidth(), viewer.getHeight(), viewer.getDividerLocation()); AppVarna varna = new AppVarna(model, ap); @@ -3674,12 +3673,12 @@ public class Jalview2XML * @param af * @param jprovider */ - protected void createChimeraViewer(Entry viewerData, - AlignFrame af, + protected void createChimeraViewer( + Entry viewerData, AlignFrame af, jarInputStreamProvider jprovider) { StructureViewerModel data = viewerData.getValue(); - String chimeraSessionFile = data.getStateData(); + String chimeraSessionFile = data.getStateData(); /* * Copy Chimera session from jar entry "viewer_"+viewId to a temporary file @@ -3716,8 +3715,8 @@ public class Jalview2XML String newViewId = viewerData.getKey(); ChimeraViewFrame cvf = new ChimeraViewFrame(chimeraSessionFile, - af.alignPanel, pdbArray, - seqsArray, colourByChimera, colourBySequence, newViewId); + af.alignPanel, pdbArray, seqsArray, colourByChimera, + colourBySequence, newViewId); cvf.setSize(data.getWidth(), data.getHeight()); cvf.setLocation(data.getX(), data.getY()); } @@ -3806,16 +3805,23 @@ public class Jalview2XML newFileLoc.append(";"); } - if (newFileLoc.length() > 0) + if (newFileLoc.length() == 0) + { + return; + } + int histbug = newFileLoc.indexOf("history = "); + if (histbug > -1) { - int histbug = newFileLoc.indexOf("history = "); + /* + * change "history = [true|false];" to "history = [1|0];" + */ histbug += 10; int diff = histbug == -1 ? -1 : newFileLoc.indexOf(";", histbug); String val = (diff == -1) ? null : newFileLoc .substring(histbug, diff); if (val != null && val.length() >= 4) { - if (val.contains("e")) + if (val.contains("e")) // eh? what can it be? { if (val.trim().equals("true")) { @@ -3828,54 +3834,55 @@ public class Jalview2XML newFileLoc.replace(histbug, diff, val); } } + } - final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames - .size()]); - final String[] id = pdbids.toArray(new String[pdbids.size()]); - final SequenceI[][] sq = seqmaps - .toArray(new SequenceI[seqmaps.size()][]); - final String fileloc = newFileLoc.toString(); - final String sviewid = viewerData.getKey(); - final AlignFrame alf = af; - final Rectangle rect = new Rectangle(svattrib.getX(), - svattrib.getY(), svattrib.getWidth(), svattrib.getHeight()); - try + final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames + .size()]); + final String[] id = pdbids.toArray(new String[pdbids.size()]); + final SequenceI[][] sq = seqmaps + .toArray(new SequenceI[seqmaps.size()][]); + final String fileloc = newFileLoc.toString(); + final String sviewid = viewerData.getKey(); + final AlignFrame alf = af; + final Rectangle rect = new Rectangle(svattrib.getX(), svattrib.getY(), + svattrib.getWidth(), svattrib.getHeight()); + try + { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() + @Override + public void run() { - @Override - public void run() + JalviewStructureDisplayI sview = null; + try { - JalviewStructureDisplayI sview = null; - try - { - sview = new StructureViewer(alf.alignPanel - .getStructureSelectionManager()).createView( - StructureViewer.ViewerType.JMOL, pdbf, id, sq, - alf.alignPanel, svattrib, fileloc, rect, sviewid); - addNewStructureViewer(sview); - } catch (OutOfMemoryError ex) + sview = new StructureViewer(alf.alignPanel + .getStructureSelectionManager()).createView( + StructureViewer.ViewerType.JMOL, pdbf, id, sq, + alf.alignPanel, svattrib, fileloc, rect, sviewid); + addNewStructureViewer(sview); + } catch (OutOfMemoryError ex) + { + new OOMWarning("restoring structure view for PDB id " + id, + (OutOfMemoryError) ex.getCause()); + if (sview != null && sview.isVisible()) { - new OOMWarning("restoring structure view for PDB id " + id, - (OutOfMemoryError) ex.getCause()); - if (sview != null && sview.isVisible()) - { - sview.closeViewer(false); - sview.setVisible(false); - sview.dispose(); - } + sview.closeViewer(false); + sview.setVisible(false); + sview.dispose(); } } - }); - } catch (InvocationTargetException ex) - { - warn("Unexpected error when opening Jmol view.", ex); + } + }); + } catch (InvocationTargetException ex) + { + warn("Unexpected error when opening Jmol view.", ex); - } catch (InterruptedException e) - { - // e.printStackTrace(); - } + } catch (InterruptedException e) + { + // e.printStackTrace(); } + } /** @@ -4412,7 +4419,7 @@ public class Jalview2XML } } af.setMenusFromViewport(af.viewport); - + // TODO: we don't need to do this if the viewport is aready visible. /* * Add the AlignFrame to the desktop (it may be 'gathered' later), unless it @@ -5317,7 +5324,7 @@ public class Jalview2XML } } } - + return result; }