Package org.xhtmlrenderer.layout

Examples of org.xhtmlrenderer.layout.LayoutContext


  }

  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


  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

  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();
        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

            stat.failedToRender(e);
            storeFailed(failedDirectory, source);
            log("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 (!compareLines(refRendered, rendered, stat)) {
            storeFailed(failedDirectory, new File(referenceDir, inputFileName), Regress.RENDER_SFX, rendered);
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.layoutContext = c;
            }

            long start = System.currentTimeMillis();

            BlockBox root = (BlockBox)getRootBox();
            if (root != null && isNeedRelayout()) {
                root.reset(c);
            } else {
                root = BoxBuilder.createRootBox(c, doc);
                setRootBox(root);
            }

            initFontFromComponent(root);

            Rectangle initialExtents = getInitialExtents(c);
            root.setContainingBlock(new ViewportBox(initialExtents));

            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);
            }

            // If the initial size we fed into the layout matches the width
View Full Code Here

        _parent = parent;
        parent.addMouseMoveListener(this);
    }

    public void mouseMove(MouseEvent e) {
        LayoutContext c = _parent.getLayoutContext();
        if (c == null) {
            return;
        }

        Box box = _parent.find(e.x, e.y);

        Element previous = _parent.getHovered_element();
        Element current = getHoveredElement(c.getCss(), box);
        if (previous == current) {
            return;
        }
        _parent.setHovered_element(current);
View Full Code Here

    /**
     * @return a new {@link LayoutContext}
     */
    protected LayoutContext newLayoutcontext() {
        LayoutContext result = _sharedContext.newLayoutContextInstance();

        if (_layout_gc == null) {
            _layout_image = new Image(getDisplay(), 1, 1);
            _layout_gc = new GC(_layout_image);
        }

        result.setFontContext(new SWTFontContext(_layout_gc));
        _sharedContext.getTextRenderer().setup(result.getFontContext());

        return result;
    }
View Full Code Here

    /**
     * @return a new {@link LayoutContext}
     */
    protected LayoutContext newLayoutcontext(GC gc) {
        LayoutContext result = _sharedContext.newLayoutContextInstance();

        result.setFontContext(new SWTFontContext(gc));
        _sharedContext.getTextRenderer().setup(result.getFontContext());

        return result;
    }
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.