Skip to content

Commit 0c4ed4a

Browse files
committed
Fix test cases.
1 parent e7de75d commit 0c4ed4a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/StandardAtomGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ TextOutline positionChargeLabel(int hydrogens,
489489
// are in the way - in which case we place it relative to the
490490
// hydrogen
491491
Rectangle2D referenceBounds = element.getBounds();
492-
if (hydrogens > 0 && position != Below)
492+
if (hydrogens > 0 && (position == Left || position == Right))
493493
referenceBounds = hydrogen.getBounds();
494494
if (position == Left)
495495
return charge.translate((referenceBounds.getMinX() - padding) - chargeBounds.getMaxX(),

display/renderbasic/src/test/java/org/openscience/cdk/renderer/generators/standard/StandardAtomGeneratorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void positionOfChargeWhenHydrogensAreLeft() {
159159
Rectangle2D chargeBounds = positioned.getBounds();
160160

161161
assertThat(chargeBounds.getMinX(), greaterThan(elementBounds.getMinX()));
162-
assertThat(chargeBounds.getCenterY(), closeTo(elementBounds.getMinY(), 0.01));
162+
assertThat(chargeBounds.getCenterY(), closeTo(localHydrogen.getBounds().getMinY(), 0.01));
163163
}
164164

165165
@Test
@@ -186,8 +186,9 @@ public void positionOfChargeWhenTwoHydrogensAreAbove() {
186186
Rectangle2D hydrogenBounds = localHydrogen.getBounds();
187187
Rectangle2D chargeBounds = positioned.getBounds();
188188

189-
assertThat(chargeBounds.getMinX(), greaterThan(hydrogenBounds.getMinX()));
190-
assertThat(chargeBounds.getCenterY(), closeTo(hydrogenBounds.getMinY(), 0.01));
189+
Rectangle2D elementBounds = element.getBounds();
190+
assertThat(chargeBounds.getMinX(), greaterThan(elementBounds.getMinX()));
191+
assertThat(chargeBounds.getCenterY(), closeTo(elementBounds.getMinY(), 0.01));
191192
}
192193

193194
@Test

0 commit comments

Comments
 (0)