ArrayList result = new ArrayList();
int totalFramesWidth = 0;
Date currentDate = myStartDate;
do {
TimeFrame currentFrame = myTimeUnitStack.createTimeFrame(
currentDate, getTopUnit(currentDate), myBottomUnit);
if (exactDate != null
&& currentFrame.getStartDate().before(exactDate)) {
currentFrame.trimLeft(exactDate);
}
if (currentFrame.getStartDate().after(currentFrame.getFinishDate())) {
throw new IllegalStateException("Frame is invalid:\n"+currentFrame+"\n date="+exactDate);
}
result.add(currentFrame);
int frameWidth = myFrameWidthFunction
.getTimeFrameWidth(currentFrame);
totalFramesWidth += frameWidth;
currentDate = currentFrame.getFinishDate();
} while (totalFramesWidth <= getBounds().getWidth());
//
return (TimeFrame[]) result.toArray(new TimeFrame[0]);
}