Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IReactionSet


*/
public class BoundsCalculator {

  public static Rectangle2D calculateBounds(IChemModel chemModel) {
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        IReactionSet reactionSet = chemModel.getReactionSet();
        Rectangle2D totalBounds = null;
        if (moleculeSet != null) {
            totalBounds = calculateBounds(moleculeSet);
        }

View Full Code Here


    }
   
    private static void setReactionIDs(IChemModel chemModel) {
        // we give all reactions an ID, in case they have none
        // IDs are needed for handling in JCP
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet != null) {
            int i = 0;
            for (IReaction reaction : reactionSet.reactions()) {
                if (reaction.getID() == null)
                    reaction.setID("Reaction " + (++i));
            }
        }
    }
View Full Code Here

        }
    }

    private static void removeDuplicateMolecules(IChemModel chemModel) {
        // we remove molecules which are in MoleculeSet as well as in a reaction
        IReactionSet reactionSet = chemModel.getReactionSet();
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        if (reactionSet != null && moleculeSet != null) {
            List<IAtomContainer> aclist = ReactionSetManipulator
                    .getAllAtomContainers(reactionSet);
            for (int i = moleculeSet.getAtomContainerCount() - 1; i >= 0; i--) {
View Full Code Here

     */
    public Rectangle paintChemModel(
            IChemModel chemModel, IDrawVisitor drawVisitor) {

        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        IReactionSet reactionSet = chemModel.getReactionSet();

        if (moleculeSet == null && reactionSet != null) {
            return paintReactionSet(reactionSet, drawVisitor);
        }

        if (moleculeSet != null && reactionSet == null) {
            return paintMoleculeSet(moleculeSet, drawVisitor);
        }

        if (moleculeSet != null && moleculeSet.getAtomContainerCount() > 0 && reactionSet != null) {
            Rectangle2D reactionSetBounds = Renderer.calculateBounds(reactionSet);
            Rectangle2D moleculeSetBounds = Renderer.calculateBounds(moleculeSet);
           
            Rectangle2D totalBounds = new Rectangle2D.Double();
           
            if (reactionSetBounds != null && moleculeSetBounds != null) {
                Rectangle.union(reactionSetBounds, moleculeSetBounds, totalBounds);
            } else if (reactionSetBounds != null) {
                totalBounds = reactionSetBounds;
            } else if (moleculeSetBounds != null) {
                totalBounds = moleculeSetBounds;
            }
           
            this.setupTransformNatural(totalBounds);
            ElementGroup diagram = new ElementGroup();
            for (IReaction reaction : reactionSet.reactions()) {
                diagram.add(this.generateDiagram(reaction));
            }
            diagram.add(this.generateDiagram(moleculeSet));
            diagram.add(this.generateDiagram(reactionSet));
            this.paint(drawVisitor, diagram);
View Full Code Here

     */
    public void paintChemModel(IChemModel chemModel,
            IDrawVisitor drawVisitor, Rectangle2D bounds, boolean resetCenter) {
        // check for an empty model
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        IReactionSet reactionSet = chemModel.getReactionSet();

        // nasty, but it seems that reactions can be read in as ChemModels
        // with BOTH a ReactionSet AND a MoleculeSet...
        if (moleculeSet == null || reactionSet != null) {
            if (reactionSet != null) {
View Full Code Here

     * @param model the model to draw.
     * @return a rectangle in screen space.
     */
    public Rectangle calculateDiagramBounds(IChemModel model) {
        IAtomContainerSet moleculeSet = model.getMoleculeSet();
        IReactionSet reactionSet = model.getReactionSet();
        if ((moleculeSet == null && reactionSet == null)) {
            return new Rectangle();
        }

        Rectangle2D moleculeBounds = null;
View Full Code Here

                Renderer.calculateBounds(moleculeSet));
    }

    public static Rectangle2D calculateBounds(IChemModel chemModel) {
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        IReactionSet reactionSet = chemModel.getReactionSet();
        Rectangle2D totalBounds = null;
        if (moleculeSet != null) {
            totalBounds = Renderer.calculateBounds(moleculeSet);
        }
View Full Code Here

    public static double calculateAverageBondLength(IChemModel model) {

        // empty models have to have a scale
        IAtomContainerSet moleculeSet = model.getMoleculeSet();
        if (moleculeSet == null) {
            IReactionSet reactionSet = model.getReactionSet();
            if (reactionSet != null) {
                return Renderer.calculateAverageBondLength(reactionSet);
            }
            return 0.0;
        }
View Full Code Here

   
    if (objectInRange == null)
      objectInRange = rendererModel.getHighlightedBond();
   
    //look if we are in a reaction box
    IReactionSet reactionSet =
        rendererPanel.getChemModel().getReactionSet();
   
    if (objectInRange == null && reactionSet != null
                && reactionSet.getReactionCount() > 0) {
     
      for(int i=0;i<reactionSet.getReactionCount();i++){
        Rectangle reactionbounds =
            renderer.calculateDiagramBounds(reactionSet.getReaction(i));
        if (reactionbounds.contains(mouseCoords.x, mouseCoords.y))
          objectInRange = reactionSet.getReaction(i);
      }
    }
   
    if (objectInRange == null)
      objectInRange = chemModelRelay.getIChemModel();
View Full Code Here

  {
    IChemObject object = getSource(event);

    logger.debug("CreateReaction action");
    IChemModel model = jcpPanel.getChemModel();
    IReactionSet reactionSet = model.getReactionSet();
    if (reactionSet == null)
    {
      reactionSet = model.getBuilder().newInstance(IReactionSet.class);
    }
    IAtomContainer container = null;
    if (object instanceof IAtom)
    {
      container = ChemModelManipulator.getRelevantAtomContainer(model, (IAtom) object);
    } else if(object instanceof IBond)
    {
      container = ChemModelManipulator.getRelevantAtomContainer(model, (IBond) object);
    } else
    {
      logger.error("Cannot add to reaction object of type: " + object.getClass().getName());
    }
    if (container == null)
    {
      logger.error("Cannot find container to add object to!");
    } else
    {
      IChemModelRelay hub = jcpPanel.get2DHub();
      IAtomContainer newContainer;
      try {
        newContainer = (IAtomContainer) container.clone();
        if(container.getID()!=null)
          newContainer.setID(container.getID());
        else
          newContainer.setID("ac"+System.currentTimeMillis());
      } catch (CloneNotSupportedException e) {
        logger.error("Could not clone IAtomContainer: ", e.getMessage());
        logger.debug(e);
        return;
      }

      logger.debug("type: ", type);
      if ("addReactantToNew".equals(type))
      {
        ReactionHub.makeReactantInNewReaction((ControllerHub)hub, newContainer, container);
        //TODO this.jcpPanel.atomAtomMappingButton.setEnabled(true);
      } else if ("addReactantToExisting".equals(type))
      {
        if (reactionSet.getReactionCount() == 0)
        {
          logger.warn("Cannot add to reaction if no one exists");
          JOptionPane.showMessageDialog(jcpPanel, GT.get("No reaction existing. Cannot add therefore to something!"), GT.get("No existing reactions"), JOptionPane.WARNING_MESSAGE);
          return;
        } else
        {
          Object[] ids = getReactionIDs(reactionSet);
         
          String s = (String)ids[0];
          if(ids.length>1){
            s = (String) JOptionPane.showInputDialog(
              null,
              "Reaction Chooser",
              "Choose reaction to add reaction to",
              JOptionPane.PLAIN_MESSAGE,
              null,
              ids,
              ids[0]
              );
          }
          if ((s != null) && (s.length() > 0))
          {
              ReactionHub.makeReactantInExistingReaction((ControllerHub)hub, s, newContainer, container);
            //TODO this.jcpPanel.atomAtomMappingButton.setEnabled(true);
          } else
          {
            logger.error("No reaction selected");
          }
        }
      } else if ("addProductToNew".equals(type))
      {
          ReactionHub.makeProductInNewReaction((ControllerHub)hub, newContainer, container);
        //this.jcpPanel.atomAtomMappingButton.setEnabled(true);
      } else if ("addProductToExisting".equals(type))
      {
        if (reactionSet.getReactionCount() == 0)
        {
          logger.warn("Cannot add to reaction if no one exists");
          JOptionPane.showMessageDialog(jcpPanel, GT.get("No reaction existing. Cannot add therefore to something!"), GT.get("No existing reactions"), JOptionPane.WARNING_MESSAGE);
          return;
        } else
View Full Code Here

TOP

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

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.