* Renders the title of the axis.
*/
private void drawTitle(double maxWidth, double maxHeight) {
double x = this.x;
double y = this.y;
PreciseRectangle bbox = new PreciseRectangle();
boolean rotate = (position == Position.LEFT || position == Position.RIGHT);
if (titleSprite == null) {
titleSprite = titleConfig.copy();
if (rotate) {
titleSprite.setRotation(270);
}
chart.addSprite(titleSprite);
}
bbox = titleSprite.getBBox();
int pad = dashSize + Math.abs(textLabelPadding);
if (rotate) {
y -= this.length / 2.0 - bbox.getHeight() / 2.0;
if (position == Position.LEFT) {
x -= (maxWidth + textLabelPadding + bbox.getWidth());
} else {
x += (maxWidth + textLabelPadding - (bbox.getWidth() / 2.0));
}
this.bbox.setWidth(this.bbox.getWidth() + bbox.getWidth());
this.bbox.setHeight(chart.getBBox().getHeight());
} else {
x += (this.length / 2.0) - (bbox.getWidth() / 2.0);
if (position == Position.TOP) {
y -= (maxHeight + pad + bbox.getHeight());
} else {
y += (maxHeight + pad - (bbox.getHeight() / 2.0));
}
this.bbox.setHeight(this.bbox.getHeight() + bbox.getHeight());
this.bbox.setWidth(chart.getBBox().getWidth());
}
titleSprite.setTranslation(x, y);
titleSprite.redraw();
}