Program: 178887
Project: 178887
Buggy source:
/** 
 * Draws the plot within the specified area on a graphics device.
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>permitted).
 * @param parentState  the state from the parent plot, if there is one(<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>permitted).
 */
public void draw(Graphics2D g2,Rectangle2D area,Point2D anchor,PlotState parentState,PlotRenderingInfo info){
  boolean b1=(area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
  boolean b2=(area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
  if (b1 || b2) {
    return;
  }
  if (info != null) {
    info.setPlotArea(area);
  }
  RectangleInsets insets=getInsets();
  insets.trim(area);
  AxisSpace space=calculateAxisSpace(g2,area);
  Rectangle2D dataArea=space.shrink(area,null);
  this.axisOffset.trim(dataArea);
  createAndAddEntity((Rectangle2D)dataArea.clone(),info,null,null);
  if (info != null) {
    info.setDataArea(dataArea);
  }
  drawBackground(g2,dataArea);
  Map axisStateMap=drawAxes(g2,area,dataArea,info);
  PlotOrientation orient=getOrientation();
  if (anchor != null && !dataArea.contains(anchor)) {
    anchor=null;
  }
  CrosshairState crosshairState=new CrosshairState();
  crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY);
  crosshairState.setAnchor(anchor);
  crosshairState.setAnchorX(Double.NaN);
  crosshairState.setAnchorY(Double.NaN);
  if (anchor != null) {
    ValueAxis domainAxis=getDomainAxis();
    if (domainAxis != null) {
      double x;
      if (orient == PlotOrientation.VERTICAL) {
        x=domainAxis.java2DToValue(anchor.getX(),dataArea,getDomainAxisEdge());
      }
 else {
        x=domainAxis.java2DToValue(anchor.getY(),dataArea,getDomainAxisEdge());
      }
      crosshairState.setAnchorX(x);
    }
    ValueAxis rangeAxis=getRangeAxis();
    if (rangeAxis != null) {
      double y;
      if (orient == PlotOrientation.VERTICAL) {
        y=rangeAxis.java2DToValue(anchor.getY(),dataArea,getRangeAxisEdge());
      }
 else {
        y=rangeAxis.java2DToValue(anchor.getX(),dataArea,getRangeAxisEdge());
      }
      crosshairState.setAnchorY(y);
    }
  }
  crosshairState.setCrosshairX(getDomainCrosshairValue());
  crosshairState.setCrosshairY(getRangeCrosshairValue());
  Shape originalClip=g2.getClip();
  Composite originalComposite=g2.getComposite();
  g2.clip(dataArea);
  g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,getForegroundAlpha()));
  AxisState domainAxisState=(AxisState)axisStateMap.get(getDomainAxis());
  if (domainAxisState == null) {
    if (parentState != null) {
      domainAxisState=(AxisState)parentState.getSharedAxisStates().get(getDomainAxis());
    }
  }
  AxisState rangeAxisState=(AxisState)axisStateMap.get(getRangeAxis());
  if (rangeAxisState == null) {
    if (parentState != null) {
      rangeAxisState=(AxisState)parentState.getSharedAxisStates().get(getRangeAxis());
    }
  }
  if (domainAxisState != null) {
    drawDomainTickBands(g2,dataArea,domainAxisState.getTicks());
  }
  if (rangeAxisState != null) {
    drawRangeTickBands(g2,dataArea,rangeAxisState.getTicks());
  }
  if (domainAxisState != null) {
    drawDomainGridlines(g2,dataArea,domainAxisState.getTicks());
    drawZeroDomainBaseline(g2,dataArea);
  }
  if (rangeAxisState != null) {
    drawRangeGridlines(g2,dataArea,rangeAxisState.getTicks());
    drawZeroRangeBaseline(g2,dataArea);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawDomainMarkers(g2,dataArea,i,Layer.BACKGROUND);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawRangeMarkers(g2,dataArea,i,Layer.BACKGROUND);
  }
  boolean foundData=false;
  DatasetRenderingOrder order=getDatasetRenderingOrder();
  if (order == DatasetRenderingOrder.FORWARD) {
    int rendererCount=this.renderers.size();
    for (int i=0; i < rendererCount; i++) {
      XYItemRenderer r=getRenderer(i);
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.BACKGROUND,info);
      }
    }
    for (int i=0; i < getDatasetCount(); i++) {
      foundData=render(g2,dataArea,i,info,crosshairState) || foundData;
    }
    for (int i=0; i < rendererCount; i++) {
      XYItemRenderer r=getRenderer(i);
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.FOREGROUND,info);
      }
    }
  }
 else   if (order == DatasetRenderingOrder.REVERSE) {
    int rendererCount=this.renderers.size();
    for (int i=rendererCount - 1; i >= 0; i--) {
      XYItemRenderer r=getRenderer(i);
      if (i >= getDatasetCount()) {
        continue;
      }
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.BACKGROUND,info);
      }
    }
    for (int i=getDatasetCount() - 1; i >= 0; i--) {
      foundData=render(g2,dataArea,i,info,crosshairState) || foundData;
    }
    for (int i=rendererCount - 1; i >= 0; i--) {
      XYItemRenderer r=getRenderer(i);
      if (i >= getDatasetCount()) {
        continue;
      }
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.FOREGROUND,info);
      }
    }
  }
  int xAxisIndex=crosshairState.getDomainAxisIndex();
  ValueAxis xAxis=getDomainAxis(xAxisIndex);
  RectangleEdge xAxisEdge=getDomainAxisEdge(xAxisIndex);
  if (!this.domainCrosshairLockedOnData && anchor != null) {
    double xx;
    if (orient == PlotOrientation.VERTICAL) {
      xx=xAxis.java2DToValue(anchor.getX(),dataArea,xAxisEdge);
    }
 else {
      xx=xAxis.java2DToValue(anchor.getY(),dataArea,xAxisEdge);
    }
    crosshairState.setCrosshairX(xx);
  }
  setDomainCrosshairValue(crosshairState.getCrosshairX(),false);
  if (isDomainCrosshairVisible()) {
    double x=getDomainCrosshairValue();
    Paint paint=getDomainCrosshairPaint();
    Stroke stroke=getDomainCrosshairStroke();
    drawDomainCrosshair(g2,dataArea,orient,x,xAxis,stroke,paint);
  }
  int yAxisIndex=crosshairState.getRangeAxisIndex();
  ValueAxis yAxis=getRangeAxis(yAxisIndex);
  RectangleEdge yAxisEdge=getRangeAxisEdge(yAxisIndex);
  if (!this.rangeCrosshairLockedOnData && anchor != null) {
    double yy;
    if (orient == PlotOrientation.VERTICAL) {
      yy=yAxis.java2DToValue(anchor.getY(),dataArea,yAxisEdge);
    }
 else {
      yy=yAxis.java2DToValue(anchor.getX(),dataArea,yAxisEdge);
    }
    crosshairState.setCrosshairY(yy);
  }
  setRangeCrosshairValue(crosshairState.getCrosshairY(),false);
  if (isRangeCrosshairVisible()) {
    double y=getRangeCrosshairValue();
    Paint paint=getRangeCrosshairPaint();
    Stroke stroke=getRangeCrosshairStroke();
    drawRangeCrosshair(g2,dataArea,orient,y,yAxis,stroke,paint);
  }
  if (!foundData) {
    drawNoDataMessage(g2,dataArea);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawDomainMarkers(g2,dataArea,i,Layer.FOREGROUND);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawRangeMarkers(g2,dataArea,i,Layer.FOREGROUND);
  }
  drawAnnotations(g2,dataArea,info);
  g2.setClip(originalClip);
  g2.setComposite(originalComposite);
  drawOutline(g2,dataArea);
}

Fixed version (ground truth):
/** 
 * Draws the plot within the specified area on a graphics device.
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>permitted).
 * @param parentState  the state from the parent plot, if there is one(<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>permitted).
 */
public void draw(Graphics2D g2,Rectangle2D area,Point2D anchor,PlotState parentState,PlotRenderingInfo info){
  boolean b1=(area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
  boolean b2=(area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
  if (b1 || b2) {
    return;
  }
  setFireChangeEvents(false);
  if (info != null) {
    info.setPlotArea(area);
  }
  RectangleInsets insets=getInsets();
  insets.trim(area);
  AxisSpace space=calculateAxisSpace(g2,area);
  Rectangle2D dataArea=space.shrink(area,null);
  this.axisOffset.trim(dataArea);
  createAndAddEntity((Rectangle2D)dataArea.clone(),info,null,null);
  if (info != null) {
    info.setDataArea(dataArea);
  }
  drawBackground(g2,dataArea);
  Map axisStateMap=drawAxes(g2,area,dataArea,info);
  PlotOrientation orient=getOrientation();
  if (anchor != null && !dataArea.contains(anchor)) {
    anchor=null;
  }
  CrosshairState crosshairState=new CrosshairState();
  crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY);
  crosshairState.setAnchor(anchor);
  crosshairState.setAnchorX(Double.NaN);
  crosshairState.setAnchorY(Double.NaN);
  if (anchor != null) {
    ValueAxis domainAxis=getDomainAxis();
    if (domainAxis != null) {
      double x;
      if (orient == PlotOrientation.VERTICAL) {
        x=domainAxis.java2DToValue(anchor.getX(),dataArea,getDomainAxisEdge());
      }
 else {
        x=domainAxis.java2DToValue(anchor.getY(),dataArea,getDomainAxisEdge());
      }
      crosshairState.setAnchorX(x);
    }
    ValueAxis rangeAxis=getRangeAxis();
    if (rangeAxis != null) {
      double y;
      if (orient == PlotOrientation.VERTICAL) {
        y=rangeAxis.java2DToValue(anchor.getY(),dataArea,getRangeAxisEdge());
      }
 else {
        y=rangeAxis.java2DToValue(anchor.getX(),dataArea,getRangeAxisEdge());
      }
      crosshairState.setAnchorY(y);
    }
  }
  crosshairState.setCrosshairX(getDomainCrosshairValue());
  crosshairState.setCrosshairY(getRangeCrosshairValue());
  Shape originalClip=g2.getClip();
  Composite originalComposite=g2.getComposite();
  g2.clip(dataArea);
  g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,getForegroundAlpha()));
  AxisState domainAxisState=(AxisState)axisStateMap.get(getDomainAxis());
  if (domainAxisState == null) {
    if (parentState != null) {
      domainAxisState=(AxisState)parentState.getSharedAxisStates().get(getDomainAxis());
    }
  }
  AxisState rangeAxisState=(AxisState)axisStateMap.get(getRangeAxis());
  if (rangeAxisState == null) {
    if (parentState != null) {
      rangeAxisState=(AxisState)parentState.getSharedAxisStates().get(getRangeAxis());
    }
  }
  if (domainAxisState != null) {
    drawDomainTickBands(g2,dataArea,domainAxisState.getTicks());
  }
  if (rangeAxisState != null) {
    drawRangeTickBands(g2,dataArea,rangeAxisState.getTicks());
  }
  if (domainAxisState != null) {
    drawDomainGridlines(g2,dataArea,domainAxisState.getTicks());
    drawZeroDomainBaseline(g2,dataArea);
  }
  if (rangeAxisState != null) {
    drawRangeGridlines(g2,dataArea,rangeAxisState.getTicks());
    drawZeroRangeBaseline(g2,dataArea);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawDomainMarkers(g2,dataArea,i,Layer.BACKGROUND);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawRangeMarkers(g2,dataArea,i,Layer.BACKGROUND);
  }
  boolean foundData=false;
  DatasetRenderingOrder order=getDatasetRenderingOrder();
  if (order == DatasetRenderingOrder.FORWARD) {
    int rendererCount=this.renderers.size();
    for (int i=0; i < rendererCount; i++) {
      XYItemRenderer r=getRenderer(i);
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.BACKGROUND,info);
      }
    }
    for (int i=0; i < getDatasetCount(); i++) {
      foundData=render(g2,dataArea,i,info,crosshairState) || foundData;
    }
    for (int i=0; i < rendererCount; i++) {
      XYItemRenderer r=getRenderer(i);
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.FOREGROUND,info);
      }
    }
  }
 else   if (order == DatasetRenderingOrder.REVERSE) {
    int rendererCount=this.renderers.size();
    for (int i=rendererCount - 1; i >= 0; i--) {
      XYItemRenderer r=getRenderer(i);
      if (i >= getDatasetCount()) {
        continue;
      }
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.BACKGROUND,info);
      }
    }
    for (int i=getDatasetCount() - 1; i >= 0; i--) {
      foundData=render(g2,dataArea,i,info,crosshairState) || foundData;
    }
    for (int i=rendererCount - 1; i >= 0; i--) {
      XYItemRenderer r=getRenderer(i);
      if (i >= getDatasetCount()) {
        continue;
      }
      if (r != null) {
        ValueAxis domainAxis=getDomainAxisForDataset(i);
        ValueAxis rangeAxis=getRangeAxisForDataset(i);
        r.drawAnnotations(g2,dataArea,domainAxis,rangeAxis,Layer.FOREGROUND,info);
      }
    }
  }
  int xAxisIndex=crosshairState.getDomainAxisIndex();
  ValueAxis xAxis=getDomainAxis(xAxisIndex);
  RectangleEdge xAxisEdge=getDomainAxisEdge(xAxisIndex);
  if (!this.domainCrosshairLockedOnData && anchor != null) {
    double xx;
    if (orient == PlotOrientation.VERTICAL) {
      xx=xAxis.java2DToValue(anchor.getX(),dataArea,xAxisEdge);
    }
 else {
      xx=xAxis.java2DToValue(anchor.getY(),dataArea,xAxisEdge);
    }
    crosshairState.setCrosshairX(xx);
  }
  setDomainCrosshairValue(crosshairState.getCrosshairX(),false);
  if (isDomainCrosshairVisible()) {
    double x=getDomainCrosshairValue();
    Paint paint=getDomainCrosshairPaint();
    Stroke stroke=getDomainCrosshairStroke();
    drawDomainCrosshair(g2,dataArea,orient,x,xAxis,stroke,paint);
  }
  int yAxisIndex=crosshairState.getRangeAxisIndex();
  ValueAxis yAxis=getRangeAxis(yAxisIndex);
  RectangleEdge yAxisEdge=getRangeAxisEdge(yAxisIndex);
  if (!this.rangeCrosshairLockedOnData && anchor != null) {
    double yy;
    if (orient == PlotOrientation.VERTICAL) {
      yy=yAxis.java2DToValue(anchor.getY(),dataArea,yAxisEdge);
    }
 else {
      yy=yAxis.java2DToValue(anchor.getX(),dataArea,yAxisEdge);
    }
    crosshairState.setCrosshairY(yy);
  }
  setRangeCrosshairValue(crosshairState.getCrosshairY(),false);
  if (isRangeCrosshairVisible()) {
    double y=getRangeCrosshairValue();
    Paint paint=getRangeCrosshairPaint();
    Stroke stroke=getRangeCrosshairStroke();
    drawRangeCrosshair(g2,dataArea,orient,y,yAxis,stroke,paint);
  }
  if (!foundData) {
    drawNoDataMessage(g2,dataArea);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawDomainMarkers(g2,dataArea,i,Layer.FOREGROUND);
  }
  for (int i=0; i < this.renderers.size(); i++) {
    drawRangeMarkers(g2,dataArea,i,Layer.FOREGROUND);
  }
  drawAnnotations(g2,dataArea,info);
  g2.setClip(originalClip);
  g2.setComposite(originalComposite);
  drawOutline(g2,dataArea);
  setFireChangeEvents(true);
}