@Override public void drawItem(Graphics2D g2,XYItemRendererState state,Rectangle2D dataArea,PlotRenderingInfo info,XYPlot plot,ValueAxis domainAxis,ValueAxis rangeAxis,XYDataset dataset,int series,int item,CrosshairState crosshairState,int pass){
  if (!getItemVisible(series,item)) {
    return;
  }
  PlotOrientation orientation=plot.getOrientation();
  Paint seriesPaint=getItemPaint(series,item);
  Stroke seriesStroke=getItemStroke(series,item);
  g2.setPaint(seriesPaint);
  g2.setStroke(seriesStroke);
  double x1=dataset.getXValue(series,item);
  double y1=dataset.getYValue(series,item);
  RectangleEdge xAxisLocation=plot.getDomainAxisEdge();
  RectangleEdge yAxisLocation=plot.getRangeAxisEdge();
  double transX1=domainAxis.valueToJava2D(x1,dataArea,xAxisLocation);
  double transY1=(Double.isNaN(y1) ? Double.NaN : rangeAxis.valueToJava2D(y1,dataArea,yAxisLocation));
  if (pass == 0 && item > 0) {
    double x0=dataset.getXValue(series,item - 1);
    double y0=dataset.getYValue(series,item - 1);
    double transX0=domainAxis.valueToJava2D(x0,dataArea,xAxisLocation);
    double transY0=(Double.isNaN(y0) ? Double.NaN : rangeAxis.valueToJava2D(y0,dataArea,yAxisLocation));
    if (orientation == PlotOrientation.HORIZONTAL) {
      if (transY0 == transY1) {
        drawLine(g2,state.workingLine,transY0,transX0,transY1,transX1,dataArea);
      }
 else {
        double transXs=transX0 + (getStepPoint() * (transX1 - transX0));
        drawLine(g2,state.workingLine,transY0,transX0,transY0,transXs,dataArea);
        drawLine(g2,state.workingLine,transY0,transXs,transY1,transXs,dataArea);
        drawLine(g2,state.workingLine,transY1,transXs,transY1,transX1,dataArea);
      }
    }
 else     if (orientation == PlotOrientation.VERTICAL) {
      if (transY0 == transY1) {
        drawLine(g2,state.workingLine,transX0,transY0,transX1,transY1,dataArea);
      }
 else {
        double transXs=transX0 + (getStepPoint() * (transX1 - transX0));
        drawLine(g2,state.workingLine,transX0,transY0,transXs,transY0,dataArea);
        drawLine(g2,state.workingLine,transXs,transY0,transXs,transY1,dataArea);
        drawLine(g2,state.workingLine,transXs,transY1,transX1,transY1,dataArea);
      }
    }
    int domainAxisIndex=plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex=plot.getRangeAxisIndex(rangeAxis);
    updateCrosshairValues(crosshairState,x1,y1,domainAxisIndex,rangeAxisIndex,transX1,transY1,orientation);
    EntityCollection entities=state.getEntityCollection();
    if (entities != null) {
      addEntity(entities,null,dataset,series,item,transX1,transY1);
    }
  }
  if (pass == 1) {
    if (isItemLabelVisible(series,item)) {
      double xx=transX1;
      double yy=transY1;
      if (orientation == PlotOrientation.HORIZONTAL) {
        xx=transY1;
        yy=transX1;
      }
      drawItemLabel(g2,orientation,dataset,series,item,xx,yy,(y1 < 0.0));
    }
  }
}

@ Override public void drawItem ( Graphics2D g2 , XYItemRendererState state , Rectangle2D dataArea , PlotRenderingInfo info , XYPlot plot , ValueAxis domainAxis , ValueAxis rangeAxis , XYDataset dataset , int series , int item , CrosshairState crosshairState , int pass ) { if ( ! getItemVisible ( series , item ) ) { return ; } PlotOrientation orientation = plot . getOrientation ( ) ; Paint seriesPaint = getItemPaint ( series , item ) ; Stroke seriesStroke = getItemStroke ( series , item ) ; g2 . setPaint ( seriesPaint ) ; g2 . setStroke ( seriesStroke ) ; double x1 = dataset . getXValue ( series , item ) ; double y1 = dataset . getYValue ( series , item ) ; RectangleEdge xAxisLocation = plot . getDomainAxisEdge ( ) ; RectangleEdge yAxisLocation = plot . getRangeAxisEdge ( ) ; double transX1 = domainAxis . valueToJava2D ( x1 , dataArea , xAxisLocation ) ; double transY1 = ( Double . isNaN ( y1 ) ? Double . NaN : rangeAxis . valueToJava2D ( y1 , dataArea , yAxisLocation ) ) ; if ( pass == 0 && item > 0 ) { double x0 = dataset . getXValue ( series , item - 1 ) ; double y0 = dataset . getYValue ( series , item - 1 ) ; double transX0 = domainAxis . valueToJava2D ( x0 , dataArea , xAxisLocation ) ; double transY0 = ( Double . isNaN ( y0 ) ? Double . NaN : rangeAxis . valueToJava2D ( y0 , dataArea , yAxisLocation ) ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { if ( transY0 == transY1 ) { drawLine ( g2 , state . workingLine , transY0 , transX0 , transY1 , transX1 , dataArea ) ; } else { double transXs = transX0 + ( getStepPoint ( ) * ( transX1 - transX0 ) ) ; drawLine ( g2 , state . workingLine , transY0 , transX0 , transY0 , transXs , dataArea ) ; drawLine ( g2 , state . workingLine , transY0 , transXs , transY1 , transXs , dataArea ) ; drawLine ( g2 , state . workingLine , transY1 , transXs , transY1 , transX1 , dataArea ) ; } } else if ( orientation == PlotOrientation . VERTICAL ) { if ( transY0 == transY1 ) { drawLine ( g2 , state . workingLine , transX0 , transY0 , transX1 , transY1 , dataArea ) ; } else { double transXs = transX0 + ( getStepPoint ( ) * ( transX1 - transX0 ) ) ; drawLine ( g2 , state . workingLine , transX0 , transY0 , transXs , transY0 , dataArea ) ; drawLine ( g2 , state . workingLine , transXs , transY0 , transXs , transY1 , dataArea ) ; drawLine ( g2 , state . workingLine , transXs , transY1 , transX1 , transY1 , dataArea ) ; } } int domainAxisIndex = plot . getDomainAxisIndex ( domainAxis ) ; int rangeAxisIndex = plot . getRangeAxisIndex ( rangeAxis ) ; updateCrosshairValues ( crosshairState , x1 , y1 , domainAxisIndex , rangeAxisIndex , transX1 , transY1 , orientation ) ; EntityCollection entities = state . getEntityCollection ( ) ; if ( entities != null ) { addEntity ( entities , null , dataset , series , item , transX1 , transY1 ) ; } } if ( pass == 1 ) { if ( isItemLabelVisible ( series , item ) ) { double xx = transX1 ; double yy = transY1 ; if ( orientation == PlotOrientation . HORIZONTAL ) { xx = transY1 ; yy = transX1 ; } drawItemLabel ( g2 , orientation , dataset , series , item , xx , yy , ( y1 < 0.0 ) ) ; } } }
draws the visual representation of a single data item .
