@@ -476,7 +476,10 @@ TextOutline positionAfter(TextOutline before, TextOutline after) {
476476 * @param hydrogen the hydrogen label outline
477477 * @return positioned charge label
478478 */
479- TextOutline positionChargeLabel (int hydrogens , HydrogenPosition position , TextOutline charge , TextOutline element ,
479+ TextOutline positionChargeLabel (int hydrogens ,
480+ HydrogenPosition position ,
481+ TextOutline charge ,
482+ TextOutline element ,
480483 TextOutline hydrogen ) {
481484
482485 final Rectangle2D chargeBounds = charge .getBounds ();
@@ -486,12 +489,14 @@ TextOutline positionChargeLabel(int hydrogens, HydrogenPosition position, TextOu
486489 // are in the way - in which case we place it relative to the
487490 // hydrogen
488491 Rectangle2D referenceBounds = element .getBounds ();
489- if (hydrogens > 0 && position == Right )
492+ if (hydrogens > 0 && position != Below )
490493 referenceBounds = hydrogen .getBounds ();
491- else if (hydrogens > 1 && position == Above ) referenceBounds = hydrogen .getBounds ();
492-
493- return charge .translate ((referenceBounds .getMaxX () + padding ) - chargeBounds .getMinX (),
494- (referenceBounds .getMinY () - (chargeBounds .getHeight () / 2 )) - chargeBounds .getMinY ());
494+ if (position == Left )
495+ return charge .translate ((referenceBounds .getMinX () - padding ) - chargeBounds .getMaxX (),
496+ (referenceBounds .getMinY () - (chargeBounds .getHeight () / 2 )) - chargeBounds .getMinY ());
497+ else
498+ return charge .translate ((referenceBounds .getMaxX () + padding ) - chargeBounds .getMinX (),
499+ (referenceBounds .getMinY () - (chargeBounds .getHeight () / 2 )) - chargeBounds .getMinY ());
495500 }
496501
497502 /**
0 commit comments