LonePairGenerator implements IGenerator<IAtomContainer> { @Override public IRenderingElement generate(IAtomContainer container, RendererModel model) { ElementGroup group = new ElementGroup(); final double SCREEN_RADIUS = 1.0; final double SCREEN_SEPARATION = 2.5; final Color RADICAL_COLOR = Color.BLACK; final double ATOM_RADIUS = ((AtomRadius) model.getParameter(AtomRadius.class)).getValue(); double scale = model.getParameter(Scale.class).getValue(); double modelAtomRadius = ATOM_RADIUS / scale; double modelPointRadius = SCREEN_RADIUS / scale; double modelSeparation = SCREEN_SEPARATION / scale; for (ILonePair lonePair : container.lonePairs()) { IAtom atom = lonePair.getAtom(); Point2d point = atom.getPoint2d(); int align = GeometryUtil.getBestAlignmentForLabelXY(container, atom); double xRadius = point.x; double yRadius = point.y; double diffx = 0; double diffy = 0; if (align == 1) { xRadius += modelAtomRadius; diffy += modelSeparation; } else if (align == -1) { xRadius -= modelAtomRadius; diffy += modelSeparation; } else if (align == 2) { yRadius -= modelAtomRadius; diffx += modelSeparation; } else if (align == -2) { yRadius += modelAtomRadius; diffx += modelSeparation; } group.add(new OvalElement(xRadius + diffx, yRadius + diffy, modelPointRadius, true, RADICAL_COLOR)); group.add(new OvalElement(xRadius - diffx, yRadius - diffy, modelPointRadius, true, RADICAL_COLOR)); } return group; } LonePairGenerator(); @Override IRenderingElement generate(IAtomContainer container, RendererModel model); @Override List<IGeneratorParameter<?>> getParameters();  }
@Test public void testEmptyContainer() { IAtomContainer emptyContainer = super.builder.newInstance(IAtomContainer.class); IRenderingElement root = generator.generate(emptyContainer, model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(0, elements.size()); }