import org.jmol.api.*;\r
import org.jmol.adapter.smarter.SmarterJmolAdapter;\r
import org.jmol.popup.*;\r
+import jalview.schemes.*;\r
\r
\r
public class AppletJmol extends Frame\r
{\r
Menu fileMenu = new Menu("File");\r
Menu viewMenu = new Menu("View");\r
+ Menu coloursMenu = new Menu("Colours");\r
Menu chainMenu = new Menu("Show Chain");\r
+ Menu helpMenu = new Menu("Help");\r
MenuItem mappingMenuItem = new MenuItem("View Mapping");\r
\r
+ CheckboxMenuItem seqColour = new CheckboxMenuItem("By Sequence", true);\r
+ MenuItem chain = new MenuItem("By Chain");\r
+ MenuItem charge = new MenuItem("Charge & Cysteine");\r
+ MenuItem zappo = new MenuItem("Zappo");\r
+ MenuItem taylor = new MenuItem("Taylor");\r
+ MenuItem hydro = new MenuItem("Hydrophobicity");\r
+ MenuItem helix = new MenuItem("Helix Propensity");\r
+ MenuItem strand = new MenuItem("Strand Propensity");\r
+ MenuItem turn = new MenuItem("Turn Propensity");\r
+ MenuItem buried = new MenuItem("Buried Index");\r
+ MenuItem user = new MenuItem("User Defined Colours");\r
+\r
+ MenuItem jmolHelp = new MenuItem("Jmol Help");\r
+\r
JmolViewer viewer;\r
JmolPopup jmolpopup;\r
\r
boolean loadedInline;\r
PDBEntry pdbentry;\r
boolean colourBySequence = true;\r
+ Vector atomsPicked = new Vector();\r
\r
public AppletJmol(PDBEntry pdbentry,\r
SequenceI[] seq,\r
menuBar.add(viewMenu);\r
mappingMenuItem.addActionListener(this);\r
viewMenu.add(chainMenu);\r
+ menuBar.add(coloursMenu);\r
+ menuBar.add(helpMenu);\r
+\r
+ charge.addActionListener(this);\r
+ hydro.addActionListener(this);\r
+ chain.addActionListener(this);\r
+ seqColour.addItemListener(this);\r
+ zappo.addActionListener(this);\r
+ taylor.addActionListener(this);\r
+ helix.addActionListener(this);\r
+ strand.addActionListener(this);\r
+ turn.addActionListener(this);\r
+ buried.addActionListener(this);\r
+ user.addActionListener(this);\r
+\r
+ jmolHelp.addActionListener(this);\r
+\r
+ coloursMenu.add(seqColour);\r
+ coloursMenu.add(chain);\r
+ coloursMenu.add(charge);\r
+ coloursMenu.add(zappo);\r
+ coloursMenu.add(taylor);\r
+ coloursMenu.add(hydro);\r
+ coloursMenu.add(helix);\r
+ coloursMenu.add(strand);\r
+ coloursMenu.add(turn);\r
+ coloursMenu.add(buried);\r
+ coloursMenu.add(user);\r
+\r
+ helpMenu.add(jmolHelp);\r
+\r
this.setMenuBar(menuBar);\r
\r
if(pdbentry.getFile()!=null)\r
pdbentry.getFile())\r
);\r
}\r
+ else if (evt.getSource() == charge)\r
+ {\r
+ colourBySequence = false;\r
+ seqColour.setState(false);\r
+ viewer.evalStringQuiet("select *;color white;select ASP,GLU;color red;"\r
+ +"select LYS,ARG;color blue;select CYS;color yellow");\r
+ }\r
+\r
+ else if (evt.getSource() == chain)\r
+ {\r
+ colourBySequence = false;\r
+ seqColour.setState(false);\r
+ viewer.evalStringQuiet("select *;color chain");\r
+ }\r
+ else if (evt.getSource() == zappo)\r
+ {\r
+ setJalviewColourScheme(new ZappoColourScheme());\r
+ }\r
+ else if (evt.getSource() == taylor)\r
+ {\r
+ setJalviewColourScheme(new TaylorColourScheme());\r
+ }\r
+ else if (evt.getSource() == hydro)\r
+ {\r
+ setJalviewColourScheme(new HydrophobicColourScheme());\r
+ }\r
+ else if (evt.getSource() == helix)\r
+ {\r
+ setJalviewColourScheme(new HelixColourScheme());\r
+ }\r
+ else if (evt.getSource() == strand)\r
+ {\r
+ setJalviewColourScheme(new StrandColourScheme());\r
+ }\r
+ else if (evt.getSource() == turn)\r
+ {\r
+ setJalviewColourScheme(new TurnColourScheme());\r
+ }\r
+ else if (evt.getSource() == buried)\r
+ {\r
+ setJalviewColourScheme(new BuriedColourScheme());\r
+ }\r
+ else if (evt.getSource() == user)\r
+ {\r
+ new UserDefinedColours(this);\r
+ }\r
+ else if(evt.getSource() == jmolHelp)\r
+ {\r
+ try{\r
+ ap.av.applet.getAppletContext().showDocument(\r
+ new java.net.URL("http://jmol.sourceforge.net/docs/JmolUserGuide/"),\r
+ "jmolHelp");\r
+ }catch(java.net.MalformedURLException ex){}\r
+ }\r
else\r
{\r
allChainsSelected = true;\r
}\r
}\r
\r
+ public void setJalviewColourScheme(ColourSchemeI cs)\r
+ {\r
+ colourBySequence = false;\r
+ seqColour.setState(false);\r
+\r
+ if(cs==null)\r
+ return;\r
+\r
+ String res;\r
+ int index;\r
+ Color col;\r
+\r
+ Enumeration en = ResidueProperties.aa3Hash.keys();\r
+ StringBuffer command = new StringBuffer("select *;color white;");\r
+ while(en.hasMoreElements())\r
+ {\r
+ res = en.nextElement().toString();\r
+ index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();\r
+ if(index>20)\r
+ continue;\r
+\r
+ col = cs.findColour(ResidueProperties.aa[index].charAt(0));\r
+\r
+ command.append("select "+res+";color["\r
+ + col.getRed() + ","\r
+ + col.getGreen() + ","\r
+ + col.getBlue() + "];");\r
+ }\r
+\r
+ viewer.evalStringQuiet(command.toString());\r
+ }\r
+\r
public void itemStateChanged(ItemEvent evt)\r
{\r
- if (!allChainsSelected)\r
+ if (evt.getSource() == seqColour)\r
+ {\r
+ colourBySequence = seqColour.getState();\r
+ colourBySequence(ap);\r
+ }\r
+ else if (!allChainsSelected)\r
centerViewer();\r
}\r
\r
String lastMessage;\r
public void mouseOverStructure(int atomIndex, String strInfo)\r
{\r
- int pdbResNum = Integer.parseInt(\r
- strInfo.substring(strInfo.indexOf("]")+ 1, strInfo.indexOf(":")));\r
+ int pdbResNum;\r
+\r
+ int chainSeparator = strInfo.indexOf(":");\r
\r
- String chainId = strInfo.substring\r
- (strInfo.indexOf(":"), strInfo.indexOf("."));\r
+ if(chainSeparator==-1)\r
+ chainSeparator = strInfo.indexOf(".");\r
\r
- if (chainId != null)\r
- chainId = chainId.substring(1, chainId.length());\r
+ pdbResNum = Integer.parseInt(\r
+ strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator));\r
+\r
+ String chainId;\r
+\r
+ if (strInfo.indexOf(":") > -1)\r
+ chainId = strInfo.substring\r
+ (strInfo.indexOf(":")+1, strInfo.indexOf("."));\r
else\r
{\r
chainId = " ";\r
\r
public void sendConsoleEcho(String strEcho)\r
{\r
- // if (scriptWindow != null)\r
- // scriptWindow.sendConsoleEcho(strEcho);\r
+ if (scriptWindow == null)\r
+ showConsole(true);\r
+\r
+ history.append("\n"+strEcho);\r
}\r
\r
public void sendConsoleMessage(String strStatus)\r
}\r
\r
public void notifyScriptTermination(String strStatus, int msWalltime)\r
- {\r
- // if (scriptWindow != null)\r
- // scriptWindow.notifyScriptTermination(strStatus, msWalltime);\r
- }\r
+ { }\r
\r
public void handlePopupMenu(int x, int y)\r
{\r
\r
public void notifyAtomPicked(int atomIndex, String strInfo)\r
{\r
- // if (scriptWindow != null)\r
+\r
+ int chainSeparator = strInfo.indexOf(":");\r
+\r
+ if(chainSeparator==-1)\r
+ chainSeparator = strInfo.indexOf(".");\r
+\r
+ String picked =\r
+ strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator);\r
+\r
+\r
+ if (strInfo.indexOf(":") > -1)\r
+ picked+=strInfo.substring(strInfo.indexOf(":")+1,\r
+ strInfo.indexOf("."));\r
+\r
+ picked+=".C";\r
+\r
+ if (!atomsPicked.contains(picked))\r
+ {\r
+ viewer.evalString("select "+picked+";label %n %r:%c");\r
+ atomsPicked.addElement(picked);\r
+ }\r
+ else\r
{\r
- // scriptWindow.sendConsoleMessage(strInfo);\r
- // scriptWindow.sendConsoleMessage("\n");\r
+ viewer.evalString("select "+picked+";label off");\r
+ atomsPicked.removeElement(picked);\r
}\r
}\r
\r
{}\r
\r
public void showUrl(String url)\r
- {}\r
+ {\r
+ try{\r
+ ap.av.applet.getAppletContext().showDocument(new java.net.URL(url),\r
+ "jmolOutput");\r
+ }catch(java.net.MalformedURLException ex)\r
+ {}\r
+ }\r
\r
public void showConsole(boolean showConsole)\r
{\r