/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
*/
package jalview.gui;
import java.io.*;
import jalview.jbgui.GStructureViewer;
+import jalview.bin.Cache;
import jalview.datamodel.*;
import jalview.gui.*;
import jalview.structure.*;
import org.jmol.api.*;
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.popup.*;
+import org.jmol.viewer.JmolConstants;
public class AppJmol extends GStructureViewer implements StructureListener,
JmolStatusListener, Runnable
pdbentry = new PDBEntry();
pdbentry.setFile(file);
pdbentry.setId(id);
- this.chains = chains;
this.sequence = seq;
this.ap = ap;
this.setBounds(bounds);
this.setTitle(title.toString());
jalview.gui.Desktop.addInternalFrame(this, title.toString(),
getBounds().width, getBounds().height);
+ // * OK, but safer to assign htmlName, URL bases, comandOptions, and
+ // statusListener now.
viewer = org.jmol.api.JmolViewer.allocateViewer(renderPanel,
- new SmarterJmolAdapter());
-
- viewer.setAppletContext("", null, null, "");
+ new SmarterJmolAdapter(), "", null, null, "", this);
- viewer.setJmolStatusListener(this);
-
- jmolpopup = JmolPopup.newJmolPopup(viewer);
+ jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true);
viewer.evalStringQuiet(command);
}
{
try
{
- // TODO: replace with reference fetching/transfer code (validate PDBentry as a DBRef?)
+ // TODO: replace with reference fetching/transfer code (validate PDBentry
+ // as a DBRef?)
jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
AlignmentI pdbseq;
- if ((pdbseq=pdbclient.getSequenceRecords(pdbentry.getId())) != null)
+ if ((pdbseq = pdbclient.getSequenceRecords(pdbentry.getId())) != null)
{
// just transfer the file name from the first seuqence's first PDBEntry
- pdbentry.setFile(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId().elementAt(0)).getFile());
+ pdbentry.setFile(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
+ .elementAt(0)).getFile());
initJmol("load " + pdbentry.getFile());
}
else
eval.append(";wireframe 100;" + eval.toString() + " and not hetero;"); // ".*;");
resetLastRes.append(";wireframe 0;" + resetLastRes.toString()
- //+ ".*;spacefill 0;");
+ // + ".*;spacefill 0;");
+ " and not hetero;spacefill 0;");
eval.append("spacefill 200;select none");
-// System.out.println("jmol:\n"+eval+"\n");
+ // System.out.println("jmol:\n"+eval+"\n");
viewer.evalStringQuiet(eval.toString());
}
System.out.println("JMOL CREATE IMAGE");
}
- public void setCallbackFunction(String callbackType,
- String callbackFunction)
- {
- }
-
public void notifyFileLoaded(String fullPathName, String fileName,
- String modelName, Object clientFile, String errorMsg)
+ String modelName, String errorMsg, int modelParts)
{
if (errorMsg != null)
{
if (fileName != null)
{
-
+ // TODO: do some checking using the modelPts number of parts against our own estimate of the number of chains
// FILE LOADED OK
ssm = StructureSelectionManager.getStructureSelectionManager();
MCview.PDBfile pdbFile = ssm.setMapping(sequence, chains, pdbentry
return;
}
- public void notifyFrameChanged(int frameNo)
- {
- boolean isAnimationRunning = (frameNo <= -2);
- }
-
- public void notifyScriptStart(String statusMessage, String additionalInfo)
- {
- }
-
public void sendConsoleEcho(String strEcho)
{
if (scriptWindow != null)
public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
{
- notifyAtomPicked(iatom, strMeasure);
+ notifyAtomPicked(iatom, strMeasure, null);
}
- public void notifyNewDefaultModeMeasurement(int count, String strInfo)
- {
- }
-
- public void notifyAtomPicked(int atomIndex, String strInfo)
+ public void notifyAtomPicked(int atomIndex, String strInfo, String strData)
{
+ if (strData!=null)
+ {
+ Cache.log.info("Non null pick data string: "+strData+" (other info: '"+strInfo+"' pos "+atomIndex+")");
+ }
Matcher matcher = pattern.matcher(strInfo);
matcher.find();
if (chainId != null)
picked += (":" + chainId.substring(1, chainId.length()));
- picked += ".CA";
+ picked = "(("+picked+".CA" + ")|("+picked+".P"+"))";
if (!atomsPicked.contains(picked))
{
}
}
- public void notifyAtomHovered(int atomIndex, String strInfo)
+ public void notifyAtomHovered(int atomIndex, String strInfo, String data)
{
+ if (data!=null)
+ {
+ Cache.log.info("Non null hover data string: "+data+" (other info: '"+strInfo+"' pos "+atomIndex+")");
+ }
mouseOverStructure(atomIndex, strInfo);
}
- public void sendSyncScript(String script, String appletName)
- {
- }
-
+ @Override
public void showUrl(String url)
{
+ try {
+ jalview.util.BrowserLauncher.openURL(url);
+ } catch (IOException e)
+ {
+ Cache.log.error("Failed to launch Jmol-associated url "+url,e);
+ // TODO: 2.6 : warn user if browser was not configured.
+ }
}
public void showConsole(boolean showConsole)
validate();
}
- public float functionXY(String functionName, int x, int y)
+ public float[][] functionXY(String functionName, int x, int y)
{
- return 0;
+ return null;
}
// /End JmolStatusListener
return viewId;
}
+ @Override
+ public String createImage(String fileName, String type,
+ Object textOrBytes, int quality)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public float[][][] functionXYZ(String functionName, int nx, int ny, int nz)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Hashtable getRegistryInfo()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void notifyCallback(int type, Object[] data)
+ {
+ try {
+ switch (type)
+ {
+ case JmolConstants.CALLBACK_LOADSTRUCT:
+ notifyFileLoaded((String) data[1], (String) data[2],
+ (String) data[3], (String) data[4], ((Integer) data[5]).intValue());
+
+ break;
+ case JmolConstants.CALLBACK_PICK:
+ notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]);
+ // also highlight in alignment
+ case JmolConstants.CALLBACK_HOVER:
+ notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]);
+ break;
+ case JmolConstants.CALLBACK_SCRIPT:
+ notifyScriptTermination((String)data[2], ((Integer)data[3]).intValue());
+ break;
+ case JmolConstants.CALLBACK_ECHO:
+ sendConsoleEcho((String)data[1]);
+ break;
+ case JmolConstants.CALLBACK_MESSAGE:
+ sendConsoleMessage((data==null) ? ((String) null) : (String)data[1]);
+ break;
+ case JmolConstants.CALLBACK_MEASURE:
+ case JmolConstants.CALLBACK_CLICK:
+ default:
+ System.err.println("Unhandled callback "+type+" "+data);
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ Cache.log.warn("Squashed Jmol callback handler error: ",e);
+ }
+ }
+
+ @Override
+ public boolean notifyEnabled(int callbackPick)
+ {
+ switch (callbackPick)
+ {
+ case JmolConstants.CALLBACK_ECHO:
+ case JmolConstants.CALLBACK_LOADSTRUCT:
+ case JmolConstants.CALLBACK_MEASURE:
+ case JmolConstants.CALLBACK_MESSAGE:
+ case JmolConstants.CALLBACK_PICK:
+ case JmolConstants.CALLBACK_SCRIPT:
+ case JmolConstants.CALLBACK_HOVER:
+ case JmolConstants.CALLBACK_ERROR:
+ return true;
+ case JmolConstants.CALLBACK_CLICK:
+ case JmolConstants.CALLBACK_ANIMFRAME:
+ case JmolConstants.CALLBACK_MINIMIZATION:
+ case JmolConstants.CALLBACK_RESIZE:
+ case JmolConstants.CALLBACK_SYNC:
+ }
+ return false;
+ }
+
+ @Override
+ public void setCallbackFunction(String callbackType,
+ String callbackFunction)
+ {
+ Cache.log.debug("Ignoring set-callback request to associate "+callbackType+" with function "+callbackFunction);
+
+ }
+
}