2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.appletgui;
22 import java.awt.event.*;
24 import jalview.api.SequenceStructureBinding;
25 import jalview.datamodel.*;
26 import jalview.structure.*;
29 import org.jmol.api.*;
30 import org.jmol.adapter.smarter.SmarterJmolAdapter;
32 import org.jmol.popup.*;
33 import org.jmol.viewer.JmolConstants;
35 import jalview.schemes.*;
37 public class AppletJmol extends EmbmenuFrame implements StructureListener,
38 JmolStatusListener, KeyListener, ActionListener, ItemListener, SequenceStructureBinding
41 Menu fileMenu = new Menu("File");
43 Menu viewMenu = new Menu("View");
45 Menu coloursMenu = new Menu("Colours");
47 Menu chainMenu = new Menu("Show Chain");
49 Menu helpMenu = new Menu("Help");
51 MenuItem mappingMenuItem = new MenuItem("View Mapping");
53 CheckboxMenuItem seqColour = new CheckboxMenuItem("By Sequence", true);
55 MenuItem chain = new MenuItem("By Chain");
57 MenuItem charge = new MenuItem("Charge & Cysteine");
59 MenuItem zappo = new MenuItem("Zappo");
61 MenuItem taylor = new MenuItem("Taylor");
63 MenuItem hydro = new MenuItem("Hydrophobicity");
65 MenuItem helix = new MenuItem("Helix Propensity");
67 MenuItem strand = new MenuItem("Strand Propensity");
69 MenuItem turn = new MenuItem("Turn Propensity");
71 MenuItem buried = new MenuItem("Buried Index");
73 MenuItem user = new MenuItem("User Defined Colours");
75 MenuItem jmolHelp = new MenuItem("Jmol Help");
91 StructureSelectionManager ssm;
93 RenderPanel renderPanel;
97 String fileLoadingError;
103 boolean colourBySequence = true;
105 Vector atomsPicked = new Vector();
108 * datasource protocol for access to PDBEntry
110 String protocol = null;
112 public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
113 AlignmentPanel ap, String protocol)
117 this.chains = chains;
118 this.pdbentry = pdbentry;
119 this.protocol = protocol;
120 if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
122 if (protocol.equals(AppletFormatAdapter.PASTE))
124 pdbentry.setId("PASTED PDB"
125 + (chains == null ? "_" : chains.toString()));
129 pdbentry.setId(pdbentry.getFile());
133 if (jalview.bin.JalviewLite.debug)
136 .println("AppletJmol: PDB ID is '" + pdbentry.getId() + "'");
139 String alreadyMapped = StructureSelectionManager
140 .getStructureSelectionManager().alreadyMappedToFile(
142 MCview.PDBfile reader = null;
143 if (alreadyMapped != null)
145 reader = StructureSelectionManager.getStructureSelectionManager()
146 .setMapping(seq, chains, pdbentry.getFile(), protocol);
147 // PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW?
148 // FOR NOW, LETS JUST OPEN A NEW WINDOW
150 MenuBar menuBar = new MenuBar();
151 menuBar.add(fileMenu);
152 fileMenu.add(mappingMenuItem);
153 menuBar.add(viewMenu);
154 mappingMenuItem.addActionListener(this);
155 viewMenu.add(chainMenu);
156 menuBar.add(coloursMenu);
157 menuBar.add(helpMenu);
159 charge.addActionListener(this);
160 hydro.addActionListener(this);
161 chain.addActionListener(this);
162 seqColour.addItemListener(this);
163 zappo.addActionListener(this);
164 taylor.addActionListener(this);
165 helix.addActionListener(this);
166 strand.addActionListener(this);
167 turn.addActionListener(this);
168 buried.addActionListener(this);
169 user.addActionListener(this);
171 jmolHelp.addActionListener(this);
173 coloursMenu.add(seqColour);
174 coloursMenu.add(chain);
175 coloursMenu.add(charge);
176 coloursMenu.add(zappo);
177 coloursMenu.add(taylor);
178 coloursMenu.add(hydro);
179 coloursMenu.add(helix);
180 coloursMenu.add(strand);
181 coloursMenu.add(turn);
182 coloursMenu.add(buried);
183 coloursMenu.add(user);
185 helpMenu.add(jmolHelp);
189 renderPanel = new RenderPanel();
190 embedMenuIfNeeded(renderPanel);
191 this.add(renderPanel, BorderLayout.CENTER);
192 viewer = JmolViewer.allocateViewer(renderPanel,
193 new SmarterJmolAdapter(), "jalviewJmol", ap.av.applet
194 .getDocumentBase(), ap.av.applet.getCodeBase(), "",
197 jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true);
199 this.addWindowListener(new WindowAdapter()
201 public void windowClosing(WindowEvent evt)
207 if (pdbentry.getFile() != null)
209 // import structure data from pdbentry.getFile based on given protocol
210 if (protocol.equals(AppletFormatAdapter.PASTE))
212 loadInline(pdbentry.getFile());
214 else if (protocol.equals(AppletFormatAdapter.FILE)
215 || protocol.equals(AppletFormatAdapter.URL))
217 viewer.openFile(pdbentry.getFile());
221 // probably CLASSLOADER based datasource..
222 // Try and get a reader on the datasource, and pass that to Jmol
225 java.io.Reader freader = null;
228 if (jalview.bin.JalviewLite.debug)
231 .println("AppletJmol:Trying to reuse existing PDBfile IO parser.");
233 // re-use the one we opened earlier
234 freader = reader.getReader();
238 if (jalview.bin.JalviewLite.debug)
241 .println("AppletJmol:Creating new PDBfile IO parser.");
243 FileParse fp = new FileParse(pdbentry.getFile(), protocol);
245 // reader = new MCview.PDBfile(fp);
246 // could set ID, etc.
247 // if (!reader.isValid())
249 // throw new Exception("Invalid datasource.
250 // "+reader.getWarningMessage());
253 freader = fp.getReader();
258 "Invalid datasource. Could not obtain Reader.");
260 viewer.openReader(pdbentry.getFile(), pdbentry.getId(), freader);
261 } catch (Exception e)
264 System.err.println("Couldn't access pdbentry id="
265 + pdbentry.getId() + " and file=" + pdbentry.getFile()
266 + " using protocol=" + protocol);
272 jalview.bin.JalviewLite.addFrame(this, "Jmol", 400, 400);
276 * create a new binding between structures in an existing jmol viewer instance and
277 * an alignpanel with sequences that have existing PDBFile entries. Note, this does not open a new Jmol window,
278 * or modify the display of the structures in the original jmol window.
281 * @param seqs - sequences to search for associations
283 public AppletJmol(JmolViewer viewer2, AlignmentPanel alignPanel,
287 // TODO Auto-generated constructor stub
290 public void loadInline(String string)
293 viewer.openStringInline(string);
296 void setChainMenuItems(Vector chains)
298 chainMenu.removeAll();
300 MenuItem menuItem = new MenuItem("All");
301 menuItem.addActionListener(this);
303 chainMenu.add(menuItem);
305 CheckboxMenuItem menuItemCB;
306 for (int c = 0; c < chains.size(); c++)
308 menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(),
310 menuItemCB.addItemListener(this);
311 chainMenu.add(menuItemCB);
315 boolean allChainsSelected = false;
320 StringBuffer cmd = new StringBuffer();
323 for (int i = 0; i < chainMenu.getItemCount(); i++)
325 if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
327 CheckboxMenuItem item = (CheckboxMenuItem) chainMenu.getItem(i);
330 lbl = item.getLabel();
335 mlength = lbl.indexOf(":", p);
336 } while (p < mlength && mlength < (lbl.length() - 2));
337 mnum = 1+getModelNum(lbl.substring(0, mlength));
339 {cmd.append(":" + lbl.substring(mlength + 1) + " /"
346 if (cmd.length() > 0)
347 cmd.setLength(cmd.length() - 4);
350 .evalString("select *;restrict " + cmd + ";cartoon;center "
355 private int getModelNum(String modelFileName)
357 String[] mfn = getPdbFile();
362 for (int i = 0; i < mfn.length; i++)
364 if (mfn[i].equalsIgnoreCase(modelFileName))
372 viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);
373 // remove listeners for all structures in viewer
374 StructureSelectionManager.getStructureSelectionManager()
375 .removeStructureViewerListener(this, this.getPdbFile());
376 // and shut down jmol
377 viewer.evalStringQuiet("zap");
378 viewer.setJmolStatusListener(null);
382 this.setVisible(false);
385 public void actionPerformed(ActionEvent evt)
388 if (evt.getSource() == mappingMenuItem)
390 jalview.appletgui.CutAndPasteTransfer cap = new jalview.appletgui.CutAndPasteTransfer(
392 Frame frame = new Frame();
395 jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping",
397 cap.setText(StructureSelectionManager.getStructureSelectionManager()
398 .printMapping(pdbentry.getFile()));
400 else if (evt.getSource() == charge)
402 colourBySequence = false;
403 seqColour.setState(false);
405 .evalStringQuiet("select *;color white;select ASP,GLU;color red;"
406 + "select LYS,ARG;color blue;select CYS;color yellow");
409 else if (evt.getSource() == chain)
411 colourBySequence = false;
412 seqColour.setState(false);
413 viewer.evalStringQuiet("select *;color chain");
415 else if (evt.getSource() == zappo)
417 setJalviewColourScheme(new ZappoColourScheme());
419 else if (evt.getSource() == taylor)
421 setJalviewColourScheme(new TaylorColourScheme());
423 else if (evt.getSource() == hydro)
425 setJalviewColourScheme(new HydrophobicColourScheme());
427 else if (evt.getSource() == helix)
429 setJalviewColourScheme(new HelixColourScheme());
431 else if (evt.getSource() == strand)
433 setJalviewColourScheme(new StrandColourScheme());
435 else if (evt.getSource() == turn)
437 setJalviewColourScheme(new TurnColourScheme());
439 else if (evt.getSource() == buried)
441 setJalviewColourScheme(new BuriedColourScheme());
443 else if (evt.getSource() == user)
445 new UserDefinedColours(this);
447 else if (evt.getSource() == jmolHelp)
451 ap.av.applet.getAppletContext().showDocument(
453 "http://jmol.sourceforge.net/docs/JmolUserGuide/"),
455 } catch (java.net.MalformedURLException ex)
461 allChainsSelected = true;
462 for (int i = 0; i < chainMenu.getItemCount(); i++)
464 if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
465 ((CheckboxMenuItem) chainMenu.getItem(i)).setState(true);
468 allChainsSelected = false;
472 private void jmolHistory(boolean enable)
474 viewer.setBooleanProperty("history", enable);
476 public void setJalviewColourScheme(ColourSchemeI cs)
478 colourBySequence = false;
479 seqColour.setState(false);
489 Enumeration en = ResidueProperties.aa3Hash.keys();
490 StringBuffer command = new StringBuffer("select *;color white;");
491 while (en.hasMoreElements())
493 res = en.nextElement().toString();
494 index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();
498 col = cs.findColour(ResidueProperties.aa[index].charAt(0));
500 command.append("select " + res + ";color[" + col.getRed() + ","
501 + col.getGreen() + "," + col.getBlue() + "];");
504 viewer.evalStringQuiet(command.toString());
508 public void itemStateChanged(ItemEvent evt)
510 if (evt.getSource() == seqColour)
513 colourBySequence = seqColour.getState();
514 colourBySequence(ap);
516 else if (!allChainsSelected)
520 public void keyPressed(KeyEvent evt)
522 if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible())
524 viewer.evalString(inputLine.getText());
525 history.append("\n$ " + inputLine.getText());
526 inputLine.setText("");
531 public void keyTyped(KeyEvent evt)
535 public void keyReleased(KeyEvent evt)
539 String[] modelFileNames = null;
541 // ////////////////////////////////
542 // /StructureListener
543 public String[] getPdbFile()
545 if (modelFileNames == null)
547 String mset[] = new String[viewer.getModelCount()];
548 for (int i = 0; i < mset.length; i++)
550 mset[i] = viewer.getModelFileName(i);
552 modelFileNames = mset;
554 return modelFileNames;
560 public void mouseOverStructure(int atomIndex, String strInfo)
563 int mdlSep = strInfo.indexOf("/");
564 int chainSeparator = strInfo.indexOf(":"), chainSeparator1 = -1;
566 if (chainSeparator == -1)
568 chainSeparator = strInfo.indexOf(".");
569 if (mdlSep > -1 && mdlSep < chainSeparator)
571 chainSeparator1 = chainSeparator;
572 chainSeparator = mdlSep;
575 pdbResNum = Integer.parseInt(strInfo.substring(
576 strInfo.indexOf("]") + 1, chainSeparator));
580 if (strInfo.indexOf(":") > -1)
581 chainId = strInfo.substring(strInfo.indexOf(":") + 1, strInfo
588 String pdbfilename = pdbentry.getFile();
591 if (chainSeparator1 == -1)
593 chainSeparator1 = strInfo.indexOf(".", mdlSep);
595 String mdlId = (chainSeparator1 > -1) ? strInfo.substring(mdlSep + 1,
596 chainSeparator1) : strInfo.substring(mdlSep + 1);
599 // recover PDB filename for the model hovered over.
601 .getModelFileName(new Integer(mdlId).intValue() - 1);
602 } catch (Exception e)
607 if (lastMessage == null || !lastMessage.equals(strInfo))
608 ssm.mouseOverStructure(pdbResNum, chainId, pdbfilename);
610 lastMessage = strInfo;
613 StringBuffer resetLastRes = new StringBuffer();
615 StringBuffer eval = new StringBuffer();
618 public void highlightAtom(int atomIndex, int pdbResNum, String chain,
621 int mdlNum = 1+getModelNum(pdbfile);
628 // if (!pdbfile.equals(pdbentry.getFile()))
630 if (resetLastRes.length() > 0)
632 viewer.evalStringQuiet(resetLastRes.toString());
636 eval.append("select " + pdbResNum); // +modelNum
638 resetLastRes.setLength(0);
639 resetLastRes.append("select " + pdbResNum); // +modelNum
641 if (!chain.equals(" "))
644 resetLastRes.append(":");
646 resetLastRes.append(chain);
650 eval.append(" /" + (mdlNum));
651 resetLastRes.append("/" + (mdlNum));
653 eval.append(";wireframe 100;" + eval.toString() + " and not hetero;");
655 resetLastRes.append(";wireframe 0;" + resetLastRes.toString()
656 + " and not hetero; spacefill 0;");
658 eval.append("spacefill 200;select none");
660 viewer.evalStringQuiet(eval.toString());
665 public void updateColours(Object source)
667 colourBySequence((AlignmentPanel) source);
670 // End StructureListener
671 // //////////////////////////
673 public Color getColour(int atomIndex, int pdbResNum, String chain,
676 if (!pdbfile.equals(pdbentry.getFile()))
679 return new Color(viewer.getAtomArgb(atomIndex));
684 FeatureRenderer fr = null;
686 public void colourBySequence(AlignmentPanel sourceap)
690 if (!colourBySequence)
692 String[] files = getPdbFile();
693 SequenceRenderer sr = new SequenceRenderer(ap.av);
695 boolean showFeatures = false;
697 if (ap.av.showSequenceFeatures)
702 fr = new jalview.appletgui.FeatureRenderer(ap.av);
705 fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
708 StringBuffer command = new StringBuffer();
710 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
712 StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
714 if (mapping == null || mapping.length < 1)
718 for (int s = 0; s < sequence.length; s++)
720 for (int sp, m = 0; m < mapping.length; m++)
722 if (mapping[m].getSequence() == sequence[s]
723 && (sp = ap.av.alignment.findIndex(sequence[s])) > -1)
725 SequenceI asp = ap.av.alignment.getSequenceAt(sp);
726 for (int r = 0; r < asp.getLength(); r++)
728 // no mapping to gaps in sequence
729 if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
733 int pos = mapping[m].getPDBResNum(asp.findPosition(r));
735 if (pos < 1 || pos == lastPos)
740 Color col = sr.getResidueBoxColour(sequence[s], r);
743 col = fr.findFeatureColour(col, sequence[s], r);
744 String newSelcom = (mapping[m].getChain() != " " ? ":"
745 + mapping[m].getChain() : "")
754 + col.getBlue() + "]";
755 if (command.toString().endsWith(newSelcom))
757 command = condenseCommand(command.toString(), pos);
760 // TODO: deal with case when buffer is too large for Jmol to parse
761 // - execute command and flush
763 command.append(";select " + pos);
764 command.append(newSelcom);
773 if (lastCommand == null || !lastCommand.equals(command.toString()))
775 viewer.evalStringQuiet(command.toString());
778 lastCommand = command.toString();
781 StringBuffer condenseCommand(String command, int pos)
784 StringBuffer sb = new StringBuffer(command.substring(0, command
785 .lastIndexOf("select") + 7));
787 command = command.substring(sb.length());
791 if (command.indexOf("-") > -1)
793 start = command.substring(0, command.indexOf("-"));
797 start = command.substring(0, command.indexOf(":"));
800 sb.append(start + "-" + pos + command.substring(command.indexOf(":")));
805 // ///////////////////////////////
806 // JmolStatusListener
808 public String eval(String strEval)
810 // System.out.println(strEval);
811 // "# 'eval' is implemented only for the applet.";
815 public void createImage(String file, String type, int quality)
819 public void notifyFileLoaded(String fullPathName, String fileName2,
820 String modelName, String errorMsg, int modelParts)
822 if (errorMsg != null)
824 fileLoadingError = errorMsg;
828 fileLoadingError = null;
829 modelFileNames = null;
831 String[] modelfilenames = getPdbFile();
832 ssm = StructureSelectionManager.getStructureSelectionManager();
833 boolean modelsloaded=false;
834 for (int modelnum = 0; modelnum < modelfilenames.length; modelnum++)
836 String fileName = modelfilenames[modelnum];
837 if (fileName != null)
839 // search pdbentries and sequences to find correct pdbentry and sequence[] pair for this filename
840 if (pdbentry.getFile().equals(fileName))
846 pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(),
847 AppletFormatAdapter.PASTE);
848 pdbentry.setFile("INLINE" + pdb.id);
852 // TODO: Jmol can in principle retrieve from CLASSLOADER but this
854 // to be tested. See mantis bug
855 // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
857 pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(),
858 AppletFormatAdapter.URL);
862 pdbentry.setId(pdb.id);
864 Vector chains = new Vector();
865 for (int i = 0; i < pdb.chains.size(); i++)
867 chains.addElement(new String(pdb.id + ":"
868 + ((MCview.PDBChain) pdb.chains.elementAt(i)).id));
870 setChainMenuItems(chains);
872 colourBySequence(ap);
874 StringBuffer title = new StringBuffer(sequence[0].getName() + ":"
877 if (pdbentry.getProperty() != null)
879 if (pdbentry.getProperty().get("method") != null)
881 title.append(" Method: ");
882 title.append(pdbentry.getProperty().get("method"));
884 if (pdbentry.getProperty().get("chains") != null)
886 title.append(" Chain:");
887 title.append(pdbentry.getProperty().get("chains"));
891 this.setTitle(title.toString());
896 // this is a foreign pdb file that jalview doesn't know about - add it to the dataset
897 // and try to find a home - either on a matching sequence or as a new sequence.
898 String pdbcontent = viewer.getData("/" + (modelnum + 1) + ".1",
900 // parse pdb file into a chain, etc.
901 // locate best match for pdb in associated views and add mapping to
909 jmolpopup.updateComputedMenus();
911 .evalStringQuiet("model 0; select backbone;restrict;cartoon;wireframe off;spacefill off");
913 ssm.addStructureViewerListener(this);
917 public void sendConsoleEcho(String strEcho)
919 if (scriptWindow == null)
922 history.append("\n" + strEcho);
925 public void sendConsoleMessage(String strStatus)
927 if (history != null && strStatus != null
928 && !strStatus.equals("Script completed"))
930 history.append("\n" + strStatus);
934 public void notifyScriptTermination(String strStatus, int msWalltime)
938 public void handlePopupMenu(int x, int y)
940 jmolpopup.show(x, y);
943 public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
945 notifyAtomPicked(iatom, strMeasure, null);
948 public void notifyAtomPicked(int atomIndex, String strInfo, String strData)
952 System.err.println("Ignoring additional pick data string " + strData);
954 int chainSeparator = strInfo.indexOf(":");
956 if (chainSeparator == -1)
957 chainSeparator = strInfo.indexOf(".");
959 String picked = strInfo.substring(strInfo.indexOf("]") + 1,
962 if ((p=strInfo.indexOf(":")) > -1)
963 picked += strInfo.substring(p + 1, strInfo
966 if ((p=strInfo.indexOf("/"))> -1)
968 mdlString += strInfo.substring(p, strInfo.indexOf(" #"));
970 picked = "((" + picked + ".CA" + mdlString+")|(" + picked + ".P" + mdlString+"))";
973 if (!atomsPicked.contains(picked))
975 viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
976 atomsPicked.addElement(picked);
980 viewer.evalString("select " + picked + ";label off");
981 atomsPicked.removeElement(picked);
987 public void notifyAtomHovered(int atomIndex, String strInfo, String data)
991 System.err.println("Ignoring additional hover info: " + data);
993 mouseOverStructure(atomIndex, strInfo);
996 public void showUrl(String url)
1000 ap.av.applet.getAppletContext().showDocument(new java.net.URL(url),
1002 } catch (java.net.MalformedURLException ex)
1007 public void showConsole(boolean showConsole)
1009 if (scriptWindow == null)
1011 scriptWindow = new Panel(new BorderLayout());
1012 inputLine = new TextField();
1013 history = new TextArea(5, 40);
1014 scriptWindow.add(history, BorderLayout.CENTER);
1015 scriptWindow.add(inputLine, BorderLayout.SOUTH);
1016 add(scriptWindow, BorderLayout.SOUTH);
1017 scriptWindow.setVisible(false);
1018 history.setEditable(false);
1019 inputLine.addKeyListener(this);
1022 scriptWindow.setVisible(!scriptWindow.isVisible());
1026 public float[][] functionXY(String functionName, int x, int y)
1031 // /End JmolStatusListener
1032 // /////////////////////////////
1034 class RenderPanel extends Panel
1036 Dimension currentSize = new Dimension();
1038 Rectangle rectClip = new Rectangle();
1040 public void update(Graphics g)
1045 public void paint(Graphics g)
1047 currentSize = this.getSize();
1048 rectClip = g.getClipBounds();
1052 g.setColor(Color.black);
1053 g.fillRect(0, 0, currentSize.width, currentSize.height);
1054 g.setColor(Color.white);
1055 g.setFont(new Font("Verdana", Font.BOLD, 14));
1056 g.drawString("Retrieving PDB data....", 20, currentSize.height / 2);
1060 viewer.renderScreenImage(g, currentSize, rectClip);
1065 public String createImage(String fileName, String type,
1066 Object textOrBytes, int quality)
1068 // TODO Auto-generated method stub
1072 public float[][][] functionXYZ(String functionName, int nx, int ny, int nz)
1074 // TODO Auto-generated method stub
1078 public Hashtable getRegistryInfo()
1080 // TODO Auto-generated method stub
1084 public void notifyCallback(int type, Object[] data)
1090 case JmolConstants.CALLBACK_LOADSTRUCT:
1091 notifyFileLoaded((String) data[1], (String) data[2],
1092 (String) data[3], (String) data[4], ((Integer) data[5])
1096 case JmolConstants.CALLBACK_PICK:
1097 notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1],
1099 // also highlight in alignment
1100 case JmolConstants.CALLBACK_HOVER:
1101 notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1],
1104 case JmolConstants.CALLBACK_SCRIPT:
1105 notifyScriptTermination((String) data[2], ((Integer) data[3])
1108 case JmolConstants.CALLBACK_ECHO:
1109 sendConsoleEcho((String) data[1]);
1111 case JmolConstants.CALLBACK_MESSAGE:
1112 sendConsoleMessage((data == null) ? ((String) null)
1113 : (String) data[1]);
1115 case JmolConstants.CALLBACK_MEASURE:
1116 case JmolConstants.CALLBACK_CLICK:
1118 System.err.println("Unhandled callback " + type + " " + data);
1121 } catch (Exception e)
1123 System.err.println("Squashed Jmol callback handler error:");
1124 e.printStackTrace();
1128 public boolean notifyEnabled(int callbackPick)
1130 switch (callbackPick)
1132 case JmolConstants.CALLBACK_ECHO:
1133 case JmolConstants.CALLBACK_LOADSTRUCT:
1134 case JmolConstants.CALLBACK_MEASURE:
1135 case JmolConstants.CALLBACK_MESSAGE:
1136 case JmolConstants.CALLBACK_PICK:
1137 case JmolConstants.CALLBACK_SCRIPT:
1138 case JmolConstants.CALLBACK_HOVER:
1139 case JmolConstants.CALLBACK_ERROR:
1141 case JmolConstants.CALLBACK_CLICK:
1142 case JmolConstants.CALLBACK_ANIMFRAME:
1143 case JmolConstants.CALLBACK_MINIMIZATION:
1144 case JmolConstants.CALLBACK_RESIZE:
1145 case JmolConstants.CALLBACK_SYNC:
1150 public void setCallbackFunction(String callbackType,
1151 String callbackFunction)
1153 System.err.println("Ignoring set-callback request to associate "
1154 + callbackType + " with function " + callbackFunction);