/** Finally renders the Object in the Graphics object.
* @param g the Graphics2D object in which to render
*/
public void renderChart(Graphics2D g) {
ChartDataModel m = getChartDataModel();
ChartDataModelConstraints con = m.getChartDataModelConstraints(CoordSystem.FIRST_YAXIS);
if(m.isColumnNumeric())
return;
RowColorModel rcm = getRowColorModel();
AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
AffineTransform yaxis2 = getTransform(CoordSystem.SECOND_YAXIS);
int datasetcount = m.getDataSetNumber();
Point2D point1 = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
con.getMaximumValue().floatValue()),
null);
Point2D point2 = yaxis1.transform(new Point2D.Float((float)con.getMaximumColumnValue(),
con.getMaximumValue().floatValue()),
null);
Point2D value = point1;
int dataunitwidth = (int)((point2.getX() - point1.getX()) / con.getMaximumColumnValue());
int boxwidth = (int)(dataunitwidth * boxWidth / datasetcount);
float margin = (float)(dataunitwidth * ((1.0 - boxWidth)/2f));
Point2D pointzero;
if(con.getMinimumValue().floatValue() > 0)
pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
con.getMinimumValue().floatValue()),
null);
else if(con.getMaximumValue().floatValue() < 0)
pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
con.getMaximumValue().floatValue()),
null);
else
pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
0f),
null);
FontRenderContext columnTopfrc = null;
LineMetrics lm = null;
DecimalFormat df = null;
Rectangle2D fontRec = null;
String columnTop = null;
if (barTopFormat != null) {
g.setFont(barTopFont);
columnTopfrc = new FontRenderContext(null, false, false);
}
/* We paint the values starting at x-value "0".
* As we only render BarCharts for ChartDataModels with
* non-numeric x-axis values we don't have to read those
* values from the data model. You can look in
* ObjectChartDataModel to see, how the x-axis bounds
* are defined: the minimum value is always 0, the maximum
* value is the amount of non-numeric x-axis values.
*/
for(int i = 0; i < datasetcount; i++) {
//System.out.println("** DataSet "+i);
for(int j = 0; j < m.getDataSetLength(i); j++) {
yaxis1.transform(new Point2D.Float((float)j, m.getValueAt(i, j).floatValue()),
value);
Rectangle2D box =
new Rectangle2D.Float((float)(value.getX() + margin + i*boxwidth),
(float)Math.min(value.getY(), pointzero.getY()),