gc.setFont(labelFont);
final Color paint = this.getItemLabelPaint(row, column);
gc.setForeground(paint);
// find out where to place the label...
ItemLabelPosition position = null;
if (!negative) {
position = this.getPositiveItemLabelPosition(row, column);
} else {
position = this.getNegativeItemLabelPosition(row, column);
}
// work out the label anchor point...
Point anchorPoint = this.calculateLabelAnchorPoint(position
.getItemLabelAnchor(), bar, plot.getOrientation());
if (this.isInternalAnchor(position.getItemLabelAnchor())) {
// TODO : correct rotation code
// Rectangle bounds =
// TextUtilities.calculateRotatedStringBounds(label,
// gc, (float) anchorPoint.x, (float) anchorPoint.y,
// position.getTextAnchor(), position.getAngle(),
// position.getRotationAnchor());
final RectangleAdapter bounds = new RectangleAdapter(TextUtilities
.getTextBounds(label, gc));
if (bounds != null) {
if (!RectangleUtil.contains(bar, bounds.getBounds())) {
if (!negative) {
position = this.getPositiveItemLabelPositionFallback();
} else {
position = this.getNegativeItemLabelPositionFallback();
}
if (position != null) {
anchorPoint = this.calculateLabelAnchorPoint(position
.getItemLabelAnchor(), bar, plot
.getOrientation());
}
}
}
}
if (position != null) {
TextUtilities.drawRotatedString(label, gc, anchorPoint.x,
anchorPoint.y, position.getTextAnchor(), position
.getAngle(), position.getRotationAnchor());
}
}