/** * {@inheritDoc} */ @Override public void setPoint2d(Point2d point2d) { atom.setPoint2d(point2d); }
/** * {@inheritDoc} */ @Override public void setPoint2d(Point2d point2d) { atom.setPoint2d(point2d); }
private IAtom atomAt(Point2d p) { IAtom atom = new Atom("C"); atom.setPoint2d(p); return atom; }
private static void set2D(IAtomContainer container, int index, IAtom[] atoms) { if ((container.getAtom(index)).getPoint2d() != null) { atoms[index].setPoint2d(new Point2d(container.getAtom(index).getPoint2d())); } }
private static void set2D(IAtomContainer container, int index, IAtom[] atoms) { if ((container.getAtom(index)).getPoint2d() != null) { atoms[index].setPoint2d(new Point2d(container.getAtom(index).getPoint2d())); } }
public static void project2D(IAtomContainer container) { for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (atom.getPoint3d() != null) { atom.setPoint2d(new Point2d(atom.getPoint3d().x, atom.getPoint3d().y)); } else { // should throw an exception } } }
public static void project2D(IAtomContainer container, HashMap<IAtom, Point2d> renderingCoordinates) { for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (atom.getPoint3d() != null) { atom.setPoint2d(new Point2d(atom.getPoint3d().x, atom.getPoint3d().y)); renderingCoordinates.put(atom, new Point2d(atom.getPoint3d().x, atom.getPoint3d().y)); } else { // should throw an exception } } } }
static IAtom atom(String symbol, int hCount, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(hCount); a.setPoint2d(new Point2d(x, y)); return a; } }
static IAtom atom(String symbol, int h, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(h); a.setPoint2d(new Point2d(x, y)); return a; }
static IAtom atom(String symbol, int hCount, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(hCount); a.setPoint2d(new Point2d(x, y)); return a; }
static IAtom atom(String symbol, int h, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(h); a.setPoint2d(new Point2d(x, y)); return a; }
@Test public void testSetPoint2d_Point2d() { Point2d point2d = new Point2d(1.0, 2.0); IAtom a = (IAtom) newChemObject(); a.setPoint2d(point2d); Assert.assertEquals(point2d, a.getPoint2d()); }
@Test public void hasCoordinatesTest() { IAtom atomWithCoordinates = super.builder.newInstance(IAtom.class); atomWithCoordinates.setPoint2d(new Point2d(0, 0)); Assert.assertTrue(generator.hasCoordinates(atomWithCoordinates)); IAtom atomWithoutCoordinates = super.builder.newInstance(IAtom.class); atomWithoutCoordinates.setPoint2d(null); Assert.assertFalse(generator.hasCoordinates(atomWithoutCoordinates)); IAtom nullAtom = null; Assert.assertFalse(generator.hasCoordinates(nullAtom)); }
@Test public void ethaneNonTerminal() { IAtom a1 = new Atom("C"); IAtom a2 = new Atom("C"); a1.setPoint2d(new Point2d(0, 0)); a2.setPoint2d(new Point2d(0.5, -0.5)); IBond bond1 = new Bond(a1, a2); a1.setImplicitHydrogenCount(3); a2.setImplicitHydrogenCount(3); assertTrue(SymbolVisibility.iupacRecommendationsWithoutTerminalCarbon() .visible(a1, Collections.singletonList(bond1), new RendererModel())); }
@Test public void iupacMethylAcceptable() { IAtom a1 = new Atom("C"); IAtom a2 = new Atom("C"); a1.setImplicitHydrogenCount(null); a2.setImplicitHydrogenCount(null); IBond bond = new Bond(a1, a2); a1.setPoint2d(new Point2d(0, 0)); a2.setPoint2d(new Point2d(0, 0)); assertFalse(SymbolVisibility.iupacRecommendationsWithoutTerminalCarbon().visible(a1, Arrays.asList(bond), new RendererModel())); }
@Test @Override public void hasCoordinatesTest() { IAtom atomWithCoordinates = super.builder.newInstance(IAtom.class); atomWithCoordinates.setPoint2d(new Point2d(0, 0)); Assert.assertTrue(generator.hasCoordinates(atomWithCoordinates)); IAtom atomWithoutCoordinates = super.builder.newInstance(IAtom.class); atomWithoutCoordinates.setPoint2d(null); Assert.assertFalse(generator.hasCoordinates(atomWithoutCoordinates)); IAtom nullAtom = null; Assert.assertFalse(generator.hasCoordinates(nullAtom)); }
@Test public void testClone_IAtom2() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); IAtom carbon = molecule.getBuilder().newInstance(IAtom.class, "C"); carbon.setPoint2d(new Point2d(2, 4)); molecule.addAtom(carbon); // 1 // test cloning of Atoms IAtomContainer clonedMol = (IAtomContainer) molecule.clone(); carbon.setPoint2d(new Point2d(3, 1)); Assert.assertEquals(clonedMol.getAtom(0).getPoint2d().x, 2.0, 0.001); }
@Test public void testGetClosestAtom_Double_Double_IAtomContainer_IAtom() { IAtom atom1 = new Atom("C"); atom1.setPoint2d(new Point2d(1, 0)); IAtom atom2 = new Atom("C"); atom2.setPoint2d(new Point2d(5, 0)); IAtomContainer acont = new AtomContainer(); acont.addAtom(atom1); acont.addAtom(atom2); Assert.assertEquals(atom2, GeometryUtil.getClosestAtom(1.0, 0.0, acont, atom1)); Assert.assertEquals(atom1, GeometryUtil.getClosestAtom(1.0, 0.0, acont, null)); }
@Test public void testIAtom_Point2d() throws Exception { IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setID("a1"); atom.setPoint2d(new Point2d(1.0, 2.0)); mol.addAtom(atom); IAtomContainer copy = CMLRoundTripTool.roundTripMolecule(convertor, mol); String difference = AtomDiff.diff(atom, copy.getAtom(0)); Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length()); }
@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); }