Examples of IAtomContainerSet


Examples of org.openscience.cdk.interfaces.IAtomContainerSet

* @cdk.module renderbasic
*/
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

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

        return totalBounds;
    }

    public static Rectangle2D calculateBounds(IReaction reaction) {
        // get the participants in the reaction
        IAtomContainerSet reactants = reaction.getReactants();
        IAtomContainerSet products = reaction.getProducts();
        if (reactants == null || products == null) return null;

        // determine the bounds of everything in the reaction
        Rectangle2D reactantsBounds = calculateBounds(reactants);
        return reactantsBounds.createUnion(calculateBounds(products));
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

        // Smiles reading
        if (cor.accepts(IAtomContainerSet.class) && chemModel==null) {
            // try to read a Molecule set
            try {
                IAtomContainerSet som = (AtomContainerSet) cor.read(new AtomContainerSet());
                chemModel = new ChemModel();
                chemModel.setMoleculeSet(som);
                if (chemModel == null) {
                    error = "The object chemModel was empty unexpectedly!";
                }
            } catch (Exception exception) {
                error = "Error while reading file: " + exception.getMessage();
                exception.printStackTrace();
            }
        }

        // MDLV3000 reading
        if (cor.accepts(IAtomContainer.class) && chemModel==null) {
            // try to read a Molecule
                IAtomContainer mol = (AtomContainer) cor.read(new AtomContainer());
                if(mol!=null )
                    try{
                        IAtomContainerSet newSet = new AtomContainerSet();
                        newSet.addAtomContainer(mol);
                        chemModel = new ChemModel();
                        chemModel.setMoleculeSet(newSet);
                        if (chemModel == null) {
                            error = "The object chemModel was empty unexpectedly!";
                        }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

    public static void generateModel(AbstractJChemPaintPanel chemPaintPanel, IAtomContainer molecule, boolean generateCoordinates, boolean shiftPasted)
    throws CDKException {
        if (molecule == null) return;

        IChemModel chemModel = chemPaintPanel.getChemModel();
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        if (moleculeSet == null) {
            moleculeSet = new AtomContainerSet();
        }
       
        // On copy & paste on top of an existing drawn structure, prevent the
        // pasted section to be drawn exactly on top or to far away from the
        // original by shifting it to a fixed position next to it.

        if (shiftPasted) {
          double maxXCurr = Double.NEGATIVE_INFINITY;
            double minXPaste = Double.POSITIVE_INFINITY;

          for (IAtomContainer atc : moleculeSet.atomContainers()) {
              // Detect  the right border of the current structure..
              for (IAtom atom : atc.atoms()) {
                  if(atom.getPoint2d().x>maxXCurr)
                      maxXCurr = atom.getPoint2d().x;
              }
              // Detect the left border of the pasted structure..
              for (IAtom atom : molecule.atoms()) {
                  if(atom.getPoint2d().x<minXPaste)
                      minXPaste = atom.getPoint2d().x;
              }
            }

            if (maxXCurr != Double.NEGATIVE_INFINITY && minXPaste != Double.POSITIVE_INFINITY) {
            // Shift the pasted structure to be nicely next to the existing one.
            final int MARGIN=1;
            final double SHIFT = maxXCurr - minXPaste;
            for (IAtom atom : molecule.atoms()) {
                atom.setPoint2d(new Point2d (atom.getPoint2d().x+MARGIN+SHIFT, atom.getPoint2d().y ));
            }
            }
        }

        if(generateCoordinates){
            // now generate 2D coordinates
            StructureDiagramGenerator sdg = new StructureDiagramGenerator();
            sdg.setTemplateHandler(new TemplateHandler(moleculeSet.getBuilder()));
            try {
                sdg.setMolecule(molecule);
                sdg.generateCoordinates();
                molecule = sdg.getMolecule();
            } catch (Exception exc) {
                JOptionPane.showMessageDialog(chemPaintPanel, GT.get("Structure could not be generated"));
                throw new CDKException(
                        "Cannot depict structure");
            }
        }

        if(moleculeSet.getAtomContainer(0).getAtomCount()==0)
            moleculeSet.getAtomContainer(0).add(molecule);
        else
            moleculeSet.addAtomContainer(molecule);

        IUndoRedoFactory undoRedoFactory= chemPaintPanel.get2DHub().getUndoRedoFactory();
        UndoRedoHandler undoRedoHandler= chemPaintPanel.get2DHub().getUndoRedoHandler();
       
        if (undoRedoFactory!=null) {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

        // we make references in products/reactants clones, since same compounds
        // in different reactions need separate layout (different positions etc)
        if (chemModel.getReactionSet() != null) {
            for (IReaction reaction : chemModel.getReactionSet().reactions()) {
                int i = 0;
                IAtomContainerSet products = reaction.getProducts();
                for (IAtomContainer product : products.atomContainers()) {
                    try {
                        products.replaceAtomContainer(i,
                                (IAtomContainer) product.clone());
                    } catch (CloneNotSupportedException e) {
                    }
                    i++;
                }
                i = 0;
                IAtomContainerSet reactants = reaction.getReactants();
                for (IAtomContainer reactant : reactants.atomContainers()) {
                    try {
                        reactants.replaceAtomContainer(i,
                                (IAtomContainer) reactant.clone());
                    } catch (CloneNotSupportedException e) {
                    }
                    i++;
                }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

    }

    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--) {
                for (int k = 0; k < aclist.size(); k++) {
                    String label = moleculeSet.getAtomContainer(i).getID();
                    if (aclist.get(k).getID().equals(label)) {
                        chemModel.getMoleculeSet().removeAtomContainer(i);
                        break;
                    }
                }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

            }
        }
    }

    private static void removeEmptyMolecules(IChemModel chemModel) {
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        if (moleculeSet != null && moleculeSet.getAtomContainerCount() == 0) {
            chemModel.setMoleculeSet(null);
        }
    }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

                status = JCPMenuTextMaker.getInstance("applet").getText(mode);
            }
        } else if (position == 1) {
            // depict bruto formula
            IChemModel chemModel = hub.getIChemModel();
            IAtomContainerSet molecules = chemModel.getMoleculeSet();
            if (molecules != null && molecules.getAtomContainerCount() > 0) {
                Iterator<IAtomContainer> containers = ChemModelManipulator
                        .getAllAtomContainers(chemModel).iterator();
                int implicitHs = 0;
                while (containers.hasNext()) {
                    for (IAtom atom : containers.next().atoms()) {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

                        toPaste = sp.parseSmiles(
                                ((String) transfer.getTransferData(
                                        DataFlavor.stringFlavor)).trim());
                        toPaste = new FixBondOrdersTool().kekuliseAromaticRings(toPaste);

                        IAtomContainerSet mols = ConnectivityChecker.partitionIntoMolecules(toPaste);
                        for(int i=0;i<mols.getAtomContainerCount();i++)
                        {
                            StructureDiagramGenerator sdg =
                                new StructureDiagramGenerator((IAtomContainer)mols.getAtomContainer(i));

                            sdg.setTemplateHandler(
                                    new TemplateHandler(toPaste.getBuilder())
                            );
                            sdg.generateCoordinates();
View Full Code Here

Examples of org.openscience.cdk.interfaces.IAtomContainerSet

   
    public BoundsGenerator() {}
   
    public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
        ElementGroup elementGroup = new ElementGroup();
        IAtomContainerSet reactants = reaction.getReactants();
        if (reactants != null) {
            elementGroup.add(this.generate(reactants, model));
        }
       
        IAtomContainerSet products = reaction.getProducts();
        if (products != null) {
            elementGroup.add(this.generate(products, model));
        }
       
        return elementGroup;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.