From 6453f3a8dfeacb9ff6c5585b2f0ff5e0bbe76e44 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 8 Sep 2010 14:12:51 +0000 Subject: [PATCH] todos & added simple method for other classes to monitor when fileUpdate events have occured --- src/jalview/ext/jmol/JalviewJmolBinding.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index f27b533..2c34762 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -373,6 +373,7 @@ public abstract class JalviewJmolBinding implements StructureListener, } } String[] selcom = new String[files.length]; + int nmatched=0; // generate select statements to select regions to superimpose structures { for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) @@ -386,7 +387,9 @@ public abstract class JalviewJmolBinding implements StructureListener, { if (matched[r]) { - + if (pdbfnum==0) { + nmatched++; + } if (lpos != commonrpositions[pdbfnum][r] - 1) { // discontinuity @@ -433,7 +436,8 @@ public abstract class JalviewJmolBinding implements StructureListener, } } } - + // TODO: consider bailing if nmatched less than 4 because superposition not well defined. + // TODO: refactor superposable position search (above) from jmol selection construction (below) for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { if (pdbfnum == refStructure) @@ -682,6 +686,10 @@ public abstract class JalviewJmolBinding implements StructureListener, // /StructureListener public synchronized String[] getPdbFile() { + if (viewer==null) + { + return new String[0]; + } if (modelFileNames == null) { @@ -1009,6 +1017,12 @@ public abstract class JalviewJmolBinding implements StructureListener, return false; } + // incremented every time a load notification is successfully handled - lightweight mechanism for other threads to detect when they can start referrring to new structures. + private long loadNotifiesHandled=0; + public long getLoadNotifiesHandled() + { + return loadNotifiesHandled; + } public void notifyFileLoaded(String fullPathName, String fileName2, String modelName, String errorMsg, int modelParts) { @@ -1182,6 +1196,7 @@ public abstract class JalviewJmolBinding implements StructureListener, fr.featuresAdded(); } refreshGUI(); + loadNotifiesHandled++; } } -- 1.7.10.2