From: Jim Procter Date: Wed, 7 Feb 2018 13:04:07 +0000 (+0000) Subject: JAL-2902 - isBusy and hasMapping methods so client can wait until a newly opened... X-Git-Tag: Release_2_10_4~68^2~33 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e07d62e6efbd954164c27e15eee49f57aa2e1b4c;p=jalview.git JAL-2902 - isBusy and hasMapping methods so client can wait until a newly opened structure view has finished mapping sequences to structure data and sending initial colour commands to the structure view. [ needed for JAL-2780 JAL-2781 tests] --- diff --git a/src/jalview/api/structures/JalviewStructureDisplayI.java b/src/jalview/api/structures/JalviewStructureDisplayI.java index fd66388..b4612cf 100644 --- a/src/jalview/api/structures/JalviewStructureDisplayI.java +++ b/src/jalview/api/structures/JalviewStructureDisplayI.java @@ -62,4 +62,11 @@ public interface JalviewStructureDisplayI */ void setJalviewColourScheme(ColourSchemeI colourScheme); + /** + * + * @return true if all background sequence/structure binding threads have + * completed for this viewer instance + */ + boolean hasMapping(); + } diff --git a/src/jalview/gui/StructureViewer.java b/src/jalview/gui/StructureViewer.java index fb37b77..f37df71 100644 --- a/src/jalview/gui/StructureViewer.java +++ b/src/jalview/gui/StructureViewer.java @@ -104,7 +104,7 @@ public class StructureViewer new PDBEntry[seqsForPdbs.size()]); SequenceI[][] theSeqs = seqsForPdbs.values().toArray( new SequenceI[seqsForPdbs.size()][]); - JalviewStructureDisplayI sview = null; + if (viewerType.equals(ViewerType.JMOL)) { sview = new AppJmol(ap, pdbsForFile, theSeqs); @@ -203,7 +203,7 @@ public class StructureViewer private JalviewStructureDisplayI onlyOnePdb(PDBEntry[] pdbs, SequenceI[] seqsForPdbs, AlignmentPanel ap) { - List seqs = new ArrayList(); + List seqs = new ArrayList<>(); if (pdbs == null || pdbs.length == 0) { return null; @@ -227,11 +227,12 @@ public class StructureViewer ap); } + JalviewStructureDisplayI sview = null; + public JalviewStructureDisplayI viewStructures(PDBEntry pdb, SequenceI[] seqsForPdb, AlignmentPanel ap) { ViewerType viewerType = getViewerType(); - JalviewStructureDisplayI sview = null; if (viewerType.equals(ViewerType.JMOL)) { sview = new AppJmol(pdb, seqsForPdb, null, ap); @@ -270,7 +271,6 @@ public class StructureViewer final boolean usetoColourbyseq = viewerData.isColourWithAlignPanel(); final boolean viewerColouring = viewerData.isColourByViewer(); - JalviewStructureDisplayI sview = null; switch (type) { case JMOL: @@ -287,4 +287,16 @@ public class StructureViewer return sview; } + public boolean isBusy() + { + if (sview != null) + { + if (!sview.hasMapping()) + { + return true; + } + } + return false; + } + } diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 31c20ed..891e771 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -34,6 +34,7 @@ import jalview.io.JalviewFileView; import jalview.jbgui.GStructureViewer; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemes; +import jalview.structure.StructureMapping; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; @@ -113,6 +114,13 @@ public abstract class StructureViewerBase extends GStructureViewer protected JMenu viewSelectionMenu; /** + * set after sequence colouring has been applied for this structure viewer. + * used to determine if the final sequence/structure mapping has been + * determined + */ + protected boolean seqColoursApplied = false; + + /** * Default constructor */ public StructureViewerBase() @@ -909,6 +917,7 @@ public abstract class StructureViewerBase extends GStructureViewer { binding.colourBySequence(ap); } + seqColoursApplied = true; } } @@ -1028,4 +1037,37 @@ public abstract class StructureViewerBase extends GStructureViewer seqColour_actionPerformed(null); } } + + @Override + public boolean hasMapping() + { + if (worker != null && (addingStructures || _started)) + { + return false; + } + if (getBinding() == null) + { + return false; + } + String[] pdbids = getBinding().getStructureFiles(); + if (pdbids == null) + { + return false; + } + int p=0; + for (String pdbid:pdbids) { + StructureMapping sm[] = getBinding().getSsm().getMapping(pdbid); + if (sm!=null && sm.length>0 && sm[0]!=null) { + p++; + } + } + // only return true if there is a mapping for every structure file we have loaded + if (p == 0 || p != pdbids.length) + { + return false; + } + // and that coloring has been applied + return seqColoursApplied; + } + }