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

misc. fix from previous changes

parent e972ad6b
Branches
No related tags found
No related merge requests found
......@@ -154,8 +154,8 @@ public class Axis implements ChartPart {
}
/////////////////////////
int i = 1; // just twice through
double width = 80; // arbitrary, final width depends on Axis tick labels
int i = 1; // just twice through is all it takes
double width = 60; // arbitrary, final width depends on Axis tick labels
double height = 0;
do {
// System.out.println("width: " + width);
......@@ -291,10 +291,12 @@ public class Axis implements ChartPart {
String sampleLabel = "";
// find the longest String in all the labels
for (int i = 0; i < axisTickCalculator.getTickLabels().size(); i++) {
// System.out.println("label: " + axisTickCalculator.getTickLabels().get(i));
if (axisTickCalculator.getTickLabels().get(i) != null && axisTickCalculator.getTickLabels().get(i).length() > sampleLabel.length()) {
sampleLabel = axisTickCalculator.getTickLabels().get(i);
}
}
// System.out.println("sampleLabel: " + sampleLabel);
// get the height of the label including rotation
TextLayout textLayout = new TextLayout(sampleLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false));
......@@ -326,7 +328,7 @@ public class Axis implements ChartPart {
// System.out.println("XAxisHeightHint");
// System.out.println("workingSpace: " + workingSpace);
AxisTickCalculator axisTickCalculator = axisTick.getAxisTickCalculator(workingSpace);
String sampleLabel = " ";
String sampleLabel = "";
// find the longest String in all the labels
for (int i = 0; i < axisTickCalculator.getTickLabels().size(); i++) {
if (axisTickCalculator.getTickLabels().get(i) != null && axisTickCalculator.getTickLabels().get(i).length() > sampleLabel.length()) {
......
......@@ -84,13 +84,13 @@ public class AxisTickDateCalculator extends AxisTickCalculator {
// generate all tickLabels and tickLocations from the first to last position
for (double value = firstPosition; value <= maxValue + 2 * gridStep; value = value + gridStep) {
if (value <= maxValue && value >= minValue) {
// if (value <= maxValue && value >= minValue) {
tickLabels.add(dateFormatter.formatDate(value, timeUnit));
// here we convert tickPosition finally to plot space, i.e. pixels
double tickLabelPosition = margin + ((value - minValue) / (maxValue - minValue) * tickSpace);
tickLocations.add(tickLabelPosition);
}
tickLabels.add(dateFormatter.formatDate(value, timeUnit));
// here we convert tickPosition finally to plot space, i.e. pixels
double tickLabelPosition = margin + ((value - minValue) / (maxValue - minValue) * tickSpace);
tickLocations.add(tickLabelPosition);
// }
}
} while (!willLabelsFitInTickSpaceHint(tickLabels, tickSpacingHint));
}
......
......@@ -138,6 +138,7 @@ public class AxisTickLabels implements ChartPart {
double tickLocation = axisTick.getTickLocations().get(i);
double shiftedTickLocation = xOffset + tickLocation;
// discard null and out of bounds labels
if (tickLabel != null && shiftedTickLocation > xOffset && shiftedTickLocation < xOffset + width) { // some are null for logarithmic axes
FontRenderContext frc = g.getFontRenderContext();
......@@ -183,6 +184,9 @@ public class AxisTickLabels implements ChartPart {
maxTickLabelHeight = tickLabelBounds.getHeight();
}
}
// else {
// System.out.println("discarding: " + tickLabel);
// }
}
// bounds
......
......@@ -136,16 +136,16 @@ public class AxisTickNumericalCalculator extends AxisTickCalculator {
// generate all tickLabels and tickLocations from the first to last position
for (BigDecimal value = cleanedFirstPosition; value.compareTo(BigDecimal.valueOf(maxValue + 2 * cleanedGridStep.doubleValue())) < 0; value = value.add(cleanedGridStep)) {
if (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0 && value.compareTo(BigDecimal.valueOf(minValue)) >= 0) {
// System.out.println(value);
String tickLabel = numberFormatter.formatNumber(value, minValue, maxValue, axisDirection);
// System.out.println(tickLabel);
tickLabels.add(tickLabel);
// here we convert tickPosition finally to plot space, i.e. pixels
double tickLabelPosition = margin + ((value.doubleValue() - minValue) / (maxValue - minValue) * tickSpace);
tickLocations.add(tickLabelPosition);
}
// if (value.compareTo(BigDecimal.valueOf(maxValue)) <= 0 && value.compareTo(BigDecimal.valueOf(minValue)) >= 0) {
// System.out.println(value);
String tickLabel = numberFormatter.formatNumber(value, minValue, maxValue, axisDirection);
// System.out.println(tickLabel);
tickLabels.add(tickLabel);
// here we convert tickPosition finally to plot space, i.e. pixels
double tickLabelPosition = margin + ((value.doubleValue() - minValue) / (maxValue - minValue) * tickSpace);
tickLocations.add(tickLabelPosition);
// }
}
} while (!willLabelsFitInTickSpaceHint(tickLabels, tickSpacingHint));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment