@Override protected void deviceFrameRect(int x,int y,int width,int height,Color color){
  AffineTransform deviceTransform=getTransform();
  int transformType=deviceTransform.getType();
  boolean usePath=((transformType & (AffineTransform.TYPE_GENERAL_ROTATION | AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
  if (usePath) {
    draw(new Rectangle2D.Float(x,y,width,height));
    return;
  }
  Stroke stroke=getStroke();
  if (stroke instanceof BasicStroke) {
    BasicStroke lineStroke=(BasicStroke)stroke;
    int endCap=lineStroke.getEndCap();
    int lineJoin=lineStroke.getLineJoin();
    if ((endCap == BasicStroke.CAP_SQUARE) && (lineJoin == BasicStroke.JOIN_MITER) && (lineStroke.getMiterLimit() == 10.0f)) {
      float lineWidth=lineStroke.getLineWidth();
      Point2D.Float penSize=new Point2D.Float(lineWidth,lineWidth);
      deviceTransform.deltaTransform(penSize,penSize);
      float deviceLineWidth=Math.min(Math.abs(penSize.x),Math.abs(penSize.y));
      Point2D.Float ul_pos=new Point2D.Float(x,y);
      deviceTransform.transform(ul_pos,ul_pos);
      Point2D.Float lr_pos=new Point2D.Float(x + width,y + height);
      deviceTransform.transform(lr_pos,lr_pos);
      float w=(float)(lr_pos.getX() - ul_pos.getX());
      float h=(float)(lr_pos.getY() - ul_pos.getY());
      WPrinterJob wPrinterJob=(WPrinterJob)getPrinterJob();
      if (wPrinterJob.selectStylePen(endCap,lineJoin,deviceLineWidth,color) == true) {
        wPrinterJob.frameRect((float)ul_pos.getX(),(float)ul_pos.getY(),w,h);
      }
 else {
        double lowerRes=Math.min(wPrinterJob.getXRes(),wPrinterJob.getYRes());
        if ((deviceLineWidth / lowerRes) < MAX_THINLINE_INCHES) {
          wPrinterJob.selectPen(deviceLineWidth,color);
          wPrinterJob.frameRect((float)ul_pos.getX(),(float)ul_pos.getY(),w,h);
        }
 else {
          draw(new Rectangle2D.Float(x,y,width,height));
        }
      }
    }
 else {
      draw(new Rectangle2D.Float(x,y,width,height));
    }
  }
}

@ Override protected void deviceFrameRect ( int x , int y , int width , int height , Color color ) { AffineTransform deviceTransform = getTransform ( ) ; int transformType = deviceTransform . getType ( ) ; boolean usePath = ( ( transformType & ( AffineTransform . TYPE_GENERAL_ROTATION | AffineTransform . TYPE_GENERAL_TRANSFORM ) ) != 0 ) ; if ( usePath ) { draw ( new Rectangle2D . Float ( x , y , width , height ) ) ; return ; } Stroke stroke = getStroke ( ) ; if ( stroke instanceof BasicStroke ) { BasicStroke lineStroke = ( BasicStroke ) stroke ; int endCap = lineStroke . getEndCap ( ) ; int lineJoin = lineStroke . getLineJoin ( ) ; if ( ( endCap == BasicStroke . CAP_SQUARE ) && ( lineJoin == BasicStroke . JOIN_MITER ) && ( lineStroke . getMiterLimit ( ) == 10.0f ) ) { float lineWidth = lineStroke . getLineWidth ( ) ; Point2D . Float penSize = new Point2D . Float ( lineWidth , lineWidth ) ; deviceTransform . deltaTransform ( penSize , penSize ) ; float deviceLineWidth = Math . min ( Math . abs ( penSize . x ) , Math . abs ( penSize . y ) ) ; Point2D . Float ul_pos = new Point2D . Float ( x , y ) ; deviceTransform . transform ( ul_pos , ul_pos ) ; Point2D . Float lr_pos = new Point2D . Float ( x + width , y + height ) ; deviceTransform . transform ( lr_pos , lr_pos ) ; float w = ( float ) ( lr_pos . getX ( ) - ul_pos . getX ( ) ) ; float h = ( float ) ( lr_pos . getY ( ) - ul_pos . getY ( ) ) ; WPrinterJob wPrinterJob = ( WPrinterJob ) getPrinterJob ( ) ; if ( wPrinterJob . selectStylePen ( endCap , lineJoin , deviceLineWidth , color ) == true ) { wPrinterJob . frameRect ( ( float ) ul_pos . getX ( ) , ( float ) ul_pos . getY ( ) , w , h ) ; } else { double lowerRes = Math . min ( wPrinterJob . getXRes ( ) , wPrinterJob . getYRes ( ) ) ; if ( ( deviceLineWidth / lowerRes ) < MAX_THINLINE_INCHES ) { wPrinterJob . selectPen ( deviceLineWidth , color ) ; wPrinterJob . frameRect ( ( float ) ul_pos . getX ( ) , ( float ) ul_pos . getY ( ) , w , h ) ; } else { draw ( new Rectangle2D . Float ( x , y , width , height ) ) ; } } } else { draw ( new Rectangle2D . Float ( x , y , width , height ) ) ; } } }
draw the bounding rectangle using transformed coordinates .
