Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IReaction


   
    public void setChemObject(IChemObject object) {
        if (object instanceof IReaction) {
            source = object;    
            // update table contents
            IReaction reaction = (IReaction)source;
            idField.setText(reaction.getID());
            //TODO
            //directionField.setSelectedIndex(reaction.getDirection());
            solventField.setText((String)reaction.getProperty(SOLVENT));
            tempField.setText((String)reaction.getProperty(TEMPERATURE));
        } else {
            throw new IllegalArgumentException("Argument must be an Reaction");
        }
    }
View Full Code Here


            throw new IllegalArgumentException("Argument must be an Reaction");
        }
    }
 
    public void applyChanges() {
        IReaction reaction = (IReaction)source;
        reaction.setID(idField.getText());
        //TODO
        //reaction.setDirection(directionField.getSelectedIndex());
        reaction.setProperty(SOLVENT, solventField.getText());
        reaction.setProperty(TEMPERATURE, tempField.getText());
    }
View Full Code Here

                logger.warn("Cannot select everything in : ", object);
            }
        } else if (type.equals("selectReactionReactants")) {
            IChemObject object = getSource(e);
            if (object instanceof IReaction) {
                IReaction reaction = (IReaction) object;
                IAtomContainer wholeModel =
                    jcpPanel.getChemModel().getBuilder().newInstance(IAtomContainer.class);
                for (IAtomContainer container :
                    MoleculeSetManipulator.getAllAtomContainers(
                            reaction.getReactants())) {
                        wholeModel.add(container);
                }
                ShapeSelection container = new RectangleSelection();
                for (IAtom atom : wholeModel.atoms()) {
                    container.atoms.add(atom);
                }
                for (IBond bond : wholeModel.bonds()) {
                    container.bonds.add(bond);
                }
                renderModel.setSelection(container);
            }
            else {
                logger.warn("Cannot select reactants from : ", object);
            }
        } else if (type.equals("selectReactionProducts")) {
            IChemObject object = getSource(e);
            if (object instanceof IReaction) {
                    IReaction reaction = (IReaction) object;
                    IAtomContainer wholeModel =
                        jcpPanel.getChemModel().getBuilder().newInstance(IAtomContainer.class);
                for (IAtomContainer container :
                    MoleculeSetManipulator.getAllAtomContainers(
                            reaction.getProducts())) {
                        wholeModel.add(container);
                }
                ShapeSelection container = new RectangleSelection();
                for (IAtom atom : wholeModel.atoms()) {
                    container.atoms.add(atom);
View Full Code Here

    this.reactantOrProduct = reactantOrProduct;
  }

  public void redo() {
    chemModel.getMoleculeSet().removeAtomContainer(movedContainer);
    IReaction reaction = chemModel.getBuilder().newInstance(IReaction.class);
    reaction.setID(reactionID);
    IAtomContainer mol=chemModel.getBuilder().newInstance(IAtomContainer.class,movedContainer);
    mol.setID(movedContainer.getID());
    if(reactantOrProduct)
      reaction.addReactant(mol);
    else
      reaction.addProduct(mol);
    if(chemModel.getReactionSet()==null)
      chemModel.setReactionSet(chemModel.getBuilder().newInstance(IReactionSet.class));
    chemModel.getReactionSet().addReaction(reaction);
    chemModel.getMoleculeSet().removeAtomContainer(oldContainer);
  }
View Full Code Here

        IReactionSet reactionSet = super.chemModelRelay.getChemModel().getReactionSet();
        if (reactionSet == null) {
            reactionSet = new ReactionChain(); //reactionSet = super.chemModelRelay.getChemModel().getBuilder().newInstance(IReactionSet.class);
            super.chemModelRelay.getChemModel().setReactionSet(reactionSet);
        }
        IReaction reaction = moleculeSet.getBuilder().newInstance(IReaction.class);
        ((ReactionChain) reactionSet).addReaction(reaction, reactionSet.getReactionCount()); //reactionSet.addReaction(reaction);
        reaction.setID(ReactionHub.newReactionId(chemModelRelay));
       
        for (IAtomContainer reactant : reactants) {
            ReactionHub.makeReactantInExistingReaction((ControllerHub) super.chemModelRelay,
                                                       reaction.getID(),
                                                       cloneReactionParticipant(reactant),
                                                       reactant);
        }
        for (IAtomContainer product : products) {
            ReactionHub.makeProductInExistingReaction((ControllerHub) super.chemModelRelay,
                                                      reaction.getID(),
                                                      cloneReactionParticipant(product),
                                                      product);
        }
       
       
View Full Code Here

public class ReactionHub {


    public static void makeReactantInNewReaction(ControllerHub controllerhub, IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = newContainer.getBuilder().newInstance(IReaction.class);
        reaction.setID(newReactionId(controllerhub));
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addReactant(mol);
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet == null)
        {
            reactionSet = chemModel.getBuilder().newInstance(IReactionSet.class);
        }
View Full Code Here

     * @see org.openscience.cdk.controller.IChemModelRelay#makeReactantInExistingReaction(java.lang.String, org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.interfaces.IAtomContainer)
     */
    public static void makeReactantInExistingReaction(ControllerHub controllerhub, String reactionId,
            IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = ReactionSetManipulator.getReactionByReactionID(chemModel.getReactionSet(), reactionId);
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addReactant(mol);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInExistingReactionEdit(chemModel, newContainer, oldcontainer, reactionId, true, "Make Reactant in "+reactionId);
View Full Code Here

    }

    public static void makeProductInNewReaction(ControllerHub controllerhub, IAtomContainer newContainer,
            IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = newContainer.getBuilder().newInstance(IReaction.class);
        reaction.setID(newReactionId(controllerhub));
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addProduct(mol);
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet == null)
        {
            reactionSet = chemModel.getBuilder().newInstance(IReactionSet.class);
        }
View Full Code Here

     * @see org.openscience.cdk.controller.IChemModelRelay#makeProductInExistingReaction(java.lang.String, org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.interfaces.IAtomContainer)
     */
    public static void makeProductInExistingReaction(ControllerHub controllerhub, String reactionId,
            IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = ReactionSetManipulator.getReactionByReactionID(chemModel.getReactionSet(), reactionId);
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addProduct(mol);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInExistingReactionEdit(chemModel, newContainer, oldcontainer, reactionId, false, "Make Reactant in "+reactionId);
View Full Code Here

    if(closestAtom != null && closestAtom.getPoint2d().distance(worldCoord) < dH)
      endAtom = chemModelRelay.getClosestAtom(worldCoord);
    if(endAtom!=null && startAtom!=null){
      IMapping mapping = startAtom.getBuilder().newInstance(IMapping.class,startAtom, endAtom);
      // ok, now figure out if they are in one reaction
      IReaction reaction1 = ChemModelManipulator.getRelevantReaction(chemModelRelay.getIChemModel(), startAtom);
      IReaction reaction2 = ChemModelManipulator.getRelevantReaction(chemModelRelay.getIChemModel(), endAtom);
      if (reaction1 != null && reaction2 != null && reaction1 == reaction2)
      {
        ((IReaction)reaction1).addMapping(mapping);
      }else{
        //TODO what to do? message box? that would be a swing component
View Full Code Here

TOP

Related Classes of org.openscience.cdk.interfaces.IReaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.