int trackX = 0;
int trackY = 0;
for (Iterator<TrackGroup> groupIter = groups.iterator(); groupIter.hasNext(); ) {
TrackGroup group = groupIter.next();
if (visibleRect != null && (trackY > visibleRect.y + visibleRect.height)) {
break;
}
if (group.isVisible()) {
if (groups.size() > 1) {
final Graphics2D greyGraphics = context.getGraphic2DForColor(UIConstants.LIGHT_GREY);
greyGraphics.fillRect(0, trackY + 1, width, UIConstants.groupGap - 1);
trackY += UIConstants.groupGap;
}
// Draw a line just above group.
if (group.isDrawBorder()) {
Graphics2D graphics2D = context.getGraphic2DForColor(Color.black);
graphics2D.drawLine(0, trackY - 1, width, trackY - 1);
}
List<Track> trackList = group.getTracks();
synchronized (trackList) {
for (Track track : trackList) {
if (track == null) continue;
int trackHeight = track.getHeight();
if (visibleRect != null) {
if (trackY > visibleRect.y + visibleRect.height) {
break;
} else if (trackY + trackHeight < visibleRect.y) {
if (track.isVisible()) {
trackY += trackHeight;
}
continue;
}
}
if (track.isVisible()) {
Rectangle rect = new Rectangle(trackX, trackY, width, trackHeight);
draw(track, rect, context);
trackY += trackHeight;
}
}
}
// Draw a line just below group.
if (group.isDrawBorder()) {
Graphics2D graphics2D = context.getGraphic2DForColor(Color.black);
graphics2D.drawLine(0, trackY, width, trackY);
}
}
}