// scan through the datasets
for(int lRow = 0; lRow < lNumberOfRows; lRow++)
{
// scan through the values in the dataset
GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, lNumberOfColumns);
for (int lCol = 0; lCol < lNumberOfColumns; lCol++)
{
// get the value
double lValue = m.getValueAt(lRow, lCol).doubleValue();
// determine the scale
double lMaxValue = maxvalues[lCol];
if(lMaxValue == 0.0) {
for(int row = 0; row < lNumberOfRows; row++)
lMaxValue = Math.max(lMaxValue, m.getValueAt(row, lCol).doubleValue() * 1.1);
maxvalues[lCol] = lMaxValue;
}
double lScaledValue = lValue / lMaxValue;
double lLineValue = lRadius * lScaledValue;
// determine rotation: there are 2PI/noOfCols vertexes, this is vertex no lCol
// -1 : we want to rotate clockwise
// + PI: rotate 180 degree to get the first column pointing up
double lRotation = (-1 * (2 * Math.PI / lNumberOfColumns) * lCol) + Math.PI;
// determine the end points
double lX = center_x + (lLineValue * Math.sin(lRotation));
double lY = center_y + (lLineValue * Math.cos(lRotation));
// draw the line
Line2D lLine = new Line2D.Double(center_x, center_y, lX, lY);
g.setColor(Color.black);
g.draw(lLine);
// add to polygone
if (lCol == 0) filledPolygon.moveTo((float)lX, (float)lY);
else filledPolygon.lineTo((float)lX, (float)lY);
}
// draw the polygone
filledPolygon.closePath();
g.setPaint( rcm.getColor(lRow) );
g.draw(filledPolygon);
}
double lRotation;