import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.BufferedReader;
import javax.swing.JColorChooser;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
-import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
public class AppJmol extends StructureViewerBase
{
+ // ms to wait for Jmol to load files
+ private static final int JMOL_LOAD_TIMEOUT = 20000;
+
private static final String SPACE = " ";
private static final String BACKSLASH = "\"";
// / TODO: check if protocol is needed to be set, and if chains are
// autodiscovered.
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
- pdbentrys, seqs, null, null);
+ pdbentrys, seqs, null);
jmb.setLoadingFromArchive(true);
addAlignmentPanel(ap);
{
progressBar = ap.alignFrame;
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
- pdbentrys, seqs, null, null);
+ pdbentrys, seqs, null);
addAlignmentPanel(ap);
useAlignmentPanelForColourbyseq(ap);
if (pdbentrys.length > 1)
jmb.setColourBySequence(true);
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
- worker = null;
- {
- addingStructures = false;
- worker = new Thread(this);
- worker.start();
- }
+ addingStructures = false;
+ worker = new Thread(this);
+ worker.start();
+
this.addInternalFrameListener(new InternalFrameAdapter()
{
@Override
scriptWindow.setVisible(false);
}
- /*
- * -i for no info logging (less verbose)
- */
- jmb.allocateViewer(renderPanel, true, "", null, null, "-i",
+ jmb.allocateViewer(renderPanel, true, "", null, null, "",
scriptWindow, null);
// jmb.newJmolPopup("Jmol");
if (command == null)
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector<String> chains)
- {
- chainMenu.removeAll();
- if (chains == null)
- {
- return;
- }
- JMenuItem menuItem = new JMenuItem(
- MessageManager.getString("label.all"));
- menuItem.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- allChainsSelected = true;
- for (int i = 0; i < chainMenu.getItemCount(); i++)
- {
- if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
- {
- ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
- }
- }
- centerViewer();
- allChainsSelected = false;
- }
- });
- chainMenu.add(menuItem);
-
- for (String chain : chains)
- {
- menuItem = new JCheckBoxMenuItem(chain, true);
- menuItem.addItemListener(new ItemListener()
- {
- @Override
- public void itemStateChanged(ItemEvent evt)
- {
- if (!allChainsSelected)
- {
- centerViewer();
- }
- }
- });
-
- chainMenu.add(menuItem);
- }
- }
boolean allChainsSelected = false;
- void centerViewer()
+ @Override
+ void showSelectedChains()
{
Vector<String> toshow = new Vector<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
StringBuilder fileList = new StringBuilder();
for (String s : files)
{
- fileList.append(SPACE).append(BACKSLASH).append(Platform.escapeString(s))
- .append(BACKSLASH);
+ fileList.append(SPACE).append(BACKSLASH)
+ .append(Platform.escapeString(s)).append(BACKSLASH);
}
String filesString = fileList.toString();
jmb.evalStateCommand(command);
} catch (OutOfMemoryError oomerror)
{
- new OOMWarning(
- "When trying to add structures to the Jmol viewer!",
+ new OOMWarning("When trying to add structures to the Jmol viewer!",
oomerror);
Cache.log.debug("File locations are " + filesString);
} catch (Exception ex)
}
// need to wait around until script has finished
- int waitMax = 5000; // give up after 5 seconds
+ int waitMax = JMOL_LOAD_TIMEOUT;
int waitFor = 35;
int waitTotal = 0;
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
}
if (waitTotal > waitMax)
{
- System.err.println("Timed out waiting for Jmol to load files");
+ System.err
+ .println("Timed out waiting for Jmol to load files after "
+ + waitTotal + "ms");
+// System.err.println("finished: " + jmb.isFinishedInit()
+// + "; loaded: " + Arrays.toString(jmb.getPdbFile())
+// + "; files: " + files.toString());
+ jmb.getPdbFile();
break;
}
}
repaint();
return;
}
- setChainMenuItems(jmb.chainNames);
+ setChainMenuItems(jmb.getChainNames());
this.setTitle(jmb.getViewerTitle());
if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)