From 90e840fdc3661470ae9da0668b63e9a4ca5e039d Mon Sep 17 00:00:00 2001 From: Tim Molter <tim@knowm.org> Date: Mon, 21 Sep 2015 21:49:27 +0200 Subject: [PATCH] fix for issue #105 PDF rendering bug --- .../xchart/internal/chartpart/AxisTitle.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java index e5754331..bd05fb3f 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java @@ -38,7 +38,7 @@ public class AxisTitle implements ChartPart { /** * Constructor - * + * * @param axis the axis */ protected AxisTitle(Axis axis) { @@ -72,20 +72,24 @@ public class AxisTitle implements ChartPart { int xOffset = (int) (axis.getPaintZone().getX() + nonRotatedRectangle.getHeight()); int yOffset = (int) ((axis.getPaintZone().getHeight() + nonRotatedRectangle.getWidth()) / 2.0 + axis.getPaintZone().getY()); + + AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.PI / 2, 0, 0); + Shape shape = nonRotatedTextLayout.getOutline(rot); + AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); - at.rotate(Math.PI / -2.0, xOffset, yOffset); + + at.translate(xOffset, yOffset); g.transform(at); - g.drawString(text, xOffset, yOffset); + g.fill(shape); g.setTransform(orig); // /////////////////////////////////////////////// // System.out.println(nonRotatedRectangle.getHeight()); // bounds - bounds = - new Rectangle2D.Double(xOffset - nonRotatedRectangle.getHeight(), yOffset - nonRotatedRectangle.getWidth(), nonRotatedRectangle.getHeight() - + getChartPainter().getStyleManager().getAxisTitlePadding(), nonRotatedRectangle.getWidth()); + bounds = new Rectangle2D.Double(xOffset - nonRotatedRectangle.getHeight(), yOffset - nonRotatedRectangle.getWidth(), nonRotatedRectangle.getHeight() + getChartPainter().getStyleManager() + .getAxisTitlePadding(), nonRotatedRectangle.getWidth()); // g.setColor(Color.blue); // g.draw(bounds); } @@ -115,9 +119,8 @@ public class AxisTitle implements ChartPart { g.fill(shape); g.setTransform(orig); - bounds = - new Rectangle2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTitlePadding(), rectangle.getWidth(), rectangle.getHeight() - + getChartPainter().getStyleManager().getAxisTitlePadding()); + bounds = new Rectangle2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTitlePadding(), rectangle.getWidth(), rectangle.getHeight() + getChartPainter().getStyleManager() + .getAxisTitlePadding()); // g.setColor(Color.blue); // g.draw(bounds); -- GitLab