From: jprocter Date: Wed, 18 Aug 2010 10:16:36 +0000 (+0000) Subject: thread safe construction of Jmol instance and hack to translate invalid jmol state... X-Git-Tag: Release_2_6~123 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=05ee59c456b1b0032dd14fabe3fbaeb8569c93cb;p=jalview.git thread safe construction of Jmol instance and hack to translate invalid jmol state statements. --- diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 1a6024e..4b6879c 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -19,6 +19,7 @@ package jalview.gui; import java.awt.Rectangle; import java.io.*; +import java.lang.reflect.InvocationTargetException; import java.net.*; import java.util.*; import java.util.jar.*; @@ -578,13 +579,14 @@ public class Jalview2XML { if (frames[f] instanceof AppJmol) { + // TODO: revise schema to allow many:one PDB id binding to viewer jmol = (AppJmol) frames[f]; - if (!jmol.pdbentry.getId().equals(entry.getId()) + if (!jmol.jmb.pdbentry[0].getId().equals(entry.getId()) && !(entry.getId().length() > 4 && entry.getId() .toLowerCase().startsWith( - jmol.pdbentry.getId().toLowerCase()))) + jmol.jmb.pdbentry[0].getId().toLowerCase()))) continue; - matchedFile = jmol.pdbentry.getFile(); // record the file so we + matchedFile = jmol.jmb.pdbentry[0].getFile(); // record the file so we // can get at it if the ID // match is ambiguous (e.g. // 1QIP==1qipA) @@ -595,14 +597,14 @@ public class Jalview2XML state.setWidth(jmol.getWidth()); state.setHeight(jmol.getHeight()); state.setViewId(jmol.getViewId()); - String statestring = jmol.viewer.getStateInfo(); + String statestring = jmol.jmb.viewer.getStateInfo(); if (state != null) { state.setContent(statestring.replaceAll("\n", "")); } - for (int s = 0; s < jmol.sequence.length; s++) + for (int s = 0; s < jmol.jmb.sequence.length; s++) { - if (jal.findIndex(jmol.sequence[s]) > -1) + if (jal.findIndex(jmol.jmb.sequence[s]) > -1) { pdb.addStructureState(state); } @@ -2534,9 +2536,42 @@ public class Jalview2XML if (newFileLoc != null) { - new AppJmol(pdbFile, ids[p].getId(), seq, af.alignPanel, - newFileLoc.toString(), new java.awt.Rectangle(x, - y, width, height), sviewid); + int histbug = newFileLoc.indexOf("history = "); + 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.trim().equals("true")) { + val = "1"; + } else { + val = "0"; + } + newFileLoc.replace(histbug, diff, val); + } + } + final String pdbf=pdbFile, id=ids[p].getId(), fileloc=newFileLoc.toString(),vid=sviewid; + final SequenceI[] sq=seq; + final AlignFrame alf = af; + final java.awt.Rectangle rect = new java.awt.Rectangle(x, + y, width, height); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + new AppJmol(pdbf, id, sq, alf.alignPanel, + fileloc, rect, vid); + } + }); + } + catch (InvocationTargetException ex) + { + System.err.println("Unexpected error when opening Jmol view."); + ex.printStackTrace(); + } catch (InterruptedException e) + { + // e.printStackTrace(); + } } } @@ -2553,7 +2588,7 @@ public class Jalview2XML .setMapping(seq, null, pdbFile, jalview.io.AppletFormatAdapter.FILE); - ((AppJmol) comp).addSequence(seq); + ((AppJmol) comp).jmb.addSequence(seq); } } }