private void drawZoomRectangle(Graphics2D g2,boolean xor){
  if (this.zoomRectangle != null) {
    if (xor) {
      g2.setXORMode(Color.gray);
    }
    if (this.fillZoomRectangle) {
      g2.setPaint(this.zoomFillPaint);
      g2.fill(this.zoomRectangle);
    }
 else {
      g2.setPaint(this.zoomOutlinePaint);
      g2.draw(this.zoomRectangle);
    }
    if (xor) {
      g2.setPaintMode();
    }
  }
}

private void drawZoomRectangle ( Graphics2D g2 , boolean xor ) { if ( this . zoomRectangle != null ) { if ( xor ) { g2 . setXORMode ( Color . gray ) ; } if ( this . fillZoomRectangle ) { g2 . setPaint ( this . zoomFillPaint ) ; g2 . fill ( this . zoomRectangle ) ; } else { g2 . setPaint ( this . zoomOutlinePaint ) ; g2 . draw ( this . zoomRectangle ) ; } if ( xor ) { g2 . setPaintMode ( ) ; } } }
draws zoom rectangle ( if present ) . the drawing is performed in xor mode , therefore when this method is called twice in a row , the second call will completely restore the state of the canvas .
