X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FAppletJmol.java;h=7939d9bf4b3fa60c47ed864fc4fd54ec22363e66;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=82a5911917799c6e5df6d81ac74670dfad74bf58;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index 82a5911..7939d9b 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, 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 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. - * + * * 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 */ - package jalview.appletgui; import java.util.*; @@ -33,71 +32,121 @@ import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.popup.*; import jalview.schemes.*; - -public class AppletJmol extends EmbmenuFrame - implements StructureListener, JmolStatusListener, - KeyListener, ActionListener, ItemListener +public class AppletJmol extends EmbmenuFrame implements StructureListener, + JmolStatusListener, KeyListener, ActionListener, ItemListener { Menu fileMenu = new Menu("File"); + Menu viewMenu = new Menu("View"); + Menu coloursMenu = new Menu("Colours"); + Menu chainMenu = new Menu("Show Chain"); + Menu helpMenu = new Menu("Help"); + MenuItem mappingMenuItem = new MenuItem("View Mapping"); CheckboxMenuItem seqColour = new CheckboxMenuItem("By Sequence", true); + MenuItem chain = new MenuItem("By Chain"); + MenuItem charge = new MenuItem("Charge & Cysteine"); + MenuItem zappo = new MenuItem("Zappo"); + MenuItem taylor = new MenuItem("Taylor"); + MenuItem hydro = new MenuItem("Hydrophobicity"); + MenuItem helix = new MenuItem("Helix Propensity"); + MenuItem strand = new MenuItem("Strand Propensity"); + MenuItem turn = new MenuItem("Turn Propensity"); + MenuItem buried = new MenuItem("Buried Index"); + MenuItem user = new MenuItem("User Defined Colours"); MenuItem jmolHelp = new MenuItem("Jmol Help"); JmolViewer viewer; + JmolPopup jmolpopup; Panel scriptWindow; + TextField inputLine; + TextArea history; + SequenceI[] sequence; - String [] chains; + + String[] chains; + StructureSelectionManager ssm; + RenderPanel renderPanel; + AlignmentPanel ap; + String fileLoadingError; + boolean loadedInline; + PDBEntry pdbentry; + boolean colourBySequence = true; + Vector atomsPicked = new Vector(); - public AppletJmol(PDBEntry pdbentry, - SequenceI[] seq, - String[] chains, - AlignmentPanel ap, - String protocol) + /** + * datasource protocol for access to PDBEntry + */ + String protocol = null; + + public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains, + AlignmentPanel ap, String protocol) { this.ap = ap; this.sequence = seq; this.chains = chains; this.pdbentry = pdbentry; + this.protocol = protocol; + if (pdbentry.getId() == null || pdbentry.getId().length() < 1) + { + if (jalview.bin.JalviewLite.debug) + { + System.err.println("Setting PDB id for file " + pdbentry.getFile()); + if (protocol.equals(AppletFormatAdapter.PASTE)) + { + pdbentry.setId("PASTED PDB" + + (chains == null ? "_" : chains.toString())); + } + else + { + pdbentry.setId(pdbentry.getFile()); + } + } + } + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol: PDB ID is '" + pdbentry.getId() + "'"); + } - String alreadyMapped = StructureSelectionManager - .getStructureSelectionManager() - .alreadyMappedToFile(pdbentry.getId()); - + String alreadyMapped = StructureSelectionManager + .getStructureSelectionManager().alreadyMappedToFile( + pdbentry.getId()); + MCview.PDBfile reader = null; if (alreadyMapped != null) { - StructureSelectionManager.getStructureSelectionManager() - .setMapping(seq, chains, pdbentry.getFile(), protocol); - //PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW? - //FOR NOW, LETS JUST OPEN A NEW WINDOW + reader = StructureSelectionManager.getStructureSelectionManager() + .setMapping(seq, chains, pdbentry.getFile(), protocol); + // PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW? + // FOR NOW, LETS JUST OPEN A NEW WINDOW } MenuBar menuBar = new MenuBar(); menuBar.add(fileMenu); @@ -141,57 +190,90 @@ public class AppletJmol extends EmbmenuFrame renderPanel = new RenderPanel(); embedMenuIfNeeded(renderPanel); this.add(renderPanel, BorderLayout.CENTER); - viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter()); + viewer = JmolViewer.allocateViewer(renderPanel, + new SmarterJmolAdapter()); - viewer.setAppletContext("jalview", - ap.av.applet.getDocumentBase(), - ap.av.applet.getCodeBase(), - null); + viewer.setAppletContext("jalview", ap.av.applet.getDocumentBase(), + ap.av.applet.getCodeBase(), null); viewer.setJmolStatusListener(this); jmolpopup = JmolPopup.newJmolPopup(viewer); this.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - closeViewer(); - } - }); - + { + public void windowClosing(WindowEvent evt) + { + closeViewer(); + } + }); - if(pdbentry.getFile()!=null) + if (pdbentry.getFile() != null) { // import structure data from pdbentry.getFile based on given protocol if (protocol.equals(AppletFormatAdapter.PASTE)) - { + { loadInline(pdbentry.getFile()); - } else - if (protocol.equals(AppletFormatAdapter.FILE) || protocol.equals(AppletFormatAdapter.URL)){ - viewer.openFile(pdbentry.getFile()); + } + else if (protocol.equals(AppletFormatAdapter.FILE) + || protocol.equals(AppletFormatAdapter.URL)) + { + viewer.openFile(pdbentry.getFile()); } else - { + { // probably CLASSLOADER based datasource.. // Try and get a reader on the datasource, and pass that to Jmol - try { - FileParse fparser = new jalview.io.FileParse(protocol, pdbentry.getFile()); - if (!fparser.isValid()) + try + { + java.io.Reader freader = null; + if (reader != null) + { + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol:Trying to reuse existing PDBfile IO parser."); + } + // re-use the one we opened earlier + freader = reader.getReader(); + } + if (freader == null) + { + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol:Creating new PDBfile IO parser."); + } + FileParse fp = new FileParse(pdbentry.getFile(), protocol); + fp.mark(); + // reader = new MCview.PDBfile(fp); + // could set ID, etc. + // if (!reader.isValid()) + // { + // throw new Exception("Invalid datasource. + // "+reader.getWarningMessage()); + // } + // fp.reset(); + freader = fp.getReader(); + } + if (freader == null) { - throw new Exception("Invalid datasource. "+fparser.getWarningMessage()); + throw new Exception( + "Invalid datasource. Could not obtain Reader."); } - viewer.openReader(pdbentry.getFile(), pdbentry.getId(), fparser.getReader()); + viewer.openReader(pdbentry.getFile(), pdbentry.getId(), freader); } catch (Exception e) { // give up! - System.err.println("Couldn't access pdbentry id="+pdbentry.getId()+" and file="+pdbentry.getFile()+" using protocol="+protocol); + System.err.println("Couldn't access pdbentry id=" + + pdbentry.getId() + " and file=" + pdbentry.getFile() + + " using protocol=" + protocol); e.printStackTrace(); } - } + } } - - jalview.bin.JalviewLite.addFrame(this, "Jmol", 400,400); + + jalview.bin.JalviewLite.addFrame(this, "Jmol", 400, 400); } public void loadInline(String string) @@ -200,7 +282,6 @@ public class AppletJmol extends EmbmenuFrame viewer.openStringInline(string); } - void setChainMenuItems(Vector chains) { chainMenu.removeAll(); @@ -213,13 +294,15 @@ public class AppletJmol extends EmbmenuFrame CheckboxMenuItem menuItemCB; for (int c = 0; c < chains.size(); c++) { - menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(), true); + menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(), + true); menuItemCB.addItemListener(this); chainMenu.add(menuItemCB); } } boolean allChainsSelected = false; + void centerViewer() { StringBuffer cmd = new StringBuffer(); @@ -236,11 +319,11 @@ public class AppletJmol extends EmbmenuFrame if (cmd.length() > 0) cmd.setLength(cmd.length() - 4); - viewer.evalString("select *;restrict " - + cmd + ";cartoon;center " + cmd); + viewer + .evalString("select *;restrict " + cmd + ";cartoon;center " + + cmd); } - void closeViewer() { viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE); @@ -248,37 +331,35 @@ public class AppletJmol extends EmbmenuFrame viewer.setJmolStatusListener(null); viewer = null; - //We'll need to find out what other + // We'll need to find out what other // listeners need to be shut down in Jmol - StructureSelectionManager - .getStructureSelectionManager() - .removeStructureViewerListener(this, pdbentry.getId()); + StructureSelectionManager.getStructureSelectionManager() + .removeStructureViewerListener(this, pdbentry.getId()); this.setVisible(false); } public void actionPerformed(ActionEvent evt) { - if(evt.getSource()==mappingMenuItem) + if (evt.getSource() == mappingMenuItem) { - jalview.appletgui.CutAndPasteTransfer cap - = new jalview.appletgui.CutAndPasteTransfer(false, null); + jalview.appletgui.CutAndPasteTransfer cap = new jalview.appletgui.CutAndPasteTransfer( + false, null); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 550, - 600); - cap.setText( - StructureSelectionManager.getStructureSelectionManager().printMapping( - pdbentry.getFile()) - ); + jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", + 550, 600); + cap.setText(StructureSelectionManager.getStructureSelectionManager() + .printMapping(pdbentry.getFile())); } else if (evt.getSource() == charge) { colourBySequence = false; seqColour.setState(false); - viewer.evalStringQuiet("select *;color white;select ASP,GLU;color red;" - +"select LYS,ARG;color blue;select CYS;color yellow"); + viewer + .evalStringQuiet("select *;color white;select ASP,GLU;color red;" + + "select LYS,ARG;color blue;select CYS;color yellow"); } else if (evt.getSource() == chain) @@ -293,7 +374,7 @@ public class AppletJmol extends EmbmenuFrame } else if (evt.getSource() == taylor) { - setJalviewColourScheme(new TaylorColourScheme()); + setJalviewColourScheme(new TaylorColourScheme()); } else if (evt.getSource() == hydro) { @@ -319,13 +400,17 @@ public class AppletJmol extends EmbmenuFrame { new UserDefinedColours(this); } - else if(evt.getSource() == jmolHelp) + else if (evt.getSource() == jmolHelp) { - try{ + try + { ap.av.applet.getAppletContext().showDocument( - new java.net.URL("http://jmol.sourceforge.net/docs/JmolUserGuide/"), - "jmolHelp"); - }catch(java.net.MalformedURLException ex){} + new java.net.URL( + "http://jmol.sourceforge.net/docs/JmolUserGuide/"), + "jmolHelp"); + } catch (java.net.MalformedURLException ex) + { + } } else { @@ -333,7 +418,7 @@ public class AppletJmol extends EmbmenuFrame for (int i = 0; i < chainMenu.getItemCount(); i++) { if (chainMenu.getItem(i) instanceof CheckboxMenuItem) - ( (CheckboxMenuItem) chainMenu.getItem(i)).setState(true); + ((CheckboxMenuItem) chainMenu.getItem(i)).setState(true); } centerViewer(); allChainsSelected = false; @@ -345,7 +430,7 @@ public class AppletJmol extends EmbmenuFrame colourBySequence = false; seqColour.setState(false); - if(cs==null) + if (cs == null) return; String res; @@ -354,19 +439,17 @@ public class AppletJmol extends EmbmenuFrame Enumeration en = ResidueProperties.aa3Hash.keys(); StringBuffer command = new StringBuffer("select *;color white;"); - while(en.hasMoreElements()) + while (en.hasMoreElements()) { res = en.nextElement().toString(); index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue(); - if(index>20) + if (index > 20) continue; col = cs.findColour(ResidueProperties.aa[index].charAt(0)); - command.append("select "+res+";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "];"); + command.append("select " + res + ";color[" + col.getRed() + "," + + col.getGreen() + "," + col.getBlue() + "];"); } viewer.evalStringQuiet(command.toString()); @@ -386,63 +469,66 @@ public class AppletJmol extends EmbmenuFrame public void keyPressed(KeyEvent evt) { - if (evt.getKeyCode() == KeyEvent.VK_ENTER - && scriptWindow.isVisible()) + if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible()) { viewer.evalString(inputLine.getText()); - history.append("\n$ "+inputLine.getText()); + history.append("\n$ " + inputLine.getText()); inputLine.setText(""); } } public void keyTyped(KeyEvent evt) - { } + { + } - public void keyReleased(KeyEvent evt){} + public void keyReleased(KeyEvent evt) + { + } - ////////////////////////////////// - ///StructureListener + // //////////////////////////////// + // /StructureListener public String getPdbFile() { return "???"; } - - String lastMessage; + public void mouseOverStructure(int atomIndex, String strInfo) { - int pdbResNum; + int pdbResNum; - int chainSeparator = strInfo.indexOf(":"); + int chainSeparator = strInfo.indexOf(":"); - if(chainSeparator==-1) - chainSeparator = strInfo.indexOf("."); + if (chainSeparator == -1) + chainSeparator = strInfo.indexOf("."); - pdbResNum = Integer.parseInt( - strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator)); + pdbResNum = Integer.parseInt(strInfo.substring( + strInfo.indexOf("]") + 1, chainSeparator)); - String chainId; + String chainId; - if (strInfo.indexOf(":") > -1) - chainId = strInfo.substring - (strInfo.indexOf(":")+1, strInfo.indexOf(".")); - else - { - chainId = " "; - } + if (strInfo.indexOf(":") > -1) + chainId = strInfo.substring(strInfo.indexOf(":") + 1, strInfo + .indexOf(".")); + else + { + chainId = " "; + } - if (lastMessage == null || !lastMessage.equals(strInfo)) - ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile()); + if (lastMessage == null || !lastMessage.equals(strInfo)) + ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile()); - lastMessage = strInfo; + lastMessage = strInfo; } StringBuffer resetLastRes = new StringBuffer(); + StringBuffer eval = new StringBuffer(); - public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) + public void highlightAtom(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!pdbfile.equals(pdbentry.getFile())) return; @@ -464,9 +550,10 @@ public class AppletJmol extends EmbmenuFrame resetLastRes.append(":" + chain); } - eval.append(";wireframe 100;"+eval.toString()+".CA;"); + eval.append(";wireframe 100;" + eval.toString() + ".CA;"); - resetLastRes.append(";wireframe 0;"+resetLastRes.toString()+".CA;spacefill 0;"); + resetLastRes.append(";wireframe 0;" + resetLastRes.toString() + + ".CA;spacefill 0;"); eval.append("spacefill 200;select none"); @@ -476,13 +563,14 @@ public class AppletJmol extends EmbmenuFrame public void updateColours(Object source) { - colourBySequence( (AlignmentPanel) source); + colourBySequence((AlignmentPanel) source); } -//End StructureListener -//////////////////////////// + // End StructureListener + // ////////////////////////// - public Color getColour(int atomIndex, int pdbResNum, String chain, String pdbfile) + public Color getColour(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!pdbfile.equals(pdbentry.getFile())) return null; @@ -491,7 +579,9 @@ public class AppletJmol extends EmbmenuFrame } String lastCommand; - FeatureRenderer fr=null; + + FeatureRenderer fr = null; + public void colourBySequence(AlignmentPanel sourceap) { this.ap = sourceap; @@ -524,10 +614,10 @@ public class AppletJmol extends EmbmenuFrame int lastPos = -1; for (int s = 0; s < sequence.length; s++) { - for (int sp,m = 0; m < mapping.length; m++) + for (int sp, m = 0; m < mapping.length; m++) { if (mapping[m].getSequence() == sequence[s] - && (sp=ap.av.alignment.findIndex(sequence[s])) > -1) + && (sp = ap.av.alignment.findIndex(sequence[s])) > -1) { SequenceI asp = ap.av.alignment.getSequenceAt(sp); for (int r = 0; r < asp.getLength(); r++) @@ -537,9 +627,7 @@ public class AppletJmol extends EmbmenuFrame { continue; } - int pos = mapping[m].getPDBResNum( - asp.findPosition(r)); - + int pos = mapping[m].getPDBResNum(asp.findPosition(r)); if (pos < 1 || pos == lastPos) continue; @@ -551,11 +639,10 @@ public class AppletJmol extends EmbmenuFrame if (showFeatures) col = fr.findFeatureColour(col, sequence[s], r); - if (command.toString().endsWith(":" + mapping[m].getChain() + - ";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "]")) + if (command.toString().endsWith( + ":" + mapping[m].getChain() + ";color[" + col.getRed() + + "," + col.getGreen() + "," + col.getBlue() + + "]")) { command = condenseCommand(command.toString(), pos); continue; @@ -568,10 +655,8 @@ public class AppletJmol extends EmbmenuFrame command.append(":" + mapping[m].getChain()); } - command.append(";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "]"); + command.append(";color[" + col.getRed() + "," + col.getGreen() + + "," + col.getBlue() + "]"); } break; } @@ -585,11 +670,11 @@ public class AppletJmol extends EmbmenuFrame lastCommand = command.toString(); } - StringBuffer condenseCommand(String command, int pos) { - StringBuffer sb = new StringBuffer(command.substring(0, command.lastIndexOf("select")+7)); + StringBuffer sb = new StringBuffer(command.substring(0, command + .lastIndexOf("select") + 7)); command = command.substring(sb.length()); @@ -597,40 +682,41 @@ public class AppletJmol extends EmbmenuFrame if (command.indexOf("-") > -1) { - start = command.substring(0,command.indexOf("-")); + start = command.substring(0, command.indexOf("-")); } else { start = command.substring(0, command.indexOf(":")); } - sb.append(start+"-"+pos+command.substring(command.indexOf(":"))); + sb.append(start + "-" + pos + command.substring(command.indexOf(":"))); return sb; } - ///////////////////////////////// - //JmolStatusListener + // /////////////////////////////// + // JmolStatusListener public String eval(String strEval) { - // System.out.println(strEval); - //"# 'eval' is implemented only for the applet."; + // System.out.println(strEval); + // "# 'eval' is implemented only for the applet."; return null; } public void createImage(String file, String type, int quality) - {} + { + } public void setCallbackFunction(String callbackType, - String callbackFunction) - {} + String callbackFunction) + { + } public void notifyFileLoaded(String fullPathName, String fileName, - String modelName, Object clientFile, - String errorMsg) + String modelName, Object clientFile, String errorMsg) { - if(errorMsg!=null) + if (errorMsg != null) { fileLoadingError = errorMsg; repaint(); @@ -641,26 +727,28 @@ public class AppletJmol extends EmbmenuFrame if (fileName != null) { - //FILE LOADED OK + // FILE LOADED OK jmolpopup.updateComputedMenus(); - viewer.evalStringQuiet( - "select backbone;restrict;cartoon;wireframe off;spacefill off"); + viewer + .evalStringQuiet("select backbone;restrict;cartoon;wireframe off;spacefill off"); ssm = StructureSelectionManager.getStructureSelectionManager(); - MCview.PDBfile pdb; if (loadedInline) { - pdb = ssm.setMapping(sequence,chains, - pdbentry.getFile(), - AppletFormatAdapter.PASTE); - pdbentry.setFile("INLINE"+pdb.id); + pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(), + AppletFormatAdapter.PASTE); + pdbentry.setFile("INLINE" + pdb.id); } else { - pdb = ssm.setMapping(sequence,chains, - pdbentry.getFile(), - AppletFormatAdapter.URL); + // TODO: Jmol can in principle retrieve from CLASSLOADER but this needs + // to be tested. See mantis bug + // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605 + + pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(), + AppletFormatAdapter.URL); + } pdbentry.setId(pdb.id); @@ -670,14 +758,14 @@ public class AppletJmol extends EmbmenuFrame Vector chains = new Vector(); for (int i = 0; i < pdb.chains.size(); i++) { - chains.addElement( ( (MCview.PDBChain) pdb.chains.elementAt(i)).id); + chains.addElement(((MCview.PDBChain) pdb.chains.elementAt(i)).id); } setChainMenuItems(chains); colourBySequence(ap); - StringBuffer title = new StringBuffer(sequence[0].getName() + ":" + - pdbentry.getId()); + StringBuffer title = new StringBuffer(sequence[0].getName() + ":" + + pdbentry.getId()); if (pdbentry.getProperty() != null) { @@ -706,27 +794,29 @@ public class AppletJmol extends EmbmenuFrame } public void notifyScriptStart(String statusMessage, String additionalInfo) - {} + { + } public void sendConsoleEcho(String strEcho) { if (scriptWindow == null) showConsole(true); - history.append("\n"+strEcho); + history.append("\n" + strEcho); } public void sendConsoleMessage(String strStatus) { - if(history!=null && strStatus!=null - && !strStatus.equals("Script completed")) + if (history != null && strStatus != null + && !strStatus.equals("Script completed")) { - history.append("\n"+strStatus); + history.append("\n" + strStatus); } } public void notifyScriptTermination(String strStatus, int msWalltime) - { } + { + } public void handlePopupMenu(int x, int y) { @@ -739,34 +829,34 @@ public class AppletJmol extends EmbmenuFrame } public void notifyNewDefaultModeMeasurement(int count, String strInfo) - {} + { + } public void notifyAtomPicked(int atomIndex, String strInfo) { int chainSeparator = strInfo.indexOf(":"); - if(chainSeparator==-1) + if (chainSeparator == -1) chainSeparator = strInfo.indexOf("."); - String picked = - strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator); - + String picked = strInfo.substring(strInfo.indexOf("]") + 1, + chainSeparator); if (strInfo.indexOf(":") > -1) - picked+=strInfo.substring(strInfo.indexOf(":")+1, - strInfo.indexOf(".")); + picked += strInfo.substring(strInfo.indexOf(":") + 1, strInfo + .indexOf(".")); - picked+=".CA"; + picked += ".CA"; if (!atomsPicked.contains(picked)) { - viewer.evalString("select "+picked+";label %n %r:%c"); + viewer.evalString("select " + picked + ";label %n %r:%c"); atomsPicked.addElement(picked); } else { - viewer.evalString("select "+picked+";label off"); + viewer.evalString("select " + picked + ";label off"); atomsPicked.removeElement(picked); } } @@ -777,15 +867,18 @@ public class AppletJmol extends EmbmenuFrame } public void sendSyncScript(String script, String appletName) - {} + { + } public void showUrl(String url) { - try{ + try + { ap.av.applet.getAppletContext().showDocument(new java.net.URL(url), - "jmolOutput"); - }catch(java.net.MalformedURLException ex) - {} + "jmolOutput"); + } catch (java.net.MalformedURLException ex) + { + } } public void showConsole(boolean showConsole) @@ -812,19 +905,20 @@ public class AppletJmol extends EmbmenuFrame return 0; } - ///End JmolStatusListener - /////////////////////////////// - + // /End JmolStatusListener + // ///////////////////////////// - class RenderPanel - extends Panel + class RenderPanel extends Panel { Dimension currentSize = new Dimension(); + Rectangle rectClip = new Rectangle(); - public void update(Graphics g) { + public void update(Graphics g) + { paint(g); } + public void paint(Graphics g) { currentSize = this.getSize();