Package org.apache.fop.layoutmgr

Examples of org.apache.fop.layoutmgr.BreakElement


        LinkedList returnList = new LinkedList();
       
        for (int p = 0; p < knuthParagraphs.size(); p++) {
            // null penalty between paragraphs
            if (p > 0 && !((BlockLevelLayoutManager) parentLM).mustKeepTogether()) {
                returnList.add(new BreakElement(
                        new Position(this), 0, context));
                //returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
            }
       
            LineLayoutPossibilities llPoss;
            llPoss = (LineLayoutPossibilities) lineLayoutsList.get(p);
            KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p);

            if (!seq.isInlineSequence()) {
                LinkedList targetList = new LinkedList();
                ListIterator listIter = seq.listIterator();
                while (listIter.hasNext()) {
                    ListElement tempElement;
                    tempElement = (ListElement) listIter.next();
                    if (tempElement.getLayoutManager() != this) {
                        tempElement.setPosition(notifyPos(new NonLeafPosition(this,
                                tempElement.getPosition())));
                    }
                    targetList.add(tempElement);
                }
                returnList.addAll(targetList);
            } else if (seq.isInlineSequence() && alignment == EN_JUSTIFY) {
                /* justified vertical alignment (not in the XSL FO recommendation):
                   create a multi-layout sequence whose elements will contain
                   a conventional Position */
                Position returnPosition = new LeafPosition(this, p);
                createElements(returnList, llPoss, returnPosition);
            } else {
                /* "normal" vertical alignment: create a sequence whose boxes
                   represent effective lines, and contain LineBreakPositions */
                Position returnPosition = new LeafPosition(this, p);
                int startIndex = 0;
                for (int i = 0;
                        i < llPoss.getChosenLineCount();
                        i++) {
                    if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
                            && i >= fobj.getOrphans()
                            && i <= llPoss.getChosenLineCount() - fobj.getWidows()
                            && returnList.size() > 0) {
                        // null penalty allowing a page break between lines
                        returnList.add(new BreakElement(
                                returnPosition, 0, context));
                        //returnList.add(new KnuthPenalty(0, 0, false, returnPosition, false));
                    }
                    int endIndex
                      = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
View Full Code Here


                    log.error("This is a conflict situation. The output may be wrong."
                            + " Please send your FO file to fop-dev@xmlgraphics.apache.org!");
                }
                p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in XSL 1.0)
            }
            returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, breakClass, context));
            if (penaltyOrGlueLen < 0) {
                returnList.add(new KnuthGlue(-penaltyOrGlueLen, 0, 0, new Position(null), true));
            }

            if (log.isDebugEnabled()) {
View Full Code Here

                    if (last.isPenalty()) {
                        KnuthPenalty pen = (KnuthPenalty)last;
                        pen.setP(-KnuthPenalty.INFINITE);
                        pen.setBreakClass(rowFO.getBreakBefore());
                    } else {//if (last instanceof BreakElement) { // TODO vh: seems the only possibility
                        BreakElement breakPoss = (BreakElement) last;
                        breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
                        breakPoss.setBreakClass(rowFO.getBreakBefore());
                    }
                } else {
                    returnList.add(new BreakElement(new Position(getTableLM()),
                            0, -KnuthPenalty.INFINITE, rowFO.getBreakBefore(), context));
                }
            }
           
            //Border resolution
            if (!isSeparateBorderModel()) {
                resolveNormalBeforeAfterBordersForRowGroup(rowGroup, iter);
            }

            //Reset keep-with-next when remaining inside the table.
            //The context flag is only used to propagate keep-with-next to the outside.
            //The clearing is ok here because createElementsForRowGroup already handles
            //the keep when inside a table.
            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
           
            //Element list creation
            createElementsForRowGroup(context, alignment, bodyType,
                        returnList, rowGroup);
           
            //Handle keeps
            if (context.isKeepWithNextPending()) {
                log.debug("child LM (row group) signals pending keep-with-next");
            }
            if (context.isKeepWithPreviousPending()) {
                log.debug("child LM (row group) signals pending keep-with-previous");
                if (returnList.size() > 0) {
                    //Modify last penalty
                    ListElement last = (ListElement)returnList.getLast();
                    if (last.isPenalty()) {
                        BreakElement breakPoss = (BreakElement)last;
                        //Only honor keep if there's no forced break
                        if (!breakPoss.isForcedBreak()) {
                            breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
                        }
                    }
                }
            }
           
            //Check for break-after on the table-row at the end of the row group
            rowFO = rowGroup[rowGroup.length - 1].getTableRow();
            if (rowFO != null && rowFO.getBreakAfter() != Constants.EN_AUTO) {
                if (returnList.size() > 0) {
                    ListElement last = (ListElement)returnList.getLast();
                    if (last instanceof KnuthPenalty) {
                        KnuthPenalty pen = (KnuthPenalty)last;
                        pen.setP(-KnuthPenalty.INFINITE);
                        pen.setBreakClass(rowFO.getBreakAfter());
                    } else if (last instanceof BreakElement) {
                        BreakElement breakPoss = (BreakElement)last;
                        breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
                        breakPoss.setBreakClass(rowFO.getBreakAfter());
                    }
                }
            }
        }
       
View Full Code Here

                    //Clear keep pending flag
                    context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
                    childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
                    // add an infinite penalty to forbid a break between
                    // blocks
                    contentList.add(new BreakElement(
                            new Position(this), KnuthElement.INFINITE, context));
                    //contentList.add(new KnuthPenalty(0,
                    //        KnuthElement.INFINITE, false,
                    //        new Position(this), false));
                } else if (!(((ListElement) contentList.getLast()).isGlue()
                        || (((ListElement)contentList.getLast()).isPenalty()
                                && ((KnuthPenalty)contentList.getLast()).getP() < KnuthElement.INFINITE)
                                || (contentList.getLast() instanceof BreakElement
                                        && ((BreakElement)contentList.getLast()).getPenaltyValue() < KnuthElement.INFINITE))) {
                    // TODO vh: this is hacky
                    // The getNextKnuthElements method of TableCellLM must not be called
                    // twice, otherwise some settings like indents or borders will be
                    // counted several times and lead to a wrong output. Anyway the
                    // getNextKnuthElements methods should be called only once eventually
                    // (i.e., when multi-threading the code), even when there are forced
                    // breaks.
                    // If we add a break possibility after a forced break the
                    // AreaAdditionUtil.addAreas method will act on a sequence starting
                    // with a SpaceResolver.SpaceHandlingBreakPosition element, having no
                    // LM associated to it. Thus it will stop early instead of adding
                    // areas for following Positions. The above test aims at preventing
                    // such a situation from occuring. add a null penalty to allow a break
                    // between blocks
                    contentList.add(new BreakElement(
                            new Position(this), 0, context));
                    //contentList.add(new KnuthPenalty(0, 0, false,
                    //        new Position(this), false));
                } else {
                    // the last element in contentList is a feasible breakpoint, there is
View Full Code Here

        LinkedList returnList = new LinkedList();
       
        for (int p = 0; p < knuthParagraphs.size(); p++) {
            // null penalty between paragraphs
            if (p > 0 && !((BlockLevelLayoutManager) parentLM).mustKeepTogether()) {
                returnList.add(new BreakElement(
                        new Position(this), 0, context));
                //returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
            }
       
            LineLayoutPossibilities llPoss;
            llPoss = (LineLayoutPossibilities) lineLayoutsList.get(p);
            KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p);

            if (!seq.isInlineSequence()) {
                LinkedList targetList = new LinkedList();
                ListIterator listIter = seq.listIterator();
                while (listIter.hasNext()) {
                    ListElement tempElement;
                    tempElement = (ListElement) listIter.next();
                    if (tempElement.getLayoutManager() != this) {
                        tempElement.setPosition(notifyPos(new NonLeafPosition(this,
                                tempElement.getPosition())));
                    }
                    targetList.add(tempElement);
                }
                returnList.addAll(targetList);
            } else if (seq.isInlineSequence() && alignment == EN_JUSTIFY) {
                /* justified vertical alignment (not in the XSL FO recommendation):
                   create a multi-layout sequence whose elements will contain
                   a conventional Position */
                Position returnPosition = new LeafPosition(this, p);
                createElements(returnList, llPoss, returnPosition);
            } else {
                /* "normal" vertical alignment: create a sequence whose boxes
                   represent effective lines, and contain LineBreakPositions */
                Position returnPosition = new LeafPosition(this, p);
                int startIndex = 0;
                for (int i = 0;
                        i < llPoss.getChosenLineCount();
                        i++) {
                    if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
                            && i >= fobj.getOrphans()
                            && i <= llPoss.getChosenLineCount() - fobj.getWidows()
                            && returnList.size() > 0) {
                        // null penalty allowing a page break between lines
                        returnList.add(new BreakElement(
                                returnPosition, 0, context));
                        //returnList.add(new KnuthPenalty(0, 0, false, returnPosition, false));
                    }
                    int endIndex
                      = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
View Full Code Here

                breakBetween = BreakUtil.compareBreakClasses(breakBetween,
                        context.getBreakBefore());
                if (breakBetween != Constants.EN_AUTO) {
                    penaltyValue = -KnuthElement.INFINITE;
                }
                BreakElement breakElement;
                ListIterator elemIter = returnList.listIterator(returnList.size());
                ListElement elem = (ListElement) elemIter.previous();
                if (elem instanceof KnuthGlue) {
                    breakElement = (BreakElement) elemIter.previous();
                } else {
                    breakElement = (BreakElement) elem;
                }
                breakElement.setPenaltyValue(penaltyValue);
                breakElement.setBreakClass(breakBetween);
                returnList.addAll(nextRowGroupElems);
                breakBetween = context.getBreakAfter();
                keepBetween = context.isKeepWithNextPending();
            }
        }
        /*
         * The last break produced for the last row-group of this table part must be
         * removed, because the breaking after the table will be handled by TableLM.
         * Unless the element list ends with a glue, which must be kept to accurately
         * represent the content. In such a case the break is simply disabled by setting
         * its penalty to infinite.
         */
        ListIterator elemIter = returnList.listIterator(returnList.size());
        ListElement elem = (ListElement) elemIter.previous();
        if (elem instanceof KnuthGlue) {
            BreakElement breakElement = (BreakElement) elemIter.previous();
            breakElement.setPenaltyValue(KnuthElement.INFINITE);
        } else {
            elemIter.remove();
        }
        context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, keepWithPrevious);
        context.setBreakBefore(breakBefore);
View Full Code Here

            }
            if (rowHeightSmallerThanFirstStep) {
                rowHeightSmallerThanFirstStep = false;
                p = KnuthPenalty.INFINITE;
            }
            returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, nextBreakClass, context));
            if (penaltyOrGlueLen < 0) {
                returnList.add(new KnuthGlue(-penaltyOrGlueLen, 0, 0, new Position(null), true));
            }

            laststep = step;
View Full Code Here

        if (!context.suppressBreakBefore()) {
            //addKnuthElementsForBreakBefore(returnList, context);
            int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(),
                    childLC.getBreakBefore());
            if (breakBefore != Constants.EN_AUTO) {
                returnList.addFirst(new BreakElement(getAuxiliaryPosition(),
                        0, -KnuthElement.INFINITE, breakBefore, context));
            }
        }

        //addKnuthElementsForBreakAfter(returnList, context);
        int breakAfter = BreakUtil.compareBreakClasses(getTable().getBreakAfter(),
                childLC.getBreakAfter());
        if (breakAfter != Constants.EN_AUTO) {
            returnList.add(new BreakElement(getAuxiliaryPosition(),
                    0, -KnuthElement.INFINITE, breakAfter, context));
        }

        setFinished(true);
        resetSpaces();
View Full Code Here

            if (addedBoxHeight < totalHeight) {
                int p = 0;
                if (keepWithNextActive || mustKeepTogether()) {
                    p = KnuthPenalty.INFINITE;
                }
                returnList.add(new BreakElement(stepPosition, penaltyHeight, p, -1, context));
            }
        }

        return returnList;
    }
View Full Code Here

                    //Clear keep pending flag
                    context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
                    childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
                    // add an infinite penalty to forbid a break between
                    // blocks
                    contentList.add(new BreakElement(
                            new Position(this), KnuthElement.INFINITE, context));
                    //contentList.add(new KnuthPenalty(0,
                    //        KnuthElement.INFINITE, false,
                    //        new Position(this), false));
                } else if (!(((ListElement) contentList.getLast()).isGlue()
                        || (((ListElement)contentList.getLast()).isPenalty()
                                && ((KnuthPenalty)contentList.getLast()).getP() < KnuthElement.INFINITE)
                                || (contentList.getLast() instanceof BreakElement
                                        && ((BreakElement)contentList.getLast()).getPenaltyValue() < KnuthElement.INFINITE))) {
                    // TODO vh: this is hacky
                    // The getNextKnuthElements method of TableCellLM must not be called
                    // twice, otherwise some settings like indents or borders will be
                    // counted several times and lead to a wrong output. Anyway the
                    // getNextKnuthElements methods should be called only once eventually
                    // (i.e., when multi-threading the code), even when there are forced
                    // breaks.
                    // If we add a break possibility after a forced break the
                    // AreaAdditionUtil.addAreas method will act on a sequence starting
                    // with a SpaceResolver.SpaceHandlingBreakPosition element, having no
                    // LM associated to it. Thus it will stop early instead of adding
                    // areas for following Positions. The above test aims at preventing
                    // such a situation from occurring. add a null penalty to allow a break
                    // between blocks
                    contentList.add(new BreakElement(
                            new Position(this), 0, context));
                    //contentList.add(new KnuthPenalty(0, 0, false,
                    //        new Position(this), false));
                } else {
                    // the last element in contentList is a feasible breakpoint, there is
View Full Code Here

TOP

Related Classes of org.apache.fop.layoutmgr.BreakElement

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.