Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/jfree#366' into v1.5.x
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
Yuri-Blankenstein-TNO committed May 24, 2023
2 parents ab439a4 + 7d6f3df commit d6705ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ History
##### Version 1.5.5 (not yet released)
- fix cross hair painting ([#340](https://github.com/jfree/jfreechart/issues/340))
- fix zooming on CombinedDomainXYPlot with OfflineRenderingChartPanel ([#351](https://github.com/jfree/jfreechart/issues/351))
- fix calculating if label fits inside bar for XYBarRenderer ([#366](https://github.com/jfree/jfreechart/issues/366))

##### Version 1.5.4 (8 January 2023)
- add new methods to access maps for datasets, renderers and axes in plots ([#201](https://github.com/jfree/jfreechart/issues/201));
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/jfree/chart/renderer/xy/XYBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1028,18 +1028,17 @@ private String calculateLabeltoDraw(String label, Point2D anchorPoint,
}

String result = label;
while (result != null) {
Shape bounds = TextUtils.calculateRotatedStringBounds(result,
while (result != null && !result.isEmpty()) {
Rectangle2D labelBounds = TextUtils.calculateRotatedStringBounds(result,
g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
Rectangle2D bounds2D = bounds == null ? null : bounds.getBounds2D();
position.getRotationAnchor()).getBounds2D();

if (bounds2D != null && labelBar.contains(bounds2D)) {
if (labelBar.getHeight() >= labelBounds.getHeight() && labelBar.getWidth() >= labelBounds.getWidth()) {
// Label fits
return result;
} else if (bounds2D != null && labelBar.getHeight() < bounds2D.getHeight()) {
// Label will never fit, insufficient height
} else if (labelBar.getHeight() < labelBounds.getHeight()) {
// Optimization: label will never fit due to insufficient height
return null;
} else {
switch (position.getItemLabelClip()) {
Expand Down

0 comments on commit d6705ec

Please sign in to comment.