StandardAtomGenerator { TextOutline positionHydrogenLabel(HydrogenPosition position, TextOutline element, TextOutline hydrogen) { final Rectangle2D elementBounds = element.getBounds(); final Rectangle2D hydrogenBounds = hydrogen.getBounds(); switch (position) { case Above: return hydrogen.translate(0, (elementBounds.getMinY() - padding) - hydrogenBounds.getMaxY()); case Right: return hydrogen.translate((elementBounds.getMaxX() + padding) - hydrogenBounds.getMinX(), 0); case Below: return hydrogen.translate(0, (elementBounds.getMaxY() + padding) - hydrogenBounds.getMinY()); case Left: return hydrogen.translate((elementBounds.getMinX() - padding) - hydrogenBounds.getMaxX(), 0); } return hydrogen; } StandardAtomGenerator(Font font); private  StandardAtomGenerator(Font font, double adjunctSpacing, double scriptSize);   }
@Test public void positionHydrogenAbove() { TextOutline positioned = atomGenerator.positionHydrogenLabel(HydrogenPosition.Above, element, hydrogen); Rectangle2D elementBounds = element.getBounds(); Rectangle2D hydrogenBounds = positioned.getBounds(); assertThat(elementBounds.getMinY(), greaterThan(hydrogenBounds.getMaxY())); assertThat(elementBounds.getMinX(), closeTo(hydrogenBounds.getMinX(), 0.01)); }
@Test public void positionHydrogenBelow() { TextOutline positioned = atomGenerator.positionHydrogenLabel(HydrogenPosition.Below, element, hydrogen); Rectangle2D elementBounds = element.getBounds(); Rectangle2D hydrogenBounds = positioned.getBounds(); assertThat(elementBounds.getMinY(), lessThan(hydrogenBounds.getMaxY())); assertThat(elementBounds.getMinX(), closeTo(hydrogenBounds.getMinX(), 0.01)); }
@Test public void positionHydrogenToLeft() { TextOutline positioned = atomGenerator.positionHydrogenLabel(HydrogenPosition.Left, element, hydrogen); Rectangle2D elementBounds = element.getBounds(); Rectangle2D hydrogenBounds = positioned.getBounds(); assertThat(elementBounds.getMaxX(), greaterThan(hydrogenBounds.getMinX())); assertThat(elementBounds.getMaxY(), closeTo(hydrogenBounds.getMaxY(), 0.01)); }
@Test public void positionHydrogenToRight() { TextOutline positioned = atomGenerator.positionHydrogenLabel(HydrogenPosition.Right, element, hydrogen); Rectangle2D elementBounds = element.getBounds(); Rectangle2D hydrogenBounds = positioned.getBounds(); assertThat(elementBounds.getMaxX(), lessThan(hydrogenBounds.getMinX())); assertThat(elementBounds.getMaxY(), closeTo(hydrogenBounds.getMaxY(), 0.01)); }