*
*/
public class ReactionPlusGenerator implements IReactionGenerator {
public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
ElementGroup diagram = new ElementGroup();
Color color = model.getForeColor();
IAtomContainerSet reactants = reaction.getReactants();
if(reactants.getAtomContainerCount()>0){
Rectangle2D totalBoundsReactants = Renderer.calculateBounds(reactants);
Rectangle2D bounds1 =
Renderer.calculateBounds(reactants.getAtomContainer(0));
double axis = totalBoundsReactants.getCenterY();
for (int i = 1; i < reaction.getReactantCount(); i++) {
Rectangle2D bounds2 =
Renderer.calculateBounds(reactants.getAtomContainer(i));
diagram.add(makePlus(bounds1, bounds2, axis, color));
bounds1 = bounds2;
}
}
IAtomContainerSet products = reaction.getProducts();
if(products.getAtomContainerCount()>0){
Rectangle2D totalBoundsProducts = Renderer.calculateBounds(products);
double axis = totalBoundsProducts.getCenterY();
Rectangle2D bounds1 = Renderer.calculateBounds(products.getAtomContainer(0));
for (int i = 1; i < reaction.getProductCount(); i++) {
Rectangle2D bounds2 =
Renderer.calculateBounds(products.getAtomContainer(i));
diagram.add(makePlus(bounds1, bounds2, axis, color));
bounds1 = bounds2;
}
}
return diagram;
}