Package org.xhtmlrenderer.layout

Examples of org.xhtmlrenderer.layout.LayoutContext


        // need to explicitly handle mouseout events.  This way we only try to
        // restyle elements that were actually hoverable to begin with.
    }

    public void onMouseOver(BasicPanel panel, Box box) {
        LayoutContext c = panel.getLayoutContext();

        if (c == null) {
            return;
        }

        boolean needRepaint = false;

        Element currentlyHovered = getHoveredElement(c.getCss(), box);

        if (currentlyHovered == panel.hovered_element) {
            return;
        }
View Full Code Here


  private Document loadDocument(final String uri) {
    return sharedContext.getUac().getXMLResource(uri).getDocument();
  }

  private LayoutContext newLayoutContext() {
    LayoutContext result = sharedContext.newLayoutContextInstance();
    result.setFontContext(new Java2DFontContext(outputDevice.getGraphics()));

    sharedContext.getTextRenderer().setup(result.getFontContext());

    return result;
  }
View Full Code Here

        } catch (Exception e) {
            System.err.println("Could not render input file, skipping: " + page + " err: " + e.getMessage());
            failedCount++;
            return;
        }
        LayoutContext layoutContext = renderer.getLayoutContext();
        String inputFileName = page.getName();
        IOUtil.copyFile(page, outputDir);
        writeToFile(outputDir, inputFileName + RENDER_SFX, box.dump(layoutContext, "", Box.DUMP_RENDER));
        writeToFile(outputDir, inputFileName + LAYOUT_SFX, box.dump(layoutContext, "", Box.DUMP_LAYOUT));
        fileCount++;
View Full Code Here

            if (verbose()) {
                System.err.println("Could not render input file, skipping: " + source + " err: " + e.getMessage());
            }
            return;
        }
        LayoutContext layoutContext = renderer.getLayoutContext();
        String inputFileName = source.getName();
        String refRendered = trimTrailingLS(readReference(referenceDir, inputFileName, Regress.RENDER_SFX));
        String rendered = trimTrailingLS(box.dump(layoutContext, "", Box.DUMP_RENDER));
        if (!match(refRendered, rendered, stat)) {
            storeFailed(failedDirectory, new File(referenceDir, inputFileName), Regress.RENDER_SFX, rendered);
View Full Code Here

    public void setPDFEncryption(PDFEncryption pdfEncryption) {
        _pdfEncryption = pdfEncryption;
    }

    public void layout() {
        LayoutContext c = newLayoutContext();
        BlockBox root = BoxBuilder.createRootBox(c, _doc);
        root.setContainingBlock(new ViewportBox(getInitialExtents(c)));
        root.layout(c);
        Dimension dim = root.getLayer().getPaintingDimension(c);
        root.getLayer().trimEmptyPages(c, dim.height);
View Full Code Here

        return result;
    }

    private LayoutContext newLayoutContext() {
        LayoutContext result = _sharedContext.newLayoutContextInstance();
        result.setFontContext(new ITextFontContext());
       
        _sharedContext.getTextRenderer().setup(result.getFontContext());
       
        return result;
    }
View Full Code Here

  }

  private void layout(int width) {
    Rectangle rect = new Rectangle(0, 0, width, DEFAULT_HEIGHT);
    sharedContext.set_TempCanvas(rect);
    LayoutContext c = newLayoutContext();
    BlockBox root = BoxBuilder.createRootBox(c, doc);
    root.setContainingBlock(new ViewportBox(rect));
    root.layout(c);
    this.root = root;
  }
View Full Code Here

    root.layout(c);
    this.root = root;
  }

  private LayoutContext newLayoutContext() {
    LayoutContext result = sharedContext.newLayoutContextInstance();
    result.setFontContext(new Java2DFontContext(outputDevice.getGraphics()));

    sharedContext.getTextRenderer().setup(result.getFontContext());

    return result;
  }
View Full Code Here

        getSharedContext().setCanvas(this);

        XRLog.layout(Level.FINEST, "new context end");

        LayoutContext result = getSharedContext().newLayoutContextInstance();
       
        Graphics2D layoutGraphics =
            g.getDeviceConfiguration().createCompatibleImage(1, 1).createGraphics();
        result.setFontContext(new Java2DFontContext(layoutGraphics));
       
        getSharedContext().getTextRenderer().setup(result.getFontContext());
       
        return result;
    }
View Full Code Here

            }
            if (doc == null) {
                return;
            }
           
            LayoutContext c = newLayoutContext((Graphics2D) g);
            synchronized (this) {
                this.layout_context = c;
            }
           
            long start = System.currentTimeMillis();
           
            BlockBox root = (BlockBox)getRootBox();
            if (root != null && isPendingResize()) {
                root.reset(c);
            } else {
                root = BoxBuilder.createRootBox(c, doc);
                setRootBox(root);           
            }
           
            root.setContainingBlock(new ViewportBox(getInitialExtents(c)));
            root.layout(c);
           
            long end = System.currentTimeMillis();
           
            XRLog.layout(Level.INFO, "Layout took " + (end - start) + "ms");
           
            /*
            System.out.println(root.dump(c, "", BlockBox.DUMP_LAYOUT));
            */
           
    // if there is a fixed child then we need to set opaque to false
    // so that the entire viewport will be repainted. this is slower
    // but that's the hit you get from using fixed layout
            if (root.getLayer().containsFixedContent()) {
                super.setOpaque(false);
            } else {
                super.setOpaque(true);
            }
           
            XRLog.layout(Level.FINEST, "after layout: " + root);
           
            Dimension intrinsic_size = root.getLayer().getPaintingDimension(c);
           
            if (c.isPrint()) {
                root.getLayer().trimEmptyPages(c, intrinsic_size.height);
                root.getLayer().layoutPages(c);
            }
           
            setPreferredSize(intrinsic_size);
            revalidate();
           
            // if doc is shorter than viewport
            // then stretch canvas to fill viewport exactly
            // then adjust the body element accordingly
            if (enclosingScrollPane != null) {
                if (intrinsic_size.height < enclosingScrollPane.getViewport().getHeight()) {
                    //Uu.p("int height is less than viewport height");
                    // XXX Not threadsafe
                    if (enclosingScrollPane.getViewport().getHeight() != this.getHeight()) {
                        this.setPreferredSize(new Dimension(
                                intrinsic_size.width, enclosingScrollPane.getViewport().getHeight()));
                        this.revalidate();
                    }
                    //Uu.p("need to do the body hack");
                    if (root != null && ! c.isPrint()) {
                        intrinsic_size.height = root.getHeight();
                    }
                }
               
                // turn on simple scrolling mode if there's any fixed elements
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.layout.LayoutContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.