Skip to content
Snippets Groups Projects
Commit fd0ca5df authored by Tim Molter's avatar Tim Molter
Browse files

Implemented PR#109 in a different way

parent 67a69259
No related branches found
No related tags found
No related merge requests found
...@@ -162,8 +162,7 @@ public class Axis implements ChartPart { ...@@ -162,8 +162,7 @@ public class Axis implements ChartPart {
- chartLegendWidth - chartLegendWidth
- 2 - 2 * getChartPainter().getStyleManager().getChartPadding()
* getChartPainter().getStyleManager().getChartPadding()
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
...@@ -172,9 +171,8 @@ public class Axis implements ChartPart { ...@@ -172,9 +171,8 @@ public class Axis implements ChartPart {
; ;
double height = double height = getChartPainter().getHeight() - yOffset - axisPair.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - getChartPainter().getStyleManager().getPlotPadding() - getChartPainter()
getChartPainter().getHeight() - yOffset - axisPair.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - getChartPainter().getStyleManager().getPlotPadding() .getStyleManager().getChartPadding();
- getChartPainter().getStyleManager().getChartPadding();
Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height); Rectangle2D yAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height);
this.paintZone = yAxisRectangle; this.paintZone = yAxisRectangle;
// g.setColor(Color.green); // g.setColor(Color.green);
...@@ -199,8 +197,7 @@ public class Axis implements ChartPart { ...@@ -199,8 +197,7 @@ public class Axis implements ChartPart {
// calculate paint zone // calculate paint zone
// |____________________| // |____________________|
double xOffset = double xOffset = axisPair.getYAxis().getBounds().getWidth() + (getChartPainter().getStyleManager().isYAxisTicksVisible() ? getChartPainter().getStyleManager().getPlotPadding() : 0)
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 yOffset = axisPair.getYAxis().getBounds().getY() + axisPair.getYAxis().getBounds().getHeight() + getChartPainter().getStyleManager().getPlotPadding();
...@@ -217,8 +214,7 @@ public class Axis implements ChartPart { ...@@ -217,8 +214,7 @@ public class Axis implements ChartPart {
- chartLegendWidth - chartLegendWidth
- 2 - 2 * getChartPainter().getStyleManager().getChartPadding()
* getChartPainter().getStyleManager().getChartPadding()
- (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0) - (getChartPainter().getStyleManager().isYAxisTicksVisible() ? (getChartPainter().getStyleManager().getPlotPadding()) : 0)
...@@ -230,8 +226,7 @@ public class Axis implements ChartPart { ...@@ -230,8 +226,7 @@ public class Axis implements ChartPart {
// double height = this.getXAxisHeightHint(width); // double height = this.getXAxisHeightHint(width);
// System.out.println("height: " + height); // 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 // the Y-Axis was already draw at this point so we know how much vertical room is left for the X-Axis
double height = double height = getChartPainter().getHeight() - axisPair.getYAxis().getBounds().getY() - axisPair.getYAxis().getBounds().getHeight() - getChartPainter().getStyleManager().getChartPadding()
getChartPainter().getHeight() - axisPair.getYAxis().getBounds().getY() - axisPair.getYAxis().getBounds().getHeight() - getChartPainter().getStyleManager().getChartPadding()
- getChartPainter().getStyleManager().getPlotPadding(); - getChartPainter().getStyleManager().getPlotPadding();
// System.out.println("height2: " + height2); // System.out.println("height2: " + height2);
...@@ -276,17 +271,17 @@ public class Axis implements ChartPart { ...@@ -276,17 +271,17 @@ public class Axis implements ChartPart {
// get some real tick labels // get some real tick labels
AxisTickCalculator axisTickCalculator = axisTick.getAxisTickCalculator(workingSpace); AxisTickCalculator axisTickCalculator = axisTick.getAxisTickCalculator(workingSpace);
String sampleLabel = axisTickCalculator.getTickLabels().get(0); String sampleLabel = " ";
// find the longest String in all the labels // find the longest String in all the labels
for (int i = 1; i < axisTickCalculator.getTickLabels().size(); i++) { for (int i = 0; i < axisTickCalculator.getTickLabels().size(); i++) {
if (axisTickCalculator.getTickLabels().get(i) != null && axisTickCalculator.getTickLabels().get(i).length() > sampleLabel.length()) { if (axisTickCalculator.getTickLabels().get(i) != null && axisTickCalculator.getTickLabels().get(i).length() > sampleLabel.length()) {
sampleLabel = axisTickCalculator.getTickLabels().get(i); sampleLabel = axisTickCalculator.getTickLabels().get(i);
} }
} }
TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
AffineTransform rot = AffineTransform rot = getChartPainter().getStyleManager().getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager()
getChartPainter().getStyleManager().getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(getChartPainter().getStyleManager().getXAxisLabelRotation())); .getXAxisLabelRotation()));
Shape shape = textLayout.getOutline(rot); Shape shape = textLayout.getOutline(rot);
Rectangle2D rectangle = shape.getBounds(); Rectangle2D rectangle = shape.getBounds();
axisTickLabelsHeight = rectangle.getHeight() + getChartPainter().getStyleManager().getAxisTickPadding() + getChartPainter().getStyleManager().getAxisTickMarkLength(); axisTickLabelsHeight = rectangle.getHeight() + getChartPainter().getStyleManager().getAxisTickPadding() + getChartPainter().getStyleManager().getAxisTickMarkLength();
......
...@@ -61,10 +61,10 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator { ...@@ -61,10 +61,10 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator {
// where the tick should begin in the working space in pixels // where the tick should begin in the working space in pixels
double margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace); double margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace);
int logMin = (int) Math.floor(Math.log10(minValue));
int logMax = (int) Math.ceil(Math.log10(maxValue));
// System.out.println("minValue: " + minValue); // System.out.println("minValue: " + minValue);
// System.out.println("maxValue: " + maxValue); // System.out.println("maxValue: " + maxValue);
int logMin = (int) Math.floor(Math.log10(minValue));
int logMax = (int) Math.ceil(Math.log10(maxValue));
// System.out.println("logMin: " + logMin); // System.out.println("logMin: " + logMin);
// System.out.println("logMax: " + logMax); // System.out.println("logMax: " + logMax);
...@@ -91,7 +91,7 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator { ...@@ -91,7 +91,7 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator {
// System.out.println("tickStep: " + tickStep); // System.out.println("tickStep: " + tickStep);
// System.out.println("firstPosition: " + firstPosition); // System.out.println("firstPosition: " + firstPosition);
// System.out.println("i: " + i); // System.out.println("i: " + i);
// System.out.println("pow(10, i).doubleValue(): " + pow(10, i).doubleValue()); // System.out.println("Utils.pow(10, i): " + Utils.pow(10, i));
// using the .00000001 factor to deal with double value imprecision // using the .00000001 factor to deal with double value imprecision
for (double j = firstPosition; j <= Utils.pow(10, i) + .00000001; j = j + tickStep) { for (double j = firstPosition; j <= Utils.pow(10, i) + .00000001; j = j + tickStep) {
...@@ -114,8 +114,7 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator { ...@@ -114,8 +114,7 @@ public class AxisTickLogarithmicCalculator extends AxisTickCalculator {
tickLabels.add(numberFormatter.formatLogNumber(j, axisDirection)); tickLabels.add(numberFormatter.formatLogNumber(j, axisDirection));
} }
else { else {
// Set a space to avoid Zero length string passed to TextLayout constructor tickLabels.add(null);
tickLabels.add(" ");
} }
// add all the tick marks though // add all the tick marks though
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment