X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAppletJmol.java;h=619d5226f20fa5d039f1f1f8e65be3d26ceeacc1;hb=9ff5fcbe6681e37c441656e2f704f8d9bab9179c;hp=afbc83c546fe528dbb420dbe3bc8380bf59ca8a9;hpb=9adeaab28df6873e67ebe42e1ccd3a87cf6507af;p=jalview.git diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index afbc83c..619d522 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * * This file is part of Jalview. @@ -83,6 +83,7 @@ public class AppletJmol extends EmbmenuFrame implements RenderPanel renderPanel; AlignmentPanel ap; + ArrayList _aps = new ArrayList(); String fileLoadingError; @@ -99,12 +100,40 @@ public class AppletJmol extends EmbmenuFrame implements */ String protocol = null; + /** + * Load a bunch of pdb entries associated with sequences in the alignment and + * display them - aligning them if necessary. + * + * @param pdbentries + * each pdb file (at least one needed) + * @param boundseqs + * each set of sequences for each pdb file (must match number of pdb + * files) + * @param boundchains + * the target pdb chain corresponding with each sequence associated + * with each pdb file (may be null at any level) + * @param align + * true/false + * @param ap + * associated alignment + * @param protocol + * how to get pdb data + */ + public AppletJmol(PDBEntry[] pdbentries, SequenceI[][] boundseqs, + String[][] boundchains, boolean align, AlignmentPanel ap, + String protocol) + { + throw new Error("Not yet implemented."); + } + public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains, AlignmentPanel ap, String protocol) { this.ap = ap; jmb = new AppletJmolBinding(this, new PDBEntry[] - { pdbentry }, seq, chains, protocol); + { pdbentry }, new SequenceI[][] + { seq }, new String[][] + { chains }, protocol); jmb.setColourBySequence(true); if (pdbentry.getId() == null || pdbentry.getId().length() < 1) { @@ -172,17 +201,22 @@ public class AppletJmol extends EmbmenuFrame implements coloursMenu.add(user); helpMenu.add(jmolHelp); + this.setLayout(new BorderLayout()); setMenuBar(menuBar); renderPanel = new RenderPanel(); embedMenuIfNeeded(renderPanel); this.add(renderPanel, BorderLayout.CENTER); + scriptWindow = new Panel(); + scriptWindow.setVisible(false); + // this.add(scriptWindow, BorderLayout.SOUTH); + try { - jmb.allocateViewer(renderPanel, "jalviewJmol", - ap.av.applet.getDocumentBase(), ap.av.applet.getCodeBase(), - ""); + jmb.allocateViewer(renderPanel, true, ap.av.applet.getName() + + "_jmol_", ap.av.applet.getDocumentBase(), + ap.av.applet.getCodeBase(), "-applet", scriptWindow, null); } catch (Exception e) { System.err @@ -203,12 +237,18 @@ public class AppletJmol extends EmbmenuFrame implements closeViewer(); } }); - + if (pdbentry.getProperty() == null) + { + pdbentry.setProperty(new Hashtable()); + pdbentry.getProperty().put("protocol", protocol); + } if (pdbentry.getFile() != null) { // import structure data from pdbentry.getFile based on given protocol if (protocol.equals(AppletFormatAdapter.PASTE)) { + // TODO: JAL-623 : correctly record file contents for matching up later + // pdbentry.getProperty().put("pdbfilehash",""+pdbentry.getFile().hashCode()); loadInline(pdbentry.getFile()); } else if (protocol.equals(AppletFormatAdapter.FILE) @@ -276,7 +316,7 @@ public class AppletJmol extends EmbmenuFrame implements public void loadInline(String string) { loadedInline = true; - jmb.viewer.openStringInline(string); + jmb.loadInline(string); } void setChainMenuItems(Vector chains) @@ -335,15 +375,26 @@ public class AppletJmol extends EmbmenuFrame implements Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", - 550, 600); StringBuffer sb = new StringBuffer(); - for (int s = 0; s < jmb.pdbentry.length; s++) + try + { + for (int s = 0; s < jmb.pdbentry.length; s++) + { + sb.append(StructureSelectionManager + .getStructureSelectionManager().printMapping( + jmb.pdbentry[s].getFile())); + sb.append("\n"); + } + cap.setText(sb.toString()); + } catch (OutOfMemoryError ex) { - sb.append(StructureSelectionManager.getStructureSelectionManager() - .printMapping(jmb.pdbentry[s].getFile())); - sb.append("\n"); + frame.dispose(); + System.err + .println("Out of memory when trying to create dialog box with sequence-structure mapping."); + return; } + jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", + 550, 600); } else if (evt.getSource() == charge) { @@ -439,7 +490,7 @@ public class AppletJmol extends EmbmenuFrame implements if (evt.getSource() == seqColour) { setEnabled(seqColour); - jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap.av.alignment); + jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap); } else if (!allChainsSelected) centerViewer(); @@ -467,7 +518,7 @@ public class AppletJmol extends EmbmenuFrame implements public void updateColours(Object source) { AlignmentPanel ap = (AlignmentPanel) source; - jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap.av.alignment); + jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap); } public void updateTitleAndMenus() @@ -478,7 +529,7 @@ public class AppletJmol extends EmbmenuFrame implements return; } setChainMenuItems(jmb.chainNames); - jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap.av.alignment); + jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap); setTitle(jmb.getViewerTitle()); } @@ -494,22 +545,30 @@ public class AppletJmol extends EmbmenuFrame implements } } + Panel splitPane = null; + public void showConsole(boolean showConsole) { - if (scriptWindow == null) - { - scriptWindow = new Panel(new BorderLayout()); - inputLine = new TextField(); - history = new TextArea(5, 40); - scriptWindow.add(history, BorderLayout.CENTER); - scriptWindow.add(inputLine, BorderLayout.SOUTH); - add(scriptWindow, BorderLayout.SOUTH); + if (showConsole) + { + remove(renderPanel); + splitPane = new Panel(); + + splitPane.setLayout(new java.awt.GridLayout(2, 1)); + splitPane.add(renderPanel); + splitPane.add(scriptWindow); + scriptWindow.setVisible(true); + this.add(splitPane, BorderLayout.CENTER); + splitPane.setVisible(true); + splitPane.validate(); + } + else + { scriptWindow.setVisible(false); - history.setEditable(false); - inputLine.addKeyListener(this); + remove(splitPane); + add(renderPanel, BorderLayout.CENTER); + splitPane = null; } - - scriptWindow.setVisible(!scriptWindow.isVisible()); validate(); } @@ -574,4 +633,16 @@ public class AppletJmol extends EmbmenuFrame implements { jmb.setJalviewColourScheme(ucs); } + + public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment) + { + for (int i=0;i<_aps.size();i++) + { + if (((AlignmentPanel)_aps.get(i)).av.getAlignment()==alignment) + { + return ((AlignmentPanel)_aps.get(i)); + } + } + return ap; + } }