From e381c68ead823f7d5fde3d8afbbbdaf60389d862 Mon Sep 17 00:00:00 2001 From: Tim Molter <tim.molter@gmail.com> Date: Sun, 12 Apr 2015 16:00:34 +0200 Subject: [PATCH] remove rotating Y-Axis tick labels --- .../java/com/xeiam/xchart/StyleManager.java | 11 ------ .../xeiam/xchart/internal/chartpart/Axis.java | 39 ++++++++++--------- .../internal/chartpart/AxisTickLabels.java | 4 +- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/xchart/src/main/java/com/xeiam/xchart/StyleManager.java b/xchart/src/main/java/com/xeiam/xchart/StyleManager.java index 6c2d3f12..2673c082 100644 --- a/xchart/src/main/java/com/xeiam/xchart/StyleManager.java +++ b/xchart/src/main/java/com/xeiam/xchart/StyleManager.java @@ -124,7 +124,6 @@ public class StyleManager { private TextAlignment xAxisLabelAlignment = TextAlignment.Centre; private TextAlignment yAxisLabelAlignment = TextAlignment.Left; private int xAxisLabelRotation = 0; - private int yAxisLabelRotation = 0; // Chart Plot Area /////////////////////////////// private boolean isPlotGridLinesVisible; @@ -918,16 +917,6 @@ public class StyleManager { this.xAxisLabelRotation = xAxisLabelRotation; } - public int getYAxisLabelRotation() { - - return yAxisLabelRotation; - } - - public void setYAxisLabelRotation(int yAxisLabelRotation) { - - this.yAxisLabelRotation = yAxisLabelRotation; - } - // Chart Plot Area /////////////////////////////// /** diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java index 68de6dd2..c65cc272 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java @@ -158,23 +158,23 @@ public class Axis implements ChartPart { getChartPainter().getWidth() - - width // y-axis approx. width + - width // y-axis approx. width - - chartLegendWidth + - chartLegendWidth - - 2 - * getChartPainter().getStyleManager().getChartPadding() + - 2 + * getChartPainter().getStyleManager().getChartPadding() - - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) + - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) - - (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager() - .getChartPadding() : 0) + - (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager() + .getChartPadding() : 0) - ; + ; double height = getChartPainter().getHeight() - yOffset - axisPair.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - getChartPainter().getStyleManager().getPlotPadding() - - getChartPainter().getStyleManager().getChartPadding(); + - getChartPainter().getStyleManager().getChartPadding(); Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height); this.paintZone = yAxisRectangle; // g.setColor(Color.green); @@ -201,7 +201,7 @@ public class Axis implements ChartPart { double xOffset = axisPair.getYAxis().getBounds().getWidth() + (getChartPainter().getStyleManager().isYAxisTicksVisible() ? getChartPainter().getStyleManager().getPlotPadding() : 0) - + getChartPainter().getStyleManager().getChartPadding(); + + getChartPainter().getStyleManager().getChartPadding(); double yOffset = axisPair.getYAxis().getBounds().getY() + axisPair.getYAxis().getBounds().getHeight() + getChartPainter().getStyleManager().getPlotPadding(); double chartLegendWidth = 0; @@ -213,19 +213,19 @@ public class Axis implements ChartPart { getChartPainter().getWidth() - - axisPair.getYAxis().getBounds().getWidth() // y-axis was already painted + - axisPair.getYAxis().getBounds().getWidth() // y-axis was already painted - - chartLegendWidth + - chartLegendWidth - - 2 - * getChartPainter().getStyleManager().getChartPadding() + - 2 + * getChartPainter().getStyleManager().getChartPadding() - - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) + - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) - - (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager() - .getChartPadding() : 0) + - (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE && getChartPainter().getStyleManager().isLegendVisible() ? getChartPainter().getStyleManager() + .getChartPadding() : 0) - ; + ; double height = this.getXAxisHeightHint(width); Rectangle2D xAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height); @@ -248,6 +248,9 @@ public class Axis implements ChartPart { } /** + * The vertical Y-Axis is drawn first, but to know the lower bounds of it, we need to know how high the X-Axis paint zone is going to be. Since the tick labels could be rotated, we need to actually + * determine the tick labels first to get an idea of how tall thew X-Axis tick labels will be. + * * @return */ private double getXAxisHeightHint(double workingSpace) { diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java index cd59f690..d22f8635 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java @@ -89,9 +89,7 @@ public class AxisTickLabels implements ChartPart { for (Double tickLocation : axisLabelTextLayouts.keySet()) { TextLayout axisLabelTextLayout = axisLabelTextLayouts.get(tickLocation); - AffineTransform rot = - getChartPainter().getStyleManager().getYAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-Math.toRadians(getChartPainter().getStyleManager().getYAxisLabelRotation())); - Shape shape = axisLabelTextLayout.getOutline(rot); + Shape shape = axisLabelTextLayout.getOutline(null); Rectangle2D tickLabelBounds = shape.getBounds(); double flippedTickLocation = yOffset + height - tickLocation; -- GitLab