Examples of LayoutContext


Examples of org.xhtmlrenderer.layout.LayoutContext

        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

Examples of org.xhtmlrenderer.layout.LayoutContext

            }
            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
Copyright © 2018 www.massapi.com. 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.