Package org.apache.fop.layoutmgr

Examples of org.apache.fop.layoutmgr.PositionIterator


        }
       
        if (headerElements != null) {
            //header positions for the last part are the second-to-last element and need to
            //be handled first before all other TableContentPositions
            PositionIterator nestedIter = new KnuthPossPosIter(headerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        //Iterate over all steps
        Iterator posIter = positions.iterator();
        iterateAndPaintPositions(posIter, painter);
        painter.addAreasAndFlushRow(true);

        if (footerElements != null) {
            //Positions for footers are simply added at the end
            PositionIterator nestedIter = new KnuthPossPosIter(footerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        painter.notifyEndOfSequence();
View Full Code Here


        }
       
        if (headerElements != null) {
            //header positions for the last part are the second-to-last element and need to
            //be handled first before all other TableContentPositions
            PositionIterator nestedIter = new KnuthPossPosIter(headerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        //Iterate over all steps
        Iterator posIter = positions.iterator();
        iterateAndPaintPositions(posIter, painter);
        painter.addAreasAndFlushRow(true);

        if (footerElements != null) {
            //Positions for footers are simply added at the end
            PositionIterator nestedIter = new KnuthPossPosIter(footerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        painter.notifyEndOfSequence();
View Full Code Here

                    tempElement = (KnuthElement) seqIterator.next();
                    iStartElement++;
                }
   
                // Add the inline areas to lineArea
                PositionIterator inlinePosIter
                    = new KnuthPossPosIter(seq, iStartElement,
                                           iEndElement + 1);
   
                iStartElement = lbp.getLeafPos() + 1;
                if (iStartElement == seq.size()) {
                    // advance to next paragraph
                    iStartElement = 0;
                }
   
                lc.setSpaceAdjust(lbp.dAdjust);
                lc.setIPDAdjust(lbp.ipdAdjust);
                lc.setLeadingSpace(new SpaceSpecifier(true));
                lc.setTrailingSpace(new SpaceSpecifier(false));
                lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);

                /* extension (not in the XSL FO recommendation): if the left and right margins
                   have been optimized, recompute indents and / or adjust ratio, according
                   to the paragraph horizontal alignment */
                if (false && textAlignment == EN_JUSTIFY) {
                    // re-compute space adjust ratio
                    int updatedDifference = context.getStackLimit().opt - lbp.lineWidth + lbp.difference;
                    double updatedRatio = 0.0;
                    if (updatedDifference > 0) {
                        updatedRatio = (float) updatedDifference / lbp.availableStretch;
                    } else if (updatedDifference < 0) {
                        updatedRatio = (float) updatedDifference / lbp.availableShrink;
                    }
                    lc.setIPDAdjust(updatedRatio);
                    //log.debug("LLM.addAreas> old difference = " + lbp.difference + " new difference = " + updatedDifference);
                    //log.debug("              old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
                } else if (false && textAlignment == EN_CENTER) {
                    // re-compute indent
                    int updatedIndent = lbp.startIndent
                                            + (context.getStackLimit().opt - lbp.lineWidth) / 2;
                    lineArea.setStartIndent(updatedIndent);
                } else if (false && textAlignment == EN_END) {
                    // re-compute indent
                    int updatedIndent = lbp.startIndent
                                            + (context.getStackLimit().opt - lbp.lineWidth);
                    lineArea.setStartIndent(updatedIndent);
                }

                setCurrentArea(lineArea);
                setChildContext(lc);
                while ((childLM = inlinePosIter.getNextChildLM()) != null) {
                    lc.setFlags(LayoutContext.LAST_AREA, (childLM == lastLM));
                    childLM.addAreas(inlinePosIter, lc);
                    lc.setLeadingSpace(lc.getTrailingSpace());
                    lc.setTrailingSpace(new SpaceSpecifier(false));
                }
               
                // when can this be null?
                // if display-align is distribute, add space after
                if (context.getSpaceAfter() > 0
                    && (!context.isLastArea() || parentIter.hasNext())) {
                    lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter());
                }
                lineArea.finalize();
                parentLM.addChildArea(lineArea);
            } else if (pos instanceof NonLeafPosition) {
                // Nested block-level content;
                // go down the LM stack again;
                // collect all consecutive NonLeafPosition objects,
                // "unwrap" them and put the child positions in a new list.
                LinkedList positionList = new LinkedList();
                Position innerPosition;
                innerPosition = ((NonLeafPosition) pos).getPosition();
                positionList.add(innerPosition);
                while (parentIter.hasNext()) {
                    pos = (Position)parentIter.peekNext();
                    if (!(pos instanceof NonLeafPosition)) {
                        break;
                    }
                    pos = (Position) parentIter.next();
                    innerPosition = ((NonLeafPosition) pos).getPosition();
                    positionList.add(innerPosition);
                }
               
                // do we have the last LM?
                LayoutManager lastLM = null;
                if (!parentIter.hasNext()) {
                    lastLM = innerPosition.getLM();
                }

                // this may be wrong; not all areas belong inside a single line area
                // see InlineStackingLM.addChildArea
                LineArea lineArea = new LineArea();
                setCurrentArea(lineArea);
                setChildContext(lc);

                PositionIterator childPosIter = new StackingIter(positionList.listIterator());
                LayoutContext blocklc = new LayoutContext(0);
                blocklc.setLeadingSpace(new SpaceSpecifier(true));
                blocklc.setTrailingSpace(new SpaceSpecifier(false));
                blocklc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
                while ((childLM = childPosIter.getNextChildLM()) != null) {
                    // set last area flag
                    blocklc.setFlags(LayoutContext.LAST_AREA,
                            (context.isLastArea() && childLM == lastLM));
                    blocklc.setStackLimit(context.getStackLimit());
                    // Add the line areas to Area
View Full Code Here

        }
       
        if (headerElements != null) {
            //header positions for the last part are the second-to-last element and need to
            //be handled first before all other TableContentPositions
            PositionIterator nestedIter = new KnuthPossPosIter(headerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        //Iterate over all steps
        Iterator posIter = positions.iterator();
        iterateAndPaintPositions(posIter, painter);
        painter.addAreasAndFlushRow(true);

        if (footerElements != null) {
            //Positions for footers are simply added at the end
            PositionIterator nestedIter = new KnuthPossPosIter(footerElements);
            iterateAndPaintPositions(nestedIter, painter);
            painter.addAreasAndFlushRow(true);
        }
       
        painter.notifyEndOfSequence();
View Full Code Here

                    tempElement = (KnuthElement) seqIterator.next();
                    iStartElement++;
                }
   
                // Add the inline areas to lineArea
                PositionIterator inlinePosIter
                    = new KnuthPossPosIter(seq, iStartElement,
                                           iEndElement + 1);
   
                iStartElement = lbp.getLeafPos() + 1;
                if (iStartElement == seq.size()) {
                    // advance to next paragraph
                    iStartElement = 0;
                }
   
                lc.setSpaceAdjust(lbp.dAdjust);
                lc.setIPDAdjust(lbp.ipdAdjust);
                lc.setLeadingSpace(new SpaceSpecifier(true));
                lc.setTrailingSpace(new SpaceSpecifier(false));
                lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);

                /* extension (not in the XSL FO recommendation): if the left and right margins
                   have been optimized, recompute indents and / or adjust ratio, according
                   to the paragraph horizontal alignment */
                if (false && textAlignment == EN_JUSTIFY) {
                    // re-compute space adjust ratio
                    int updatedDifference = context.getStackLimit().opt - lbp.lineWidth + lbp.difference;
                    double updatedRatio = 0.0;
                    if (updatedDifference > 0) {
                        updatedRatio = (float) updatedDifference / lbp.availableStretch;
                    } else if (updatedDifference < 0) {
                        updatedRatio = (float) updatedDifference / lbp.availableShrink;
                    }
                    lc.setIPDAdjust(updatedRatio);
                    //log.debug("LLM.addAreas> old difference = " + lbp.difference + " new difference = " + updatedDifference);
                    //log.debug("              old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
                } else if (false && textAlignment == EN_CENTER) {
                    // re-compute indent
                    int updatedIndent = lbp.startIndent
                                            + (context.getStackLimit().opt - lbp.lineWidth) / 2;
                    lineArea.setStartIndent(updatedIndent);
                } else if (false && textAlignment == EN_END) {
                    // re-compute indent
                    int updatedIndent = lbp.startIndent
                                            + (context.getStackLimit().opt - lbp.lineWidth);
                    lineArea.setStartIndent(updatedIndent);
                }

                setCurrentArea(lineArea);
                setChildContext(lc);
                while ((childLM = inlinePosIter.getNextChildLM()) != null) {
                    lc.setFlags(LayoutContext.LAST_AREA, (childLM == lastLM));
                    childLM.addAreas(inlinePosIter, lc);
                    lc.setLeadingSpace(lc.getTrailingSpace());
                    lc.setTrailingSpace(new SpaceSpecifier(false));
                }
               
                // when can this be null?
                // if display-align is distribute, add space after
                if (context.getSpaceAfter() > 0
                    && (!context.isLastArea() || parentIter.hasNext())) {
                    lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter());
                }
                lineArea.finalize();
                parentLM.addChildArea(lineArea);
            } else if (pos instanceof NonLeafPosition) {
                // Nested block-level content;
                // go down the LM stack again;
                // collect all consecutive NonLeafPosition objects,
                // "unwrap" them and put the child positions in a new list.
                LinkedList positionList = new LinkedList();
                Position innerPosition;
                innerPosition = ((NonLeafPosition) pos).getPosition();
                positionList.add(innerPosition);
                while (parentIter.hasNext()) {
                    pos = (Position)parentIter.peekNext();
                    if (!(pos instanceof NonLeafPosition)) {
                        break;
                    }
                    pos = (Position) parentIter.next();
                    innerPosition = ((NonLeafPosition) pos).getPosition();
                    positionList.add(innerPosition);
                }
               
                // do we have the last LM?
                LayoutManager lastLM = null;
                if (!parentIter.hasNext()) {
                    lastLM = innerPosition.getLM();
                }

                // this may be wrong; not all areas belong inside a single line area
                // see InlineStackingLM.addChildArea
                LineArea lineArea = new LineArea();
                setCurrentArea(lineArea);
                setChildContext(lc);

                PositionIterator childPosIter = new StackingIter(positionList.listIterator());
                LayoutContext blocklc = new LayoutContext(0);
                blocklc.setLeadingSpace(new SpaceSpecifier(true));
                blocklc.setTrailingSpace(new SpaceSpecifier(false));
                blocklc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
                while ((childLM = childPosIter.getNextChildLM()) != null) {
                    // set last area flag
                    blocklc.setFlags(LayoutContext.LAST_AREA,
                            (context.isLastArea() && childLM == lastLM));
                    blocklc.setStackLimit(context.getStackLimit());
                    // Add the line areas to Area
View Full Code Here

TOP

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

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.