*/
protected void calculateBarWidth(final CategoryPlot plot,
final Rectangle dataArea, final int rendererIndex,
final CategoryItemRendererState state) {
final CategoryAxis domainAxis = this.getDomainAxis(plot, rendererIndex);
final CategoryDataset dataset = plot.getDataset(rendererIndex);
if (dataset != null) {
final int columns = dataset.getColumnCount();
final int rows = dataset.getRowCount();
double space = 0.0;
final PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.height;
} else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.width;
}
final double maxWidth = space * this.getMaximumBarWidth();
double categoryMargin = 0.0;
double currentItemMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
if (rows > 1) {
currentItemMargin = this.getItemMargin();
}
final double used = space
* (1 - domainAxis.getLowerMargin()
- domainAxis.getUpperMargin() - categoryMargin - currentItemMargin);
if ((rows * columns) > 0) {
state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
} else {
state.setBarWidth(Math.min(used, maxWidth));
}