Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtomContainer


            return selectionElements;
        if (this.autoUpdateSelection || selection.isFilled()) {
            double r = model.getSelectionRadius() / model.getScale();

            double d = 4 * r;
            IAtomContainer selectedAC = selection.getConnectedAtomContainer();
            if (selectedAC != null) {
                for (IAtom atom : selectedAC.atoms()) {
                    Point2d p = atom.getPoint2d();
                    IRenderingElement element;
                    element = new OvalElement(
                          p.x, p.y, d, false, selectionColor);
                    selectionElements.add(element);
View Full Code Here


        String svg;
        String cml;

        @SuppressWarnings("unchecked")
        public JcpSelection(IAtomContainer tocopy1) {
            IAtomContainer tocopy= tocopy1.getBuilder().newInstance(IAtomContainer.class,tocopy1);
            // MDL mol output
            StringWriter sw = new StringWriter();
            try {
        new MDLV2000Writer(sw).writeMolecule(tocopy);
      } catch (Exception e) {
View Full Code Here

        JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target;
        applet.button("C").click();
        applet.button("bondTool").click();
        applet.panel("renderpanel").robot.click(applet.panel("renderpanel").component(),new Point(100,100));
        applet.button("select").click();
    IAtomContainer ethane = panel.getChemModel().getMoleculeSet().getAtomContainer(0);
    Point2d p1 = ethane.getAtom(0).getPoint2d();
    p1 = panel.getRenderPanel().getRenderer().toScreenCoordinates(p1.x, p1.y);
      panel.get2DHub().mouseClickedDown((int)p1.x, (int)p1.y);
        applet.panel("renderpanel").robot.waitForIdle();
      panel.get2DHub().mouseClickedUp((int)p1.x, (int)p1.y);
        panel.get2DHub().updateView();
        applet.panel("renderpanel").robot.waitForIdle();
        IChemObjectSelection sel = panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection();
        Assert.assertEquals(true, sel.contains(ethane.getAtom(0)));
        applet.menuItem("formalCharge").requireEnabled();

        Point2d p2 = ethane.getAtom(1).getPoint2d();
    p2 = panel.getRenderPanel().getRenderer().toScreenCoordinates(p2.x, p2.y);
      panel.get2DHub().mouseClickedDown((int)p2.x, (int)p2.y);
        applet.panel("renderpanel").robot.waitForIdle();
      panel.get2DHub().mouseClickedUp((int)p2.x, (int)p2.y);
        panel.get2DHub().updateView();
        applet.panel("renderpanel").robot.waitForIdle();
        sel = panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection();
        Assert.assertEquals(true, sel.contains(ethane.getAtom(1)));
        applet.menuItem("formalCharge").requireEnabled();
    }
View Full Code Here

    }

    public static Rectangle2D calculateBounds(IAtomContainerSet moleculeSet) {
        Rectangle2D totalBounds = null;
        for (int i = 0; i < moleculeSet.getAtomContainerCount(); i++) {
            IAtomContainer ac = moleculeSet.getAtomContainer(i);
            Rectangle2D acBounds = Renderer.calculateBounds(ac);
            if (totalBounds == null) {
                totalBounds = acBounds;
            } else {
                Rectangle2D.union(totalBounds, acBounds, totalBounds);
View Full Code Here

    }

    private IRenderingElement generateDiagram(IAtomContainerSet moleculeSet) {
        ElementGroup diagram = new ElementGroup();
        for (int i = 0; i < moleculeSet.getAtomContainerCount(); i++) {
            IAtomContainer ac = moleculeSet.getAtomContainer(i);
            for (IGenerator generator : this.generators) {
                diagram.add(generator.generate(ac, this.rendererModel));
            }
        }
        return diagram;
View Full Code Here

   * @see
   * org.openscience.cdk.controller.IChemModelRelay#addPhenyl(org.openscience
   * .cdk.interfaces.IBond, boolean)
   */
  public IRing addPhenyl(IBond bond, boolean phantom) {
    IAtomContainer sharedAtoms = bond.getBuilder().newInstance(IAtomContainer.class);
    IAtom firstAtom = bond.getAtom(0); // Assumes two-atom bonds only
    IAtom secondAtom = bond.getAtom(1);
    sharedAtoms.addAtom(firstAtom);
    sharedAtoms.addAtom(secondAtom);
    sharedAtoms.addBond(bond);
    IAtomContainer sourceContainer = ChemModelManipulator
        .getRelevantAtomContainer(chemModel, firstAtom);

    Point2d sharedAtomsCenter = GeometryTools.get2DCenter(sharedAtoms);

    // calculate two points that are perpendicular to the highlighted bond
    // and have a certain distance from the bond center
    Point2d firstPoint = firstAtom.getPoint2d();
    Point2d secondPoint = secondAtom.getPoint2d();
    Vector2d diff = new Vector2d(secondPoint);
    diff.sub(firstPoint);
    double bondLength = firstPoint.distance(secondPoint);
    double angle = GeometryTools.getAngle(diff.x, diff.y);
    Point2d newPoint1 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle + (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle + (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);
    Point2d newPoint2 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle - (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle - (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);

    // decide on which side to draw the ring??
    IAtomContainer connectedAtoms = bond.getBuilder().newInstance(IAtomContainer.class);
    for (IAtom atom : sourceContainer.getConnectedAtomsList(firstAtom)) {
      if (atom != secondAtom)
        connectedAtoms.addAtom(atom);
    }
    for (IAtom atom : sourceContainer.getConnectedAtomsList(secondAtom)) {
      if (atom != firstAtom)
        connectedAtoms.addAtom(atom);
    }
    Point2d conAtomsCenter = GeometryTools.get2DCenter(connectedAtoms);
    double distance1 = newPoint1.distance(conAtomsCenter);
    double distance2 = newPoint2.distance(conAtomsCenter);
    Vector2d ringCenterVector = new Vector2d(sharedAtomsCenter);
View Full Code Here

     */
    @Test
    public void testGetInchiFromLandDAlanine3D() throws Exception {
       
        // L-Alanine
        IAtomContainer acL = new AtomContainer();
        IAtom a1L = new Atom("C", new Point3d(-0.358, 0.819, 20.655));
        IAtom a2L = new Atom("C", new Point3d(-1.598, -0.032, 20.905));
        IAtom a3L = new Atom("N", new Point3d(-0.275, 2.014, 21.574));
        IAtom a4L = new Atom("C", new Point3d(0.952, 0.043, 20.838));
        IAtom a5L = new Atom("O", new Point3d(-2.678, 0.479, 21.093));
        IAtom a6L = new Atom("O", new Point3d(-1.596, -1.239, 20.958));
        a1L.setImplicitHydrogenCount(1);
        a3L.setImplicitHydrogenCount(2);
        a4L.setImplicitHydrogenCount(3);
        a5L.setImplicitHydrogenCount(1);
        acL.addAtom(a1L);
        acL.addAtom(a2L);
        acL.addAtom(a3L);
        acL.addAtom(a4L);
        acL.addAtom(a5L);
        acL.addAtom(a6L);
       
        acL.addBond(new Bond(a1L, a2L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a1L, a3L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a1L, a4L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a2L, a5L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a2L, a6L, CDKConstants.BONDORDER_DOUBLE));
       
        Assert.assertEquals(gen.generateInchi(acL).getInChI(), "InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1");
       
       
        // D-Alanine
        IAtomContainer acD = new AtomContainer();
        IAtom a1D = new Atom("C", new Point3d(0.358, 0.819, 20.655));
        IAtom a2D = new Atom("C", new Point3d(1.598, -0.032, 20.905));
        IAtom a3D = new Atom("N", new Point3d(0.275, 2.014, 21.574));
        IAtom a4D = new Atom("C", new Point3d(-0.952, 0.043, 20.838));
        IAtom a5D = new Atom("O", new Point3d(2.678, 0.479, 21.093));
        IAtom a6D = new Atom("O", new Point3d(1.596, -1.239, 20.958));
        a1D.setImplicitHydrogenCount(1);
        a3D.setImplicitHydrogenCount(2);
        a4D.setImplicitHydrogenCount(3);
        a5D.setImplicitHydrogenCount(1);
        acD.addAtom(a1D);
        acD.addAtom(a2D);
        acD.addAtom(a3D);
        acD.addAtom(a4D);
        acD.addAtom(a5D);
        acD.addAtom(a6D);
       
        acD.addBond(new Bond(a1D, a2D, CDKConstants.BONDORDER_SINGLE));
        acD.addBond(new Bond(a1D, a3D, CDKConstants.BONDORDER_SINGLE));
        acD.addBond(new Bond(a1D, a4D, CDKConstants.BONDORDER_SINGLE));
        acD.addBond(new Bond(a2D, a5D, CDKConstants.BONDORDER_SINGLE));
        acD.addBond(new Bond(a2D, a6D, CDKConstants.BONDORDER_DOUBLE));
       
                                                             //"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1");
        Assert.assertEquals(gen.generateInchi(acL).getInChI(), "InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1");

    }
View Full Code Here

  }

  // OK TODO this could do with less partitioning
  public void removeBond(IBond bond) {
    removeBondWithoutUndo(bond);
    IAtomContainer undAtomContainer = bond.getBuilder().newInstance(IAtomContainer.class);
    undAtomContainer.addBond(bond);
    if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) {
      IUndoRedoable undoredo = getUndoRedoFactory()
          .getRemoveAtomsAndBondsEdit(getIChemModel(),
              undAtomContainer, "Remove Bond", this);
      getUndoRedoHandler().postEdit(undoredo);
View Full Code Here

    List<IAtomContainer> containersList = ChemModelManipulator
        .getAllAtomContainers(chemModel);
    Iterator<IAtomContainer> iterator = containersList.iterator();
    Map<IBond, IBond.Order[]> changedBonds = new HashMap<IBond, IBond.Order[]>();
    while (iterator.hasNext()) {
      IAtomContainer ac = (IAtomContainer) iterator.next();
      for (IBond bond : ac.bonds()) {
        IBond.Order[] orders = new IBond.Order[2];
        orders[1] = bond.getOrder();
        changedBonds.put(bond, orders);
      }
      satChecker.saturate(ac);
      for (IBond bond : ac.bonds()) {
        IBond.Order[] orders = changedBonds.get(bond);
        orders[0] = bond.getOrder();
        changedBonds.put(bond, orders);
      }
    }
View Full Code Here

    List<IAtomContainer> containersList = ChemModelManipulator
        .getAllAtomContainers(chemModel);
    Iterator<IAtomContainer> iterator = containersList.iterator();
    Map<IBond, IBond.Order[]> changedBonds = new HashMap<IBond, IBond.Order[]>();
    while (iterator.hasNext()) {
      IAtomContainer ac = iterator.next();
      for (IBond bond : ac.bonds()) {
        IBond.Order[] orders = new IBond.Order[2];
        orders[1] = bond.getOrder();
        orders[0] = Order.SINGLE;
        changedBonds.put(bond, orders);
        bond.setOrder(Order.SINGLE);
View Full Code Here

TOP

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

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.