private void paintLayers(RenderingContext c, List layers) { for (int i = 0; i < layers.size(); i++) { Layer layer = (Layer) layers.get(i); layer.paint(c); } }
private void paintLayers(RenderingContext c, List layers) { for (int i = 0; i < layers.size(); i++) { Layer layer = (Layer) layers.get(i); layer.paint(c); } }
root.paint(c); } else { paintPagedView(c, root);
root.paint(c); g.translate(-left, -top);
public void paintPage(Graphics2D g, int pageNo) { Layer root = getRootLayer(); if (root == null) { throw new RuntimeException("Document needs layout"); } if (pageNo < 0 || pageNo >= root.getPages().size()) { throw new IllegalArgumentException("Page " + pageNo + " is not between 0 " + "and " + root.getPages().size()); } RenderingContext c = newRenderingContext(g); PageBox page = (PageBox)root.getPages().get(pageNo); c.setPageCount(root.getPages().size()); c.setPage(pageNo, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = g.getClip(); Rectangle content = page.getPrintClippingBounds(c); g.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); g.translate(left, top); root.paint(c); g.translate(-left, -top); g.setClip(working); }
protected void doRender(RenderingContext c) { try { c.getOutputDevice().translate(-_origin.x, -_origin.y); long start = System.currentTimeMillis(); if (c.isPrint()) { paintPagedView(c, _rootBox.getLayer()); } else { _rootBox.getLayer().paint(c); } long after = System.currentTimeMillis(); if (Configuration.isTrue("xr.incremental.repaint.print-timing", false)) { Uu.p("repaint took ms: " + (after - start)); } } catch (Throwable e) { XRLog.exception(e.getMessage(), e); } ((SWTOutputDevice) c.getOutputDevice()).clean(); }
root.paint(c); } else { paintPagedView(c, root);
public void paintMarginAreas(RenderingContext c, int additionalClearance, short mode) { for (int i = 0; i < MARGIN_AREA_DEFS.length; i++) { MarginAreaContainer container = _marginAreas[i]; if (container != null) { TableBox table = _marginAreas[i].getTable(); Point p = container.getArea().getPaintingPosition( c, this, additionalClearance, mode); c.getOutputDevice().translate(p.x, p.y); table.getLayer().paint(c); c.getOutputDevice().translate(-p.x, -p.y); } } }
root.paint(c); g.translate(-left, -top);
public void paintMarginAreas(RenderingContext c, int additionalClearance, short mode) { for (int i = 0; i < MARGIN_AREA_DEFS.length; i++) { MarginAreaContainer container = _marginAreas[i]; if (container != null) { TableBox table = _marginAreas[i].getTable(); Point p = container.getArea().getPaintingPosition( c, this, additionalClearance, mode); c.getOutputDevice().translate(p.x, p.y); table.getLayer().paint(c); c.getOutputDevice().translate(-p.x, -p.y); } } }
/** * Renders the XML document if necessary and returns the root Box. If already rendered, same Box * reference will be returned. * * @return The XML rendered as a Box. */ public Box render() { if (!rendered) { setDocument(loadDocument(sourceDocument), sourceDocumentBase, new XhtmlNamespaceHandler()); layout(this.width); height = this.height == -1 ? root.getHeight() : this.height; BufferedImage outputImage = createBufferedImage(this.width, height); outputDevice = new Java2DOutputDevice(outputImage); Graphics2D newG = (Graphics2D) outputImage.getGraphics(); try { if ( renderingHints != null ) { newG.getRenderingHints().putAll(renderingHints); } RenderingContext rc = sharedContext.newRenderingContextInstance(); rc.setFontContext(new Java2DFontContext(newG)); rc.setOutputDevice(outputDevice); sharedContext.getTextRenderer().setup(rc.getFontContext()); root.getLayer().paint(rc); } finally { if (newG != null) newG.dispose(); } rendered = true; } return root; }
/** * Renders the XML document if necessary and returns the resulting image. If already rendered, same image * reference will be returned. * * {@link #getImage(int)} with the target width. * * @return The XML rendered as a BufferedImage. */ public BufferedImage getImage() { if (!rendered) { setDocument((doc == null ? loadDocument(sourceDocument) : doc), sourceDocumentBase, new XhtmlNamespaceHandler()); layout(this.width); height = this.height == -1 ? root.getHeight() : this.height; outputImage = createBufferedImage(this.width, height); outputDevice = new Java2DOutputDevice(outputImage); Graphics2D newG = (Graphics2D) outputImage.getGraphics(); if ( renderingHints != null ) { newG.getRenderingHints().putAll(renderingHints); } RenderingContext rc = sharedContext.newRenderingContextInstance(); rc.setFontContext(new Java2DFontContext(newG)); rc.setOutputDevice(outputDevice); sharedContext.getTextRenderer().setup(rc.getFontContext()); root.getLayer().paint(rc); newG.dispose(); rendered = true; } return outputImage; }
/** * Renders the XML document if necessary and returns the resulting image. If already rendered, same image * reference will be returned. * * {@link #getImage(int)} with the target width. * * @return The XML rendered as a BufferedImage. */ public BufferedImage getImage() { if (!rendered) { setDocument((doc == null ? loadDocument(sourceDocument) : doc), sourceDocumentBase, new XhtmlNamespaceHandler()); layout(this.width); height = this.height == -1 ? root.getHeight() : this.height; outputImage = createBufferedImage(this.width, height); outputDevice = new Java2DOutputDevice(outputImage); Graphics2D newG = (Graphics2D) outputImage.getGraphics(); if ( renderingHints != null ) { newG.getRenderingHints().putAll(renderingHints); } RenderingContext rc = sharedContext.newRenderingContextInstance(); rc.setFontContext(new Java2DFontContext(newG)); rc.setOutputDevice(outputDevice); sharedContext.getTextRenderer().setup(rc.getFontContext()); root.getLayer().paint(rc); newG.dispose(); rendered = true; } return outputImage; }
/** * Renders the XML document if necessary and returns the root Box. If already rendered, same Box * reference will be returned. * * @return The XML rendered as a Box. */ public Box render() { if (!rendered) { setDocument(loadDocument(sourceDocument), sourceDocumentBase, new XhtmlNamespaceHandler()); layout(this.width); height = this.height == -1 ? root.getHeight() : this.height; BufferedImage outputImage = createBufferedImage(this.width, height); outputDevice = new Java2DOutputDevice(outputImage); Graphics2D newG = (Graphics2D) outputImage.getGraphics(); try { if ( renderingHints != null ) { newG.getRenderingHints().putAll(renderingHints); } RenderingContext rc = sharedContext.newRenderingContextInstance(); rc.setFontContext(new Java2DFontContext(newG)); rc.setOutputDevice(outputDevice); sharedContext.getTextRenderer().setup(rc.getFontContext()); root.getLayer().paint(rc); } finally { if (newG != null) newG.dispose(); } rendered = true; } return root; }
private void paintPage(RenderingContext c, PdfWriter writer, PageBox page) throws IOException { provideMetadataToPage(writer, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = _outputDevice.getClip(); Rectangle content = page.getPrintClippingBounds(c); if (isScaleToFit()) { int pageWidth = calculateWidth(c, page); content.setSize(pageWidth, (int) content.getSize().getHeight());//RTD - to change } _outputDevice.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); _outputDevice.translate(left, top); _root.getLayer().paint(c); _outputDevice.translate(-left, -top); _outputDevice.setClip(working); }
private void paintPage(RenderingContext c, PdfWriter writer, PageBox page) { provideMetadataToPage(writer, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = _outputDevice.getClip(); Rectangle content = page.getPrintClippingBounds(c); _outputDevice.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); _outputDevice.translate(left, top); _root.getLayer().paint(c); _outputDevice.translate(-left, -top); _outputDevice.setClip(working); }
private void paintPage(RenderingContext c, PdfWriter writer, PageBox page) { provideMetadataToPage(writer, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = _outputDevice.getClip(); Rectangle content = page.getPrintClippingBounds(c); _outputDevice.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); _outputDevice.translate(left, top); _root.getLayer().paint(c); _outputDevice.translate(-left, -top); _outputDevice.setClip(working); }
private void paintPage(RenderingContext c, PdfWriter writer, PageBox page) { provideMetadataToPage(writer, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = _outputDevice.getClip(); Rectangle content = page.getPrintClippingBounds(c); _outputDevice.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); _outputDevice.translate(left, top); _root.getLayer().paint(c); _outputDevice.translate(-left, -top); _outputDevice.setClip(working); }
private void paintPage(RenderingContext c, PdfWriter writer, PageBox page) { provideMetadataToPage(writer, page); page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT); page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT); page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT); Shape working = _outputDevice.getClip(); Rectangle content = page.getPrintClippingBounds(c); _outputDevice.clip(content); int top = -page.getPaintingTop() + page.getMarginBorderPadding(c, CalculatedStyle.TOP); int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT); _outputDevice.translate(left, top); _root.getLayer().paint(c); _outputDevice.translate(-left, -top); _outputDevice.setClip(working); }
root.paint(c); out.translate(-left, -top);