int count = entries.size();
GradRecord[] records = new GradRecord[count];
double previousRatio = 0.0;
for (int currentIndex = 0; currentIndex < count; currentIndex++)
{
GradientEntryNode entry = entries.get(currentIndex);
double thisRatio = entry.ratio;
// Auto-calculate gradient ratio if omitted from an entry.
if (Double.isNaN(thisRatio))
{
// The first ratio is assumed to be 0.0.
if (currentIndex == 0)
{
thisRatio = 0.0;
}
// The last ratio is assumed to be 1.0.
else if (currentIndex == count - 1)
{
thisRatio = 1.0;
}
else
{
// Other omitted ratios are divided evenly between the last
// ratio and the next specified ratio (or 1.0 if none).
double nextRatio = 1.0;
int nextIndex = count - 1;
for (int i = currentIndex; i < count; i++)
{
GradientEntryNode nextEntry = entries.get(i);
if (!Double.isNaN(nextEntry.ratio))
{
nextRatio = nextEntry.ratio;
nextIndex = i;
break;