protected void validatePaper(Paper origPaper,Paper newPaper){
  if (origPaper == null || newPaper == null) {
    return;
  }
 else {
    double wid=origPaper.getWidth();
    double hgt=origPaper.getHeight();
    double ix=origPaper.getImageableX();
    double iy=origPaper.getImageableY();
    double iw=origPaper.getImageableWidth();
    double ih=origPaper.getImageableHeight();
    Paper defaultPaper=new Paper();
    wid=((wid > 0.0) ? wid : defaultPaper.getWidth());
    hgt=((hgt > 0.0) ? hgt : defaultPaper.getHeight());
    ix=((ix > 0.0) ? ix : defaultPaper.getImageableX());
    iy=((iy > 0.0) ? iy : defaultPaper.getImageableY());
    iw=((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
    ih=((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
    if (iw > wid) {
      iw=wid;
    }
    if (ih > hgt) {
      ih=hgt;
    }
    if ((ix + iw) > wid) {
      ix=wid - iw;
    }
    if ((iy + ih) > hgt) {
      iy=hgt - ih;
    }
    newPaper.setSize(wid,hgt);
    newPaper.setImageableArea(ix,iy,iw,ih);
  }
}

protected void validatePaper ( Paper origPaper , Paper newPaper ) { if ( origPaper == null || newPaper == null ) { return ; } else { double wid = origPaper . getWidth ( ) ; double hgt = origPaper . getHeight ( ) ; double ix = origPaper . getImageableX ( ) ; double iy = origPaper . getImageableY ( ) ; double iw = origPaper . getImageableWidth ( ) ; double ih = origPaper . getImageableHeight ( ) ; Paper defaultPaper = new Paper ( ) ; wid = ( ( wid > 0.0 ) ? wid : defaultPaper . getWidth ( ) ) ; hgt = ( ( hgt > 0.0 ) ? hgt : defaultPaper . getHeight ( ) ) ; ix = ( ( ix > 0.0 ) ? ix : defaultPaper . getImageableX ( ) ) ; iy = ( ( iy > 0.0 ) ? iy : defaultPaper . getImageableY ( ) ) ; iw = ( ( iw > 0.0 ) ? iw : defaultPaper . getImageableWidth ( ) ) ; ih = ( ( ih > 0.0 ) ? ih : defaultPaper . getImageableHeight ( ) ) ; if ( iw > wid ) { iw = wid ; } if ( ih > hgt ) { ih = hgt ; } if ( ( ix + iw ) > wid ) { ix = wid - iw ; } if ( ( iy + ih ) > hgt ) { iy = hgt - ih ; } newPaper . setSize ( wid , hgt ) ; newPaper . setImageableArea ( ix , iy , iw , ih ) ; } }
updates a paper object to reflect the current printer ' s selected paper size and imageable area for that paper size . default implementation copies settings from the original , applies applies some validity checks , changes them only if they are clearly unreasonable , then sets them into the new paper . subclasses are expected to override this method to make more informed decisons .
