BoundsCalculator { public static Rectangle2D calculateBounds(IChemModel chemModel) { IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); IReactionSet reactionSet = chemModel.getReactionSet(); Rectangle2D totalBounds = new Rectangle2D.Double(); if (moleculeSet != null) { totalBounds = totalBounds.createUnion(calculateBounds(moleculeSet)); } if (reactionSet != null) { totalBounds = totalBounds.createUnion(calculateBounds(reactionSet)); } return totalBounds; }  static Rectangle2D calculateBounds(IChemModel chemModel); static Rectangle2D calculateBounds(IReactionSet reactionSet); static Rectangle2D calculateBounds(IReaction reaction); static Rectangle2D calculateBounds(IAtomContainerSet moleculeSet); static Rectangle2D calculateBounds(IAtomContainer atomContainer);  }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IAtomContainer_SingleAtom() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); BoundsCalculator.calculateBounds(container); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IAtomContainer() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); BoundsCalculator.calculateBounds(container); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IAtomContainerSet_SingleAtom() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IAtomContainerSet set = container.getBuilder().newInstance(IAtomContainerSet.class); set.addAtomContainer(container); BoundsCalculator.calculateBounds(set); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IAtomContainerSet() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IAtomContainerSet set = container.getBuilder().newInstance(IAtomContainerSet.class); set.addAtomContainer(container); BoundsCalculator.calculateBounds(set); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IReactionSet_SingleAtom() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IReaction reaction = container.getBuilder().newInstance(IReaction.class); reaction.addReactant(container.getBuilder().newInstance(IAtomContainer.class, container)); IReactionSet set = container.getBuilder().newInstance(IReactionSet.class); set.addReaction(reaction); BoundsCalculator.calculateBounds(set); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IReactionSet() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IReaction reaction = container.getBuilder().newInstance(IReaction.class); reaction.addReactant(container.getBuilder().newInstance(IAtomContainer.class, container)); IReactionSet set = container.getBuilder().newInstance(IReactionSet.class); set.addReaction(reaction); BoundsCalculator.calculateBounds(set); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IChemModel_SingleAtom() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IAtomContainerSet set = container.getBuilder().newInstance(IAtomContainerSet.class); set.addAtomContainer(container); IChemModel model = container.getBuilder().newInstance(IChemModel.class); model.setMoleculeSet(set); BoundsCalculator.calculateBounds(model); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IChemModel() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IAtomContainerSet set = container.getBuilder().newInstance(IAtomContainerSet.class); set.addAtomContainer(container); IChemModel model = container.getBuilder().newInstance(IChemModel.class); model.setMoleculeSet(set); BoundsCalculator.calculateBounds(model); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IReaction_SingleAtom() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IReaction reaction = container.getBuilder().newInstance(IReaction.class); reaction.addReactant(container.getBuilder().newInstance(IAtomContainer.class, container)); BoundsCalculator.calculateBounds(reaction); }
@Test(expected = IllegalArgumentException.class) public void testCalculateBounds_IReaction() { IAtomContainer container = new AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IReaction reaction = container.getBuilder().newInstance(IReaction.class); reaction.addReactant(container.getBuilder().newInstance(IAtomContainer.class, container)); BoundsCalculator.calculateBounds(reaction); }