Package org.xhtmlrenderer.render

Examples of org.xhtmlrenderer.render.Box


        textInlineMap = new LinkedHashMap();
        elementBoxMap = new HashMap();
        Stack s = new Stack();
        s.push(panel.getRootBox());
        while (!s.empty()) {
            Box b = (Box) s.pop();
            Element element = b.getElement();
            if (element != null && !elementBoxMap.containsKey(element)) {
                elementBoxMap.put(element, b);
            }
            if (b instanceof InlineLayoutBox) {
                InlineLayoutBox ilb = (InlineLayoutBox) b;
                for (Iterator it = ilb.getInlineChildren().iterator(); it.hasNext();) {
                    Object o = it.next();
                    if (o instanceof InlineText) {
                        InlineText t = (InlineText) o;
                        Text txt = t.getTextNode();
                        if (!textInlineMap.containsKey(txt)) {
                            textInlineMap.put(txt, new ArrayList());
                        }
                        ((List) textInlineMap.get(txt)).add(t);
                    } else {
                        s.push((Box) o);
                    }
                }
            } else {
                Iterator childIterator = b.getChildIterator();
                while (childIterator.hasNext()) {
                    s.push(childIterator.next());
                }
            }
        }
View Full Code Here


            b = (Box) boxes.pop();
            if (b instanceof InlineLayoutBox) {
                ilbs.add((InlineLayoutBox) b);
            } else {
                for (Iterator it = b.getChildIterator(); it.hasNext();) {
                    Box child = (Box) it.next();
                    if (!ignoreChildElements || child.getElement() == null) {
                        boxes.push(child);
                    }
                }
            }
        }
View Full Code Here

    ViewModelInfo infoFromPoint(MouseEvent e) {
        checkDocument();
        Range r = docRange.createRange();
        InlineText fndTxt = null;
        Box box = panel.getRootLayer().find(panel.getLayoutContext(), e.getX(), e.getY(), true);
        if (box == null) {
            return null;
        }
        Element elt = null;
        int offset = 0;
        InlineLayoutBox ilb = null;
        boolean containsWholeIlb = false;
        if (box instanceof InlineLayoutBox) {
            ilb = (InlineLayoutBox) box;
        } else {
            for (; ilb == null;) {
                List ilbs = getInlineLayoutBoxes(box, false);
                for (int i = ilbs.size() - 1; i >= 0; i--) {
                    InlineLayoutBox ilbt = (InlineLayoutBox) ilbs.get(i);
                    if (ilbt.getAbsY() <= e.getY() && ilbt.getAbsX() <= e.getX()) {
                        if (ilb == null || (ilbt.getAbsY() > ilb.getAbsY())
                                || (ilbt.getAbsY() == ilb.getAbsY() && ilbt.getX() > ilb.getX())) {

                            if (ilbt.isContainsVisibleContent()) {
                                boolean hasDecentTextNode = false;
                                int x = ilbt.getAbsX();

                                for (Iterator it = ilbt.getInlineChildren().iterator(); it
                                        .hasNext();) {
                                    Object o = it.next();
                                    if (o instanceof InlineText) {
                                        InlineText txt = (InlineText) o;
                                        if (txt.getTextNode() != null) {
                                            hasDecentTextNode = true;
                                            break;
                                        }
                                    }
                                }
                                if (hasDecentTextNode) {
                                    ilb = ilbt;
                                }
                            }
                        }
                        containsWholeIlb = true;
                    }
                }
                if (ilb == null) {
                    if (box.getParent() == null) {
                        return null;
                    }
                    box = box.getParent();
                }
            }
        }
        int x = ilb.getAbsX();
        InlineText lastItxt = null;
View Full Code Here

     * out and added to an anonymous block box along with the table itself.
     * If not, the table is returned.
     */
    private static BlockBox reorderTableContent(LayoutContext c, TableBox table) {
        List topCaptions = new LinkedList();
        Box header = null;
        List bodies = new LinkedList();
        Box footer = null;
        List bottomCaptions = new LinkedList();

        for (Iterator i = table.getChildIterator(); i.hasNext();) {
            Box b = (Box) i.next();
            IdentValue display = b.getStyle().getIdent(CSSName.DISPLAY);
            if (display == IdentValue.TABLE_CAPTION) {
                IdentValue side = b.getStyle().getIdent(CSSName.CAPTION_SIDE);
                if (side == IdentValue.BOTTOM) {
                    bottomCaptions.add(b);
                } else { /* side == IdentValue.TOP */
                    topCaptions.add(b);
                }
View Full Code Here

        return super.calcBaseline(c);
    }
   
    public void moveContent(LayoutContext c, final int deltaY) {
        for (int i = 0; i < getChildCount(); i++) {
            Box b = getChild(i);
            b.setY(b.getY() + deltaY);
        }
       
        getPersistentBFC().getFloatManager().performFloatOperation(
                new FloatManager.FloatOperation() {
                    public void operate(Box floater) {
View Full Code Here

            c.getOutputDevice().paintBackground(
                    c, column.getStyle(),
                    bounds, getTable().getColumnBounds(c, getCol()));
        }
       
        Box row = getParent();
        Box section = row.getParent();
       
        CalculatedStyle tableStyle = getTable().getStyle();
       
        CalculatedStyle sectionStyle = section.getStyle();
       
        imageContainer = section.getPaintingBorderEdge(c);
        imageContainer.y += tableStyle.getBorderVSpacing(c);
        imageContainer.height -= tableStyle.getBorderVSpacing(c);
        imageContainer.x += tableStyle.getBorderHSpacing(c);
        imageContainer.width -= 2*tableStyle.getBorderHSpacing(c);
       
View Full Code Here

    }

    private static boolean isPageBreakBetweenChildBoxes(RelayoutDataList relayoutDataList,
            int runStart, int runEnd, LayoutContext c, BlockBox block) {
        for ( int i = runStart; i < runEnd; i++ ) {
            Box prevChild = block.getChild(i);
            Box nextChild = block.getChild(i+1);
            // if nextChild is made of several lines, then only the first line
            // is relevant for "page-break-before: avoid".
            Box nextLine = getFirstLine(nextChild) == null ? nextChild : getFirstLine(nextChild);
            int prevChildEnd = prevChild.getAbsY() + prevChild.getHeight();
            int nextLineEnd = nextLine.getAbsY() + nextLine.getHeight();
            if ( c.getRootLayer().crossesPageBreak(c, prevChildEnd, nextLineEnd) ) {
                return true;
            }
        }
        return false;
View Full Code Here

            LayoutContext c, List localChildren, BlockBox block,
            RelayoutDataList relayoutDataList, int start, int end, boolean onNewPage) {
        int childOffset = relayoutDataList.get(start).getChildOffset();

        if (onNewPage) {
            Box startBox = (Box) localChildren.get(start);
            PageBox startPageBox = c.getRootLayer().getFirstPage(c, startBox);
            childOffset += startPageBox.getBottom() - startBox.getAbsY();
        }

        // reset height of parent as it is used for Y-setting of children
        block.setHeight(childOffset);
View Full Code Here

        }
    }

    private void saveBoxModel(File page, File outputDir, int width) throws IOException {
        BoxRenderer renderer = new BoxRenderer(page, width);
        Box box;
        try {
            box = renderer.render();
        } 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

        return super.calcBaseline(c);
    }
   
    public void moveContent(LayoutContext c, final int deltaY) {
        for (int i = 0; i < getChildCount(); i++) {
            Box b = getChild(i);
            b.setY(b.getY() + deltaY);
        }
       
        getPersistentBFC().getFloatManager().performFloatOperation(
                new FloatManager.FloatOperation() {
                    public void operate(Box floater) {
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.render.Box

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.