From: <sh...@us...> - 2008-12-12 10:31:56
|
Revision: 13544 http://cdk.svn.sourceforge.net/cdk/?rev=13544&view=rev Author: shk3 Date: 2008-12-12 10:31:51 +0000 (Fri, 12 Dec 2008) Log Message: ----------- more actions Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JChemPaintResources.properties Added Paths: ----------- jchempaint/trunk/src/main/org/openscience/jchempaint/action/AdjustBondOrdersAction.java Added: jchempaint/trunk/src/main/org/openscience/jchempaint/action/AdjustBondOrdersAction.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/action/AdjustBondOrdersAction.java (rev 0) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/action/AdjustBondOrdersAction.java 2008-12-12 10:31:51 UTC (rev 13544) @@ -0,0 +1,103 @@ +/* + * $RCSfile$ + * $Author: egonw $ + * $Date: 2007-01-04 17:26:00 +0000 (Thu, 04 Jan 2007) $ + * $Revision: 7634 $ + * + * Copyright (C) 1997-2008 Christoph Steinbeck, Stefan Kuhn + * + * Contact: cdk...@li... + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * All we ask is that proper credit is given for our work, which includes + * - but is not limited to - adding the above copyright notice to the beginning + * of your source code files, and to any copyright notice that you may distribute + * with programs based on this work. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.openscience.jchempaint.action; + +import java.awt.event.ActionEvent; +import java.util.Iterator; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.openscience.cdk.ChemModel; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.interfaces.IBond; +import org.openscience.cdk.interfaces.IBond.Order; +import org.openscience.cdk.tools.SaturationChecker; +import org.openscience.cdk.tools.manipulator.ChemModelManipulator; + + +/** + * Triggers the adjustment of BondOrders + * + */ +public class AdjustBondOrdersAction extends JCPAction +{ + + private static final long serialVersionUID = -2930750443449102916L; + + public void actionPerformed(ActionEvent e) + { + ChemModel model = (ChemModel) jcpPanel.getChemModel(); + logger.debug("Adjusting bondorders: ", type); + if (type.equals("clear")) + { + try + { + SaturationChecker satChecker = new SaturationChecker(); + List containersList = ChemModelManipulator.getAllAtomContainers(model); + Iterator iterator = containersList.iterator(); + while(iterator.hasNext()) + { + IAtomContainer ac = (IAtomContainer)iterator.next(); + for(IBond bond : ac.bonds()) { + bond.setOrder(Order.SINGLE); + } + } + jcpPanel.get2DHub().updateView(); + } catch (Exception exc) + { + String error = "Could not adjust bondorders."; + logger.error(error); + logger.debug(exc); + JOptionPane.showMessageDialog(jcpPanel, error); + } + } else + { + try + { + SaturationChecker satChecker = new SaturationChecker(); + List containersList = ChemModelManipulator.getAllAtomContainers(model); + Iterator iterator = containersList.iterator(); + while(iterator.hasNext()) + { + IAtomContainer ac = (IAtomContainer)iterator.next(); + satChecker.saturate(ac); + } + jcpPanel.get2DHub().updateView(); + } catch (Exception exc) + { + String error = "Could not adjust bondorders."; + logger.error(error); + logger.debug(exc); + JOptionPane.showMessageDialog(jcpPanel, error); + } + } + } +} + Property changes on: jchempaint/trunk/src/main/org/openscience/jchempaint/action/AdjustBondOrdersAction.java ___________________________________________________________________ Added: svn:executable + * Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JChemPaintResources.properties =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JChemPaintResources.properties 2008-12-11 17:46:45 UTC (rev 13543) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/resources/JChemPaintResources.properties 2008-12-12 10:31:51 UTC (rev 13544) @@ -98,8 +98,8 @@ addImplHydrogenAction=org.openscience.cdk.applications.jchempaint.action.AddHydrogenAction@implicit makeHydrogenExplicitAction=org.openscience.cdk.applications.jchempaint.action.AddHydrogenAction@explicit makeHydrogenImplicitAction=org.openscience.cdk.applications.jchempaint.action.AddHydrogenAction@allimplicit -adjustBondOrdersAction=org.openscience.cdk.applications.jchempaint.action.AdjustBondOrdersAction -resetBondOrdersAction=org.openscience.cdk.applications.jchempaint.action.AdjustBondOrdersAction@clear +adjustBondOrdersAction=org.openscience.jchempaint.action.AdjustBondOrdersAction +resetBondOrdersAction=org.openscience.jchempaint.action.AdjustBondOrdersAction@clear cleanupAction=org.openscience.jchempaint.action.CleanupAction modelPropsAction=org.openscience.cdk.applications.jchempaint.action.ModelPropsAction editDictRefAction=org.openscience.cdk.applications.jchempaint.action.EditDictRefsAction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |