ReactionPlusGenerator implements IGenerator<IReaction> { @Override public IRenderingElement generate(IReaction reaction, RendererModel model) { ElementGroup diagram = new ElementGroup(); Color color = model.getParameter(BasicSceneGenerator.ForegroundColor.class).getValue(); IAtomContainerSet reactants = reaction.getReactants(); if (reactants.getAtomContainerCount() > 1) { Rectangle2D totalBoundsReactants = BoundsCalculator.calculateBounds(reactants); Rectangle2D bounds1 = BoundsCalculator.calculateBounds(reactants.getAtomContainer(0)); double axis = totalBoundsReactants.getCenterY(); for (int i = 1; i < reaction.getReactantCount(); i++) { Rectangle2D bounds2 = BoundsCalculator.calculateBounds(reactants.getAtomContainer(i)); diagram.add(makePlus(bounds1, bounds2, axis, color)); bounds1 = bounds2; } } IAtomContainerSet products = reaction.getProducts(); if (products.getAtomContainerCount() > 1) { Rectangle2D totalBoundsProducts = BoundsCalculator.calculateBounds(products); double axis = totalBoundsProducts.getCenterY(); Rectangle2D bounds1 = BoundsCalculator.calculateBounds(reactants.getAtomContainer(0)); for (int i = 1; i < reaction.getProductCount(); i++) { Rectangle2D bounds2 = BoundsCalculator.calculateBounds(products.getAtomContainer(i)); diagram.add(makePlus(bounds1, bounds2, axis, color)); bounds1 = bounds2; } } return diagram; }  @Override IRenderingElement generate(IReaction reaction, RendererModel model); @Override List<IGeneratorParameter<?>> getParameters();  }
@Test public void testEmptyReaction() { IReaction singleReaction = super.builder.newInstance(IReaction.class); IRenderingElement root = generator.generate(singleReaction, model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(0, elements.size()); }