}
*/
// step 3: resolve overlaps; start from top
for (int i=1;i<mProgramItems[col].length; i++) {
ProgramItem curItem = mProgramItems[col][i];
ProgramItem prevItem = mProgramItems[col][i-1];
double minY = prevItem.getY() + prevItem.getHeight();
if (minY > curItem.getY()) {
curItem.setPos(curItem.getX(), minY);
}
}
ProgramItem lastItem = mProgramItems[col][numberOfPrograms-1];
// step 4: go through programs from bottom and move them up if necessary
if (lastItem.getY() + lastItem.getHeight() > mColumnHeight/mZoom) {
lastItem.setPos(lastItem.getX(), mColumnHeight/mZoom - lastItem.getHeight());
for (int i=numberOfPrograms-2;i>=0;i--) {
ProgramItem curItem = mProgramItems[col][i];
ProgramItem nextItem = mProgramItems[col][i+1];
if (curItem.getY()+curItem.getHeight() > nextItem.getY()) {
curItem.setPos(curItem.getX(), nextItem.getY()-curItem.getHeight());
}
else {
break;
}
}
}
// step 5: set the maximum height of each program
for (int i=0;i<mProgramItems[col].length-1; i++) {
ProgramItem curItem = mProgramItems[col][i];
ProgramItem nextItem = mProgramItems[col][i+1];
curItem.setMaximumHeight((int)(nextItem.getY()-curItem.getY()));
}
//Set the max height for the last program of the channel.
lastItem.setMaximumHeight((int)(mColumnHeight/mZoom-lastItem.getY()));
// step 6: Check, if the first program of the column is within the column space.