final boolean hasPing = ping != null && ping.length > 0;
if (!hasText && !hasPing) {
return;
}
// Initialize all counters
FromToCounter counterX = new FromToCounter(x1, x2);
FromToCounter counterY = new FromToCounter(y1, y2);
FromToCounter textCounter = new FromToCounter();
FromToCounter pingCounter = new FromToCounter();
if (hasText) {
textCounter.reset(0, text.length - 1);
}
if (hasPing) {
pingCounter.reset(0, ping.length - 1);
}
// Start processing the area
while (counterX.hasNext()) {
counterX.next();
counterY.reset();
while (counterY.hasNext()) {
counterY.next();
if (textCounter.hasNext()) {
if (pingCounter.hasNext()) {
// Text and ping are available
set(counterX.get(), counterY.get(), text[textCounter.next()], ping[pingCounter.next()]);
} else {
// Only text is available
setText(counterX.get(), counterY.get(), text[textCounter.next()]);
}
} else if (pingCounter.hasNext()) {
// Only ping is available
setPing(counterX.get(), counterY.get(), ping[pingCounter.next()]);
}
}
}
}