class 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;
    }

}