}
protected XYModel getDedicationChart(List<Stretch> stretches,
ResourceAllocation<?> allocation, BigDecimal taskHours,
BaseCalendar calendar){
XYModel xymodel = new SimpleXYModel();
String title = "hours";
LocalDate previousDate = allocation.getStartDate();
BigDecimal previousPercentage = BigDecimal.ZERO;
xymodel.addValue(title, previousDate.toDateTimeAtStartOfDay()
.getMillis(), 0);
for (Stretch stretch : stretches) {
BigDecimal amountWork = stretch.getAmountWorkPercentage()
.subtract(previousPercentage).multiply(taskHours);
LocalDate endDate = stretch.getDateIn(allocation);
Integer days = Days.daysBetween(previousDate, endDate)
.getDays();
if (calendar != null) {
days -= calendar.getNonWorkableDays(previousDate,
endDate.minusDays(1)).size();
}
BigDecimal hoursPerDay = BigDecimal.ZERO;
if (days > 0) {
hoursPerDay = amountWork.divide(new BigDecimal(days),
RoundingMode.DOWN);
}
xymodel.addValue(title, previousDate.toDateTimeAtStartOfDay()
.getMillis(), hoursPerDay);
if (days > 0) {
xymodel.addValue(title, endDate.toDateTimeAtStartOfDay()
.getMillis() - 1, hoursPerDay);
}
previousDate = endDate;
previousPercentage = stretch.getAmountWorkPercentage();
}
xymodel.addValue(title, previousDate.toDateTimeAtStartOfDay()
.getMillis() + 1, 0);
return xymodel;
}