int monthOfYear = day.getMonthOfYear();
if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
monthOfYear = event.getGanttDiagramEventMonth();
}
int year = day.getYear();
YearMonthDay yearMonthDay = new YearMonthDay(year, monthOfYear, 1);
isEventToMarkWeekendsAndHolidays = event.isGanttDiagramEventToMarkWeekendsAndHolidays();
if (!isEventToMarkWeekendsAndHolidays) {
builder.append("<td style=\"width: ").append(convertToEm(numberOfUnits))
.append("em;\"><div style=\"position: relative;\">");
}
if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
if (dayOfMonth > yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
addEmptyDiv(builder);
builder.append("</div></td>");
continue;
}
}
specialDiv = false;
for (Interval interval : event.getGanttDiagramEventSortedIntervals()) {
toWrite = null;
toMark = true;
LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
if ((event.getGanttDiagramEventDayType(interval) == DayType.SPECIFIC_DAYS)
|| (event.getGanttDiagramEventDayType(interval) == DayType.WORKDAY)) {
if ((localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME)
|| (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) || (Holiday.isHoliday(localDate))) {
toMark = false;
}
}
if (isEventToMarkWeekendsAndHolidays) {
if (Holiday.isHoliday(localDate)) {
toWrite = F;
} else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
toWrite = S;
} else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {
toWrite = D;
}
}
if (interval.getStart().getYear() <= year && interval.getEnd().getYear() >= year) {
if (interval.getStart().getYear() < year && interval.getEnd().getYear() > year) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
}
// Started in same year and Ended after
else if (interval.getStart().getYear() == year && interval.getEnd().getYear() > year) {
if (interval.getStart().getMonthOfYear() < monthOfYear) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
} else if (interval.getStart().getMonthOfYear() == monthOfYear) {
if (interval.getStart().getDayOfMonth() == dayOfMonth) {
startIndex = calculateTimeOfDay(interval.getStart());
addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
convertToEm(startIndex - 1));
} else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
}
}
}
// Ended in same year and started before
else if (interval.getStart().getYear() < year && interval.getEnd().getYear() == year) {
if (interval.getEnd().getMonthOfYear() > monthOfYear) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
} else if (interval.getEnd().getMonthOfYear() == monthOfYear) {
if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
} else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
endIndex = calculateTimeOfDay(interval.getEnd());
addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
}
}
}
// Ended and Started In Same Year
else if (interval.getStart().getYear() == year && interval.getEnd().getYear() == year) {
if (interval.getStart().getMonthOfYear() <= monthOfYear
&& interval.getEnd().getMonthOfYear() >= monthOfYear) {
if (interval.getStart().getMonthOfYear() == monthOfYear
&& interval.getEnd().getMonthOfYear() > monthOfYear) {
if (interval.getStart().getDayOfMonth() == dayOfMonth) {
startIndex = calculateTimeOfDay(interval.getStart());
addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
convertToEm(startIndex - 1));
} else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
}
} else if (interval.getStart().getMonthOfYear() < monthOfYear
&& interval.getEnd().getMonthOfYear() == monthOfYear) {
if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
} else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
endIndex = calculateTimeOfDay(interval.getEnd());
addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
}
} else if (interval.getStart().getMonthOfYear() < monthOfYear
&& interval.getEnd().getMonthOfYear() > monthOfYear) {
addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
} else if (interval.getStart().getMonthOfYear() == monthOfYear
&& interval.getEnd().getMonthOfYear() == monthOfYear) {
if (interval.getStart().getDayOfMonth() <= dayOfMonth
&& interval.getEnd().getDayOfMonth() >= dayOfMonth) {
if (event.isGanttDiagramEventIntervalsLongerThanOneDay()
&& (interval.getStart().getDayOfMonth() == dayOfMonth || interval.getEnd()
.getDayOfMonth() > dayOfMonth)) {
startIndex = calculateTimeOfDay(interval.getStart());
addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
convertToEm(startIndex - 1));
} else if (interval.getStart().getDayOfMonth() == dayOfMonth
&& interval.getEnd().getDayOfMonth() > dayOfMonth) {
startIndex = calculateTimeOfDay(interval.getStart());
addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
convertToEm(startIndex - 1));
}
else if (interval.getStart().getDayOfMonth() < dayOfMonth
&& interval.getEnd().getDayOfMonth() == dayOfMonth) {
endIndex = calculateTimeOfDay(interval.getEnd());
addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
}
else if (interval.getStart().getDayOfMonth() == dayOfMonth
&& interval.getEnd().getDayOfMonth() == dayOfMonth) {
startIndex = calculateTimeOfDay(interval.getStart());
endIndex = calculateTimeOfDay(interval.getEnd());
if (startIndex == endIndex) {
addSpecialDiv(builder, convertToEm(1), convertToEm(startIndex - 1));
} else {
addSpecialDiv(builder, convertToEm((endIndex - startIndex) + 1),
convertToEm(startIndex - 1));
}
}
}
}
}
}
}
}
if (!isEventToMarkWeekendsAndHolidays) {
builder.append("</div></td>");
} else if (!specialDiv) {
builder.append("<td class=\"tdnomark\">");
if (dayOfMonth <= yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
if (Holiday.isHoliday(localDate)) {
builder.append(F);
} else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
builder.append("S");
} else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {