if (!menuItem.isArmed() && (isMarked || isOnAir || mTime != -1)) {
g.setColor(Color.white);
g.fillRect(x, top, menuItem.getWidth(), bottom);
}
Color markedColor = Plugin.getPluginManager().getTvBrowserSettings().getColorForMarkingPriority(
mProgram.getMarkPriority());
if (isMarked) {
if (markedColor != null) {
g.setColor(markedColor);
}
g.fillRect(x, top, menuItem.getWidth(), bottom);
}
if (isOnAir || mTime != -1) {
int minutesAfterMidnight = mTime != -1 ? mTime : IOUtilities.getMinutesAfterMidnight();
int progLength = mProgram.getLength();
int startTime = mProgram.getHours() * 60 + mProgram.getMinutes();
int elapsedMinutes;
if (minutesAfterMidnight < startTime) {
// The next day has begun -> we have to add 24 * 60 minutes
// Example: Start time was 23:50 = 1430 minutes after midnight
// now it is 0:03 = 3 minutes after midnight
// elapsedMinutes = (24 * 60) + 3 - 1430 = 13 minutes
elapsedMinutes = (24 * 60) + minutesAfterMidnight - startTime;
} else {
elapsedMinutes = minutesAfterMidnight - startTime;
}
int progressX = 0;
if (progLength > 0) {
progressX = elapsedMinutes * (width - i.left - i.right) / progLength;
}
if (!isMarked) {
g.setColor(mTime == -1 ? Settings.propProgramTableColorOnAirLight.getColor()
: Settings.propTrayOnTimeProgramsLightBackground.getColor());
g.fillRect(x + progressX - i.right - i.left, top, width - progressX + i.right + i.left, bottom);
}
g.setColor(mTime == -1 ? Settings.propProgramTableColorOnAirDark.getColor() : isMarked ? new Color(markedColor
.darker().getRed(), markedColor.darker().getGreen(), markedColor.darker().getBlue(), (markedColor
.darker().getAlpha() / 3)) : Settings.propTrayOnTimeProgramsDarkBackground.getColor());
g.fillRect(x, top, progressX - i.right - i.left, bottom);
} else if (mProgram.isExpired()) {
((ProgramMenuItem) menuItem).stopTimer();