+ // //////
+ // test and embed menu bar if necessary.
+ //
+ if (embedMenuIfNeeded(alignPanel))
+ {
+ // adjust for status bar height too
+ alignPanel.setSize(getSize().width, getSize().height
+ - statusBar.HEIGHT);
+ }
+ add(statusBar, BorderLayout.SOUTH);
+ add(alignPanel, BorderLayout.CENTER);
+ // and register with the applet so it can pass external API calls to us
+ jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT);
+ }
+ }
+
+ /**
+ * create a new binding between structures in an existing jmol viewer instance
+ * and an alignpanel with sequences that have existing PDBFile entries. Note,
+ * this does not open a new Jmol window, or modify the display of the
+ * structures in the original jmol window. Note
+ *
+ * @param viewer
+ * JmolViewer instance
+ * @param sequenceIds
+ * - sequence Ids to search for associations This method doesn't
+ * work. See http://issues.jalview.org/browse/JAL-621
+ *
+ * public SequenceStructureBinding addStructureViewInstance(Object
+ * jmolviewer, String[] sequenceIds) { org.jmol.api.JmolViewer
+ * viewer=null; try { viewer = (org.jmol.api.JmolViewer) jmolviewer;
+ * } catch (ClassCastException ex) {
+ * System.err.println("Unsupported viewer object :"
+ * +jmolviewer.getClass()); } if (viewer==null) {
+ * System.err.println("Can't use this object as a structure viewer:"
+ * +jmolviewer.getClass()); return null; } SequenceI[] seqs=null; if
+ * (sequenceIds==null || sequenceIds.length==0) { seqs =
+ * viewport.getAlignment().getSequencesArray(); } else { Vector
+ * sqi=new Vector(); AlignmentI al = viewport.getAlignment(); for
+ * (int sid=0;sid<sequenceIds.length;sid++) { SequenceI sq =
+ * al.findName(sequenceIds[sid]); if (sq!=null) { sqi.addElement(sq);
+ * } } if (sqi.size()>0) { seqs = new SequenceI[sqi.size()]; for (int
+ * sid=0,sSize=sqi.size();sid<sSize;sid++) { seqs[sid] = (SequenceI)
+ * sqi.elementAt(sid); } } else { return null; } } ExtJmol jmv=null;
+ * // TODO: search for a jmv that involves viewer if (jmv==null){ //
+ * create a new viewer/jalview binding. jmv = new ExtJmol(viewer,
+ * alignPanel, seqs); } return jmv;
+ *
+ * }
+ **/
+ public boolean addPdbFile(String sequenceId, String pdbEntryString,
+ String pdbFile)
+ {
+ SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId);
+ boolean needtoadd = false;
+ if (toaddpdb != null)
+ {
+ Vector pdbe = toaddpdb.getPDBId();
+ PDBEntry pdbentry = null;
+ if (pdbe != null && pdbe.size() > 0)
+ {
+ for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++)
+ {
+ pdbentry = (PDBEntry) pdbe.elementAt(pe);
+ if (!pdbentry.getId().equals(pdbEntryString)
+ && !pdbentry.getFile().equals(pdbFile))
+ {
+ pdbentry = null;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+ if (pdbentry == null)
+ {
+ pdbentry = new PDBEntry();
+ pdbentry.setId(pdbEntryString);
+ pdbentry.setFile(pdbFile);
+ needtoadd = true; // add this new entry to sequence.
+ }
+ // resolve data source
+ // TODO: this code should be a refactored to an io package
+ String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB");
+ if (protocol == null)
+ {
+ return false;
+ }
+ if (needtoadd)
+ {
+ // make a note of the access mode and add
+ if (pdbentry.getProperty() == null)
+ {
+ pdbentry.setProperty(new Hashtable());
+ }
+ pdbentry.getProperty().put("protocol", protocol);
+ toaddpdb.addPDBId(pdbentry);
+ }