public void consumeInterval(ScheduleInterval interval){
// System.out.println("GanttUI consuming interval " + new java.util.Date(interval.getStart()) + " " + new java.util.Date(interval.getEnd()));
// if (interval.getEnd() < interval.getStart())
// return;
CoordinatesConverter coord=((GanttParams)graphInfo).getCoord();
if (interval.getEnd()>100000000000000L){
// this hasn't happened in years. whatever caused it is fixed, but keeping just in case
System.out.println("ERROR!!! leads to OutOfMemoryError, consumeInterval interval="+interval.getStart()+", "+CalendarUtil.toString(interval.getStart())+", "+interval.getEnd()+", "+CalendarUtil.toString(interval.getEnd())+"...");
return;
}
double x=coord.toX(interval.getStart());
double width=CoordinatesConverter.adaptSmallBarEndX(x,coord.toX(interval.getEnd()),node,config)-x;
// double width=coord.toW(interval.getEnd()-interval.getStart());
double height;
double y=yrow+config.getGanttBarYOffset();
int row=format.getRow();
if (row==1){
height=config.getGanttBarHeight();
}
else{
height=config.getBaselineHeight();
y+=config.getGanttBarHeight()+config.getBaselineHeight()*(row-2);
}
y+=height/2;
double dw=height;
if (format.getMiddle()!=null){
if (g2==null&&format.isMain()){
Shape shape=format.getMiddle().toGeneralPath(
width,
height,
x,
y,
null);
Rectangle2D bounds=shape.getBounds2D();
node.setGanttShapeOffset(bounds.getY()-y+height/2);
node.setGanttShapeHeight(bounds.getHeight());
}else{
Shape shape=format.getMiddle().draw(g2,
width,
height,
x,
y,
useTextures());
}
// draw middle before ends
}
if (g2==null) return;
if (format.getStart()!=null) format.getStart().draw(g2,
dw,
height,
x ,
y,
useTextures());
if (format.getEnd()!=null) format.getEnd().draw(g2,
dw,
height,
x+width,
y,
useTextures()); //TODO case when no start symbol
//TODO style and format of completion should be treated with bar prefererences instead of a special case
if (format.isMain()&&!node.isSummary()&&node.isStarted()){
long completedT=node.getCompleted();
if (completedT>=interval.getStart()){
double completedW=coord.toX(completedT)-x;
if (completedW>width && !GanttOption.getInstance().isCompletionIsContiguous())
completedW=width;
completedW=CoordinatesConverter.adaptSmallBarEndX(x, x+completedW, node,config)-x;
Rectangle2D progressBar=new Rectangle2D.Double(x,y-config.getGanttProgressBarHeight()/2,completedW,config.getGanttProgressBarHeight());
g2.setColor(Color.BLACK);