if (pageInfo != null) { extents = new Rectangle(0, 0, (int) pageInfo.getContentWidth(), (int) pageInfo.getContentHeight()); } else if (enclosingScrollPane != null) { Rectangle bnds = enclosingScrollPane.getViewportBorderBounds(); extents = new Rectangle(0, 0, bnds.width, bnds.height);  } else { extents = new Rectangle(getWidth(), getHeight()); }
extents = getBaseExtents(pageInfo);
    protected RenderingContext newRenderingContext(PageInfo pageInfo, Graphics2D g) {        XRLog.layout(Level.FINEST, "new context begin");        getSharedContext().setCanvas(this);        Rectangle extents;        if (pageInfo != null) {            extents = new Rectangle(0, 0,                    (int) pageInfo.getContentWidth(), (int) pageInfo.getContentHeight());        } else if (enclosingScrollPane != null) {            Rectangle bnds = enclosingScrollPane.getViewportBorderBounds();            extents = new Rectangle(0, 0, bnds.width, bnds.height);            //Uu.p("bnds = " + bnds);        } else {            extents = new Rectangle(getWidth(), getHeight());//200, 200 ) );        }        //Uu.p("newContext() = extents = " + extents);        getSharedContext().setMaxWidth(0);        //getSharedContext().setMaxHeight(0);        XRLog.layout(Level.FINEST, "new context end");        //Uu.p("new context with extents: " + extents);                RenderingContext result = getSharedContext().newRenderingContextInstance(extents);        result.setGraphics(g);        result.setPrint(pageInfo != null);        result.setInteractive(pageInfo == null);        return result;    }