From: Egon W. <eg...@us...> - 2002-08-29 15:24:52
|
Update of /cvsroot/cdk/cdk/src/org/openscience/cdk/applications In directory usw-pr-cvs1:/tmp/cvs-serv14998/src/org/openscience/cdk/applications Modified Files: PublicJmol.java Viewer.java Log Message: More code cleanup. Index: PublicJmol.java =================================================================== RCS file: /cvsroot/cdk/cdk/src/org/openscience/cdk/applications/PublicJmol.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** PublicJmol.java 29 Aug 2002 15:13:40 -0000 1.5 --- PublicJmol.java 29 Aug 2002 15:24:48 -0000 1.6 *************** *** 97,112 **** public class PublicJmol extends JPanel { ! private JScrollPane scroller; ! private JViewport port; static DisplayPanel display; static AtomTypeTable atomTypeTable; - protected static JFrame frame; - private ChemFile chemFile; - - /** - * Button group for toggle buttons in the toolbar. - */ - ButtonGroup toolbarButtonGroup = new ButtonGroup(); - static File UserPropsFile; static File UserAtypeFile; --- 97,104 ---- public class PublicJmol extends JPanel { ! public static final String moleculeProperty = "molecule"; ! static DisplayPanel display; static AtomTypeTable atomTypeTable; static File UserPropsFile; static File UserAtypeFile; *************** *** 114,123 **** Splash splash; ! private static JFrame consoleframe; ! protected DisplaySettings settings = new DisplaySettings(); ! /** The name of the currently open file **/ ! public String currentFileName = ""; static { --- 106,115 ---- Splash splash; ! protected static JFrame frame; protected DisplaySettings settings = new DisplaySettings(); ! private JScrollPane scroller; ! private JViewport port; ! private ChemFile chemFile; static { *************** *** 127,132 **** System.exit(1); } ! File ujmoldir = new File(new File(System.getProperty("user.home")), ! ".jmol"); ujmoldir.mkdirs(); UserPropsFile = new File(ujmoldir, "properties"); --- 119,123 ---- System.exit(1); } ! File ujmoldir = new File(new File(System.getProperty("user.home")), ".jmol"); ujmoldir.mkdirs(); UserPropsFile = new File(ujmoldir, "properties"); *************** *** 140,147 **** splash.showStatus("Initializing Swing..."); try { ! UIManager ! .setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception exc) { ! System.err.println("Error loading L&F: " + exc); } --- 131,137 ---- splash.showStatus("Initializing Swing..."); try { ! UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception exc) { ! System.err.println("Error loading L&F: " + exc); } *************** *** 159,163 **** port.setBackingStoreEnabled(bs.booleanValue()); } catch (MissingResourceException mre) { - // just use the viewport default } --- 149,152 ---- *************** *** 169,173 **** JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); - // panel.add("North", createToolbar()); JPanel ip = new JPanel(); --- 158,161 ---- *************** *** 176,180 **** panel.add("Center", ip); add("Center", panel); - // add("South", status); splash.showStatus("Starting display..."); --- 164,167 ---- *************** *** 196,205 **** frame.getContentPane().add("Center", window); frame.pack(); ! frame.setSize(400, 400); frame.show(); return window; } ! // transfer molecule to Jmol as native object public void showChemFrame(ChemFrame cf) { ChemFile file = new ChemFile(); --- 183,194 ---- frame.getContentPane().add("Center", window); frame.pack(); ! frame.setSize(500, 500); frame.show(); return window; } ! /** ! * Transfer molecule to Jmol as native object ! */ public void showChemFrame(ChemFrame cf) { ChemFile file = new ChemFile(); *************** *** 247,311 **** } return null; - } - - private class ActionChangedListener implements PropertyChangeListener { - - AbstractButton button; - - ActionChangedListener(AbstractButton button) { - super(); - this.button = button; - } - - public void propertyChange(PropertyChangeEvent e) { - - String propertyName = e.getPropertyName(); - if (e.getPropertyName().equals(Action.NAME)) { - String text = (String) e.getNewValue(); - if (button.getText() != null) { - button.setText(text); - } - } else if (propertyName.equals("enabled")) { - Boolean enabledState = (Boolean) e.getNewValue(); - button.setEnabled(enabledState.booleanValue()); - } - } - } - - /** - * Returns a new File referenced by the property 'user.dir', or null - * if the property is not defined. - * - * @return a File to the user directory - */ - static File getUserDirectory() { - if (System.getProperty("user.dir") == null) { - return null; - } - return new File(System.getProperty("user.dir")); - } - - public static final String moleculeProperty = "molecule"; - - private abstract class MoleculeDependentAction extends AbstractAction - implements PropertyChangeListener { - - public MoleculeDependentAction(String name) { - super(name); - setEnabled(false); - } - - public void propertyChange(PropertyChangeEvent event) { - - if (event.getSource() instanceof PublicJmol) { - PublicJmol jmol = (PublicJmol) event.getSource(); - if (jmol.hasMolecule()) { - setEnabled(true); - } else { - setEnabled(false); - } - } - } - } --- 236,239 ---- Index: Viewer.java =================================================================== RCS file: /cvsroot/cdk/cdk/src/org/openscience/cdk/applications/Viewer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** Viewer.java 29 Aug 2002 15:13:41 -0000 1.9 --- Viewer.java 29 Aug 2002 15:24:49 -0000 1.10 *************** *** 89,94 **** org.openscience.jmol.PublicJmol jmol = org.openscience.jmol.PublicJmol.getJmol(frame); jmol.showChemFrame(Convertor.convert(m)); - // frame.setSize(400, 400); - // frame.show(); frame.getContentPane().add(jmol, BorderLayout.CENTER); --- 89,92 ---- *************** *** 136,143 **** } frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); ! // if (!useJmol) { ! frame.setSize(500,500); ! frame.setVisible(true); ! // } frame.addWindowListener(new AppCloser()); } --- 134,139 ---- } frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); ! frame.setSize(500,500); ! frame.setVisible(true); frame.addWindowListener(new AppCloser()); } |