double y = 0;
double maxHeight = height;
boolean vertical = false;
double furthestLabel = 0;
int horizontalLabelPadding = textLabelPadding;
Rotation labelRotation = labelConfig.getRotation();
if (labelRotation != null) {
vertical = (Math.floor((labelRotation.getDegrees() - 90) % 180) == 0);
}
for (int i = 0; i < ticks.size() / labelStepRatio; i++) {
point = ticks.get(i * labelStepRatio);
textLabel = getOrCreateLabel(i);
bbox = textLabel.getBBox();
maxHeight = Math.max(maxHeight, bbox.getHeight() + dashSize + horizontalLabelPadding);
if (!vertical) {
x = Math.floor(point.getX() - (bbox.getHeight() / 2.0));
} else {
x = Math.floor(point.getX() - (bbox.getWidth() / 2.0));
}
if (position == Position.TOP) {
y = Math.floor(point.getY() - dashSize - horizontalLabelPadding - bbox.getHeight());
} else {
y = Math.floor(point.getY() + dashSize + horizontalLabelPadding);
if (labelRotation != null) {
y += bbox.getHeight();
}
}
textLabel.setHidden(false);
textLabel.setX(x);
textLabel.setY(y);
if (labelRotation != null) {
textLabel.setRotation(new Rotation(x, y, labelRotation.getDegrees()));
}
textLabel.redraw();
bbox = textLabel.getBBox();
// Skip label if there isn't available minimum space