Skip to content
Snippets Groups Projects
Commit 28d125df authored by Tim Molter's avatar Tim Molter Committed by Niklas Polke
Browse files

when determining X-Axis height, consider all labels, not just the first one

parent 1aabc057
No related branches found
No related tags found
No related merge requests found
......@@ -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,26 +213,26 @@ 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);
// System.out.println("height: " + height);
// the Y-Axis was already draw at this point so we know how much vertical room is left for the X-Axis
double height =
getChartPainter().getHeight() - axisPair.getYAxis().getBounds().getY() - axisPair.getYAxis().getBounds().getHeight() - getChartPainter().getStyleManager().getChartPadding()
- getChartPainter().getStyleManager().getPlotPadding();
- getChartPainter().getStyleManager().getPlotPadding();
// System.out.println("height2: " + height2);
Rectangle2D xAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height);
......@@ -277,6 +277,12 @@ public class Axis implements ChartPart {
// get some real tick labels
AxisTickCalculator axisTickCalculator = axisTick.getAxisTickCalculator(workingSpace);
String sampleLabel = axisTickCalculator.getTickLabels().get(0);
// find the longest String in all the labels
for (int i = 1; i < axisTickCalculator.getTickLabels().size(); i++) {
if (axisTickCalculator.getTickLabels().get(i).length() > sampleLabel.length()) {
sampleLabel = axisTickCalculator.getTickLabels().get(i);
}
}
TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
AffineTransform rot =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment