From 2147e6f6d1d8e3e53db73f3806b48d117dc79083 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 5 Apr 2018 14:26:26 +0100 Subject: [PATCH] JAL-2944 allow StructureViewer proxy to be created for an existing view in order to add structures to it --- src/jalview/gui/StructureViewer.java | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/jalview/gui/StructureViewer.java b/src/jalview/gui/StructureViewer.java index f37df71..8b501ad 100644 --- a/src/jalview/gui/StructureViewer.java +++ b/src/jalview/gui/StructureViewer.java @@ -64,6 +64,17 @@ public class StructureViewer ssm = structureSelectionManager; } + /** + * Factory to create a proxy for modifying existing structure viewer + * + */ + public static StructureViewer reconfigure( + JalviewStructureDisplayI display) + { + StructureViewer sv = new StructureViewer(display.getBinding().getSsm()); + sv.sview = display; + return sv; + } public ViewerType getViewerType() { String viewType = Cache.getDefault(Preferences.STRUCTURE_DISPLAY, @@ -104,6 +115,30 @@ public class StructureViewer new PDBEntry[seqsForPdbs.size()]); SequenceI[][] theSeqs = seqsForPdbs.values().toArray( new SequenceI[seqsForPdbs.size()][]); + if (sview != null) + { + new Thread(new Runnable() + { + @Override + public void run() + { + + for (int pdbep = 0; pdbep < pdbsForFile.length; pdbep++) + { + PDBEntry pdb = pdbsForFile[pdbep]; + if (!sview.addAlreadyLoadedFile(theSeqs[pdbep], null, ap, + pdb.getId())) + { + sview.addToExistingViewer(pdb, theSeqs[pdbep], null, ap, + pdb.getId()); + } + } + + sview.updateTitleAndMenus(); + } + }).start(); + return sview; + } if (viewerType.equals(ViewerType.JMOL)) { @@ -232,6 +267,15 @@ public class StructureViewer public JalviewStructureDisplayI viewStructures(PDBEntry pdb, SequenceI[] seqsForPdb, AlignmentPanel ap) { + if (sview != null) + { + if (!sview.addAlreadyLoadedFile(seqsForPdb, null, ap, pdb.getId())) + { + sview.addToExistingViewer(pdb, seqsForPdb, null, ap, pdb.getId()); + } + sview.updateTitleAndMenus(); + return sview; + } ViewerType viewerType = getViewerType(); if (viewerType.equals(ViewerType.JMOL)) { -- 1.7.10.2