-
-
-
- static class JmolPanel
- extends JPanel implements JmolSelectionListener
- {
- JmolViewer viewer;
- JmolAdapter adapter;
- JmolPanel()
- {
- adapter = new SmarterJmolAdapter(null);
- viewer = org.jmol.viewer.Viewer.allocateViewer(this, adapter);
- viewer.addSelectionListener(this);
-
- MyStatusListener myStatusListener;
- myStatusListener = new MyStatusListener();
- viewer.setJmolStatusListener(myStatusListener);
-
- JFrame frame = new JFrame("script window");
- // scriptWindow = new ScriptWindow(viewer, frame);
-
- myStatusListener.jmolpopup = JmolPopup.newJmolPopup(viewer);
- }
- public ScriptWindow scriptWindow;
- class MyStatusListener implements JmolStatusListener
- {
-
- JmolPopup jmolpopup ;
-
-
- public String eval(String strEval) {
- return "# 'eval' is implemented only for the applet.";
- }
-
- public void createImage(String file, String type, int quality) {
- System.out.println("CREATE IMAGE");
- // ImageCreator c = new ImageCreator(viewer, status);
- // c.createImage(file, type, quality);
- }
-
- public void setCallbackFunction(String callbackType, String callbackFunction) {
- // applet only?
- }
-
- public void notifyFileLoaded(String fullPathName, String fileName,
- String modelName, Object clientFile,
- String errorMsg) {
-
- }
-
- public void notifyFrameChanged(int frameNo) {
- // Note: twos-complement. To get actual frame number, use
- // Math.max(frameNo, -2 - frameNo)
- // -1 means all frames are now displayed
-
- boolean isAnimationRunning = (frameNo <= -2);
-
- }
-
- public void notifyScriptStart(String statusMessage, String additionalInfo) {
- //System.out.println("notifyScriptStart:" + statusMessage + (additionalInfo == "" ? "" : additionalInfo));
- }
-
- public void sendConsoleEcho(String strEcho) {
- if (scriptWindow != null)
- scriptWindow.sendConsoleEcho(strEcho);
- }
-
- public void sendConsoleMessage(String strStatus) {
- if (scriptWindow != null)
- scriptWindow.sendConsoleMessage(strStatus);
- }
-
- public void notifyScriptTermination(String strStatus, int msWalltime) {
- if (scriptWindow != null)
- scriptWindow.notifyScriptTermination(strStatus, msWalltime);
- }
-
- public void handlePopupMenu(int x, int y) {
- jmolpopup.show(x, y);
- }
-
- public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) {
- notifyAtomPicked(iatom, strMeasure);
- }
-
- public void notifyNewDefaultModeMeasurement(int count, String strInfo) {
- // measurementTable.updateTables();
- }
-
- public void notifyAtomPicked(int atomIndex, String strInfo) {
-
- System.out.println("ATOM PICKED "+atomIndex+" "+strInfo);
- if (scriptWindow != null) {
- scriptWindow.sendConsoleMessage(strInfo);
- scriptWindow.sendConsoleMessage("\n");
- }
- }
-
- public void notifyAtomHovered(int atomIndex, String strInfo) {
-System.out.println("HOVER "+atomIndex+" "+strInfo);
- }
-
- public void sendSyncScript(String script, String appletName) {
- }
-
- public void showUrl(String url) {
- }
-
- public void showConsole(boolean showConsole) {
- System.out.println("SHOW CONSOLE" +(scriptWindow==null));
- if (scriptWindow == null)
- return;
- if (showConsole)
- scriptWindow.show();
- else
- scriptWindow.hide();
- }
-
- public float functionXY(String functionName, int x, int y) {
- return 0; // for user-defined isosurface functions (testing only -- bob hanson)
- }
-
- }
-
-
- class ScriptWindowAction extends AbstractAction {
-
- public ScriptWindowAction() {
- super("BLAH");
- }
-
- public void actionPerformed(ActionEvent e) {
- if (scriptWindow != null)
- scriptWindow.show();
- }
- }
-
- /**
- * Called when the selected atoms change
- * @param selection bit set giving selection of atom indexes
- */
- public void selectionChanged(BitSet selection)
- {
- System.out.println("SELECTION: "+selection);
- }
-
-
- public JmolSimpleViewer getViewer()
- {
- return viewer;
- }
-
- final Dimension currentSize = new Dimension();
- final Rectangle rectClip = new Rectangle();
-
- public void paint(Graphics g)
- {
-
- getSize(currentSize);
- g.getClipBounds(rectClip);
- viewer.renderScreenImage(g, currentSize, rectClip);
- }
- }
-
-