ReactantsBoxGenerator implements IGenerator<IReaction> { @Override public IRenderingElement generate(IReaction reaction, RendererModel model) { if (!model.getParameter(ShowReactionBoxes.class).getValue()) return null; if (reaction.getReactantCount() == 0) return new ElementGroup(); double separation = model.getParameter(BondLength.class).getValue() / model.getParameter(Scale.class).getValue() / 2; Rectangle2D totalBounds = BoundsCalculator.calculateBounds(reaction.getReactants()); ElementGroup diagram = new ElementGroup(); double minX = totalBounds.getMinX(); double minY = totalBounds.getMinY(); double maxX = totalBounds.getMaxX(); double maxY = totalBounds.getMaxY(); Color foregroundColor = model.getParameter(BasicSceneGenerator.ForegroundColor.class).getValue(); diagram.add(new RectangleElement(minX - separation, minY - separation, maxX + separation, maxY + separation, foregroundColor)); diagram.add(new TextElement((minX + maxX) / 2, minY - separation, "Reactants", foregroundColor)); 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()); }