BasicAtomGenerator implements IGenerator<IAtomContainer> { @Override public IRenderingElement generate(IAtomContainer container, RendererModel model) { ElementGroup elementGroup = new ElementGroup(); for (IAtom atom : container.atoms()) { elementGroup.add(MarkedElement.markupAtom(this.generate(container, atom, model), atom)); } return elementGroup; } BasicAtomGenerator(); @Override IRenderingElement generate(IAtomContainer container, RendererModel model); IRenderingElement generate(IAtomContainer atomContainer, IAtom atom, RendererModel model); IRenderingElement generateCompactElement(IAtom atom, RendererModel model); AtomSymbolElement generateElement(IAtom atom, int alignment, RendererModel model); @Override List<IGeneratorParameter<?>> getParameters();  }
@Test public void testSingleAtom() { IAtomContainer singleAtom = makeSingleAtom(); IRenderingElement root = generator.generate(singleAtom, singleAtom.getAtom(0), model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(1, elements.size()); }
@Test public void testSingleBond() { IAtomContainer container = makeSingleBond(); model.set(CompactAtom.class, true); model.set(CompactShape.class, Shape.OVAL); model.set(ShowEndCarbons.class, true); IRenderingElement root = generator.generate(container, model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(2, elements.size()); OvalElement ovalA = (OvalElement) elements.get(0); OvalElement ovalB = (OvalElement) elements.get(1); Assert.assertNotSame(0, distance(ovalA.xCoord, ovalA.yCoord, ovalB.xCoord, ovalB.yCoord)); }
@Test public void testSquare() { IAtomContainer square = makeSquare(); model.set(KekuleStructure.class, true); IRenderingElement root = generator.generate(square, model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(4, elements.size()); Assert.assertEquals(new Point2d(0, 0), center(elements)); }