Skip to content

Commit

Permalink
Use paint(drawVisitor,diagram) from ChemModelRenderer and not Abstrac…
Browse files Browse the repository at this point in the history
…tRenderer

This is important because you can only access the
drawCenter on the outer renderer and the paint method
needs to be called on the same object.
  • Loading branch information
goglepox authored and egonw committed May 19, 2012
1 parent a613ca2 commit d947407
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main/org/openscience/cdk/renderer/ChemModelRenderer.java
Expand Up @@ -21,6 +21,8 @@
*/
package org.openscience.cdk.renderer;

import static org.openscience.cdk.renderer.BoundsCalculator.calculateBounds;

import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.util.List;
Expand Down Expand Up @@ -196,21 +198,30 @@ public Rectangle paint(IChemModel chemModel, IDrawVisitor drawVisitor) {
IReactionSet reactionSet = chemModel.getReactionSet();

if (moleculeSet == null && reactionSet != null) {
return reactionSetRenderer.paint(reactionSet, drawVisitor);
Rectangle2D totalBounds = calculateBounds(reactionSet);
this.setupTransformNatural(totalBounds);
IRenderingElement diagram = reactionSetRenderer.generateDiagram(reactionSet);
this.paint(drawVisitor,diagram);
return this.convertToDiagramBounds(totalBounds);
}

if (moleculeSet != null && reactionSet == null) {
return moleculeSetRenderer.paint(moleculeSet, drawVisitor);
Rectangle2D totalBounds = calculateBounds(moleculeSet);
this.setupTransformNatural(totalBounds);
IRenderingElement diagram = moleculeSetRenderer.generateDiagram(moleculeSet);
this.paint( drawVisitor, diagram);
return this.convertToDiagramBounds(totalBounds);
}

if (moleculeSet != null && reactionSet != null) {
Rectangle2D totalBounds = BoundsCalculator.calculateBounds(reactionSet);
totalBounds = totalBounds.createUnion(
BoundsCalculator.calculateBounds(moleculeSet));
Rectangle2D totalBounds = BoundsCalculator.calculateBounds(chemModel);

this.setupTransformNatural(totalBounds);

ElementGroup diagram = new ElementGroup();
diagram.add(reactionSetRenderer.generateDiagram(reactionSet));
diagram.add(moleculeSetRenderer.generateDiagram(moleculeSet));

this.paint(drawVisitor, diagram);

// the size of the painted diagram is returned
Expand Down

0 comments on commit d947407

Please sign in to comment.