/** * {@inheritDoc} */ @Override public Point2d getPoint2d() { return atom.getPoint2d(); }
/** * {@inheritDoc} */ @Override public Point2d getPoint2d() { return atom.getPoint2d(); }
/** * Determines if this Atom contains 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atom Description of the Parameter *@return boolean indication that 2D coordinates are available */ public static boolean has2DCoordinates(IAtom atom) { return (atom.getPoint2d() != null); }
private void map2DCoordsToCML(CMLAtom cmlAtom, IAtom cdkAtom) { if (cdkAtom.getPoint2d() != null) { cmlAtom.setX2(cdkAtom.getPoint2d().x); cmlAtom.setY2(cdkAtom.getPoint2d().y); } }
/** * Reflect the point {@code p} over the {@code bond}. * * @param p the point to reflect * @param bond bond * @return the reflected point */ private Point2d reflect(Point2d p, IBond bond) { IAtom a = bond.getBegin(); IAtom b = bond.getEnd(); return reflect(p, a.getPoint2d().x, a.getPoint2d().y, b.getPoint2d().x, b.getPoint2d().y); }
private void reflect(IntStack stack, Tuple2d begP, Tuple2d endP) { double dx = endP.x - begP.x; double dy = endP.y - begP.y; double a = (dx * dx - dy * dy) / (dx * dx + dy * dy); double b = 2 * dx * dy / (dx * dx + dy * dy); for (int i = 0; i < stack.len; i++) { reflect(atoms[stack.xs[i]].getPoint2d(), begP, a, b); } }
private static double angle(IBond bond) { Point2d end = bond.getBegin().getPoint2d(); Point2d beg = bond.getEnd().getPoint2d(); return Math.atan2(end.y - beg.y, end.x - beg.x); }
private static double angle(IBond bond) { Point2d end = bond.getBegin().getPoint2d(); Point2d beg = bond.getEnd().getPoint2d(); return Math.atan2(end.y - beg.y, end.x - beg.x); }
private void reflect(IntStack stack, Tuple2d begP, Tuple2d endP) { double dx = endP.x - begP.x; double dy = endP.y - begP.y; double a = (dx * dx - dy * dy) / (dx * dx + dy * dy); double b = 2 * dx * dy / (dx * dx + dy * dy); for (int i = 0; i < stack.len; i++) { reflect(atoms[stack.xs[i]].getPoint2d(), begP, a, b); } }
private int getNumberOfDimensions(IAtomContainer mol) { for (IAtom atom : mol.atoms()) { if (atom.getPoint3d() != null) return 3; else if (atom.getPoint2d() != null) return 2; } return 0; }
private int getNumberOfDimensions(IAtomContainer mol) { for (IAtom atom : mol.atoms()) { if (atom.getPoint3d() != null && !forceWriteAs2DCoords.isSet()) return 3; else if (atom.getPoint2d() != null) return 2; } return 0; }
@Test public void hydrogensAppearBeforeWhenBondIsFromRight() throws Exception { IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); when(atom1.getPoint2d()).thenReturn(new Point2d(0, 0)); when(atom2.getPoint2d()).thenReturn(new Point2d(1, 0)); assertThat(HydrogenPosition.position(atom1, Arrays.asList(atom2)), is(Left)); }
@Test public void testGetPoint2d() { Point2d point2d = new Point2d(1.0, 2.0); IAtom a = (IAtom) newChemObject(); a.setPoint2d(point2d); Assert.assertNotNull(a.getPoint2d()); Assert.assertEquals(point2d.x, a.getPoint2d().x, 0.001); Assert.assertEquals(point2d.y, a.getPoint2d().y, 0.001); }
/** * These molecules are laid out 'H2N=NH2.H2N=NH2', ensure we give them more space than * usual (bond length) */ @Test public void dihydroazine() throws Exception { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("N=N.N=N"); layout(mol); assertThat(mol.getAtom(2).getPoint2d().x - mol.getAtom(1).getPoint2d().x, is(greaterThan(SDG.getBondLength()))); }
@Test public void testCoordinates3D() throws Exception { String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2' x3='0.0 0.1' y3='1.2 1.3' z3='2.1 2.5'/></molecule>"; IChemFile chemFile = parseCMLString(cmlString); IAtomContainer mol = checkForSingleMoleculeFile(chemFile); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertNull(mol.getAtom(0).getPoint2d()); Assert.assertNull(mol.getAtom(1).getPoint2d()); Assert.assertNotNull(mol.getAtom(0).getPoint3d()); Assert.assertNotNull(mol.getAtom(1).getPoint3d()); }
/** * Method to test the Atom(String symbol) method. */ @Test public void testAtom_String() { IAtom a = new Atom("C"); Assert.assertEquals("C", a.getSymbol()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testDebugAtom_String_Point3d() { Point3d point3d = new Point3d(1.0, 2.0, 3.0); IAtom a = new DebugAtom("C", point3d); Assert.assertEquals("C", a.getSymbol()); Assert.assertEquals(point3d, a.getPoint3d()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testAtom_String_Point2d() { Point2d point2d = new Point2d(1.0, 2.0); IAtom a = new Atom("C", point2d); Assert.assertEquals("C", a.getSymbol()); Assert.assertEquals(point2d, a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testAtom_NH4plus() { IAtom a = new Atom("NH4+"); Assert.assertEquals("N", a.getSymbol()); Assert.assertEquals((Integer) 7, a.getAtomicNumber()); Assert.assertEquals((Integer) 4, a.getImplicitHydrogenCount()); Assert.assertEquals((Integer) 1, a.getFormalCharge()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testAtom_13CH3() { IAtom a = new Atom("13CH3"); Assert.assertEquals("C", a.getSymbol()); Assert.assertEquals((Integer) 13, a.getMassNumber()); Assert.assertEquals((Integer) 6, a.getAtomicNumber()); Assert.assertEquals((Integer) 3, a.getImplicitHydrogenCount()); Assert.assertEquals((Integer) 0, a.getFormalCharge()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }