Skip to content

Commit

Permalink
Ensure that the totalBounds object returned is non-null
Browse files Browse the repository at this point in the history
Signed-off-by: Arvid Berg <goglepox@gmail.com>
  • Loading branch information
egonw committed Mar 26, 2012
1 parent f4f4772 commit 1324985
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/main/org/openscience/cdk/renderer/BoundsCalculator.java
Expand Up @@ -56,18 +56,16 @@ public class BoundsCalculator {
public static Rectangle2D calculateBounds(IChemModel chemModel) {
IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
IReactionSet reactionSet = chemModel.getReactionSet();
Rectangle2D totalBounds = null;
Rectangle2D totalBounds = new Rectangle2D.Double();
if (moleculeSet != null) {
totalBounds = calculateBounds(moleculeSet);
totalBounds = totalBounds.createUnion(
calculateBounds(moleculeSet)
);
}

if (reactionSet != null) {
if (totalBounds == null) {
totalBounds = calculateBounds(reactionSet);
} else {
totalBounds = totalBounds.createUnion(
calculateBounds(reactionSet));
}
totalBounds = totalBounds.createUnion(
calculateBounds(reactionSet)
);
}
return totalBounds;
}
Expand Down

0 comments on commit 1324985

Please sign in to comment.