RadicalGenerator implements IGenerator<IAtomContainer> { @Override public IRenderingElement generate(IAtomContainer container, RendererModel model) { ElementGroup group = new ElementGroup(); final double SCREEN_RADIUS = 2.0; final Color RADICAL_COLOR = Color.BLACK; final double ATOM_RADIUS = ((AtomRadius) model.getParameter(AtomRadius.class)).getValue() / model.getParameter(Scale.class).getValue(); double modelRadius = SCREEN_RADIUS / model.getParameter(Scale.class).getValue(); double modelSpacing = modelRadius * 2.5; Map<IAtom, Integer> singleElectronsPerAtom = new HashMap<IAtom, Integer>(); for (ISingleElectron electron : container.singleElectrons()) { IAtom atom = electron.getAtom(); if (singleElectronsPerAtom.get(atom) == null) singleElectronsPerAtom.put(atom, 0); Point2d point = atom.getPoint2d(); int align = GeometryUtil.getBestAlignmentForLabelXY(container, atom); double xRadius = point.x; double yRadius = point.y; if (align == 1) { xRadius += ATOM_RADIUS * 4 + singleElectronsPerAtom.get(atom) * modelSpacing; } else if (align == -1) { xRadius -= ATOM_RADIUS * 4 + singleElectronsPerAtom.get(atom) * modelSpacing; } else if (align == 2) { yRadius += ATOM_RADIUS * 4 + singleElectronsPerAtom.get(atom) * modelSpacing; } else if (align == -2) { yRadius -= ATOM_RADIUS * 4 + singleElectronsPerAtom.get(atom) * modelSpacing; } singleElectronsPerAtom.put(atom, singleElectronsPerAtom.get(atom) + 1); group.add(new OvalElement(xRadius, yRadius, modelRadius, true, RADICAL_COLOR)); } return group; } RadicalGenerator(); @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()); }