- final Set<PDBEntry> pdbEntries = toView.keySet();
- PDBEntry[] pdbs = pdbEntries.toArray(new PDBEntry[pdbEntries.size()]);
- SequenceI[][] seqsForPdbs = new SequenceI[pdbEntries.size()][];
- for (int i = 0; i < pdbs.length; i++)
- {
- final List<SequenceI> seqsForPdb = toView.get(pdbs[i]);
- seqsForPdbs[i] = seqsForPdb.toArray(new SequenceI[seqsForPdb.size()]);
- }
-
- openNewChimera(alignPanel, pdbs, seqsForPdbs);
- }
-
- /**
- * add a new structure (with associated sequences and chains) to this viewer,
- * retrieving it if necessary first.
- *
- * @param pdbentry
- * @param seq
- * @param chains
- * @param alignFrame
- * @param align
- * if true, new structure(s) will be align using associated alignment
- */
- private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
- final String[] chains, final boolean b,
- final IProgressIndicator alignFrame)
- {
- if (pdbentry.getFile() == null)
- {
- if (worker != null && worker.isAlive())
- {
- // a retrieval is in progress, wait around and add ourselves to the
- // queue.
- new Thread(new Runnable()
- {
- public void run()
- {
- while (worker != null && worker.isAlive() && _started)
- {
- try
- {
- Thread.sleep(100 + ((int) Math.random() * 100));
-
- } catch (Exception e)
- {
- }
-
- }
- // and call ourselves again.
- addStructure(pdbentry, seq, chains, b, alignFrame);
- }
- }).start();
- return;
- }
- }
- // otherwise, start adding the structure.
- jmb.addSequenceAndChain(new PDBEntry[]
- { pdbentry }, new SequenceI[][]
- { seq }, new String[][]
- { chains });
- addingStructures = true;
- _started = false;
- alignAddedStructures = b;
- // progressBar = alignFrame; // visual indication happens on caller frame.
- (worker = new Thread(this)).start();
- return;
- }
-
- private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
- {
- List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
- JInternalFrame[] frames = Desktop.instance.getAllFrames();
-
- for (JInternalFrame frame : frames)
- {
- if (frame instanceof ChimeraViewFrame)
- {
- if (((StructureViewerBase) frame).isLinkedWith(apanel))
- {
- result.add((ChimeraViewFrame) frame);
- }
- }
- }
- return result;