ExtendedAtomGenerator extends BasicAtomGenerator { @Override public IRenderingElement generate(IAtomContainer container, IAtom atom, RendererModel model) { boolean drawNumbers = false; if (model.hasParameter(WillDrawAtomNumbers.class)) { drawNumbers = model.getParameter(WillDrawAtomNumbers.class).getValue(); } if (!hasCoordinates(atom) || invisibleHydrogen(atom, model) || (invisibleCarbon(atom, container, model) && !drawNumbers)) { return null; } else if (model.getParameter(CompactAtom.class).getValue()) { return this.generateCompactElement(atom, model); } else { String text; if (atom instanceof IPseudoAtom) { text = ((IPseudoAtom) atom).getLabel(); } else if (invisibleCarbon(atom, container, model) && drawNumbers) { text = String.valueOf(container.indexOf(atom) + 1); } else { text = atom.getSymbol(); } Point2d point = atom.getPoint2d(); Color ccolor = getAtomColor(atom, model); TextGroupElement textGroup = new TextGroupElement(point.x, point.y, text, ccolor); decorate(textGroup, container, atom, model); return textGroup; } }  @Override IRenderingElement generate(IAtomContainer container, IAtom atom, RendererModel model); @Override List<IGeneratorParameter<?>> getParameters();  }
@Test @Override 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 @Override 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 @Override 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)); }