Examples of InlineKnuthSequence


Examples of org.apache.fop.layoutmgr.InlineKnuthSequence

            }
        }
        if (returnedList.size() == 0) {
            //Inline part of the footnote is empty. Need to send back an auxiliary
            //zero-width, zero-height inline box so the footnote gets painted.
            KnuthSequence seq = new InlineKnuthSequence();
            //Need to use an aux. box, otherwise, the line height can't be forced to zero height.
            forcedAnchor = new KnuthInlineBox(0, null, null, true);
            seq.add(forcedAnchor);
            returnedList.add(seq);
        }
        setFinished(true);

        addAnchor(returnedList);
View Full Code Here

Examples of org.apache.fop.layoutmgr.InlineKnuthSequence

        lineStartBAP = context.getLineStartBorderAndPaddingWidth();
        lineEndBAP = context.getLineEndBorderAndPaddingWidth();
        alignmentContext = context.getAlignmentContext();

        LinkedList returnList = new LinkedList();
        KnuthSequence sequence = new InlineKnuthSequence();
        AreaInfo ai = null;
        returnList.add(sequence);

        while (iNextStart < textArray.length) {
            char ch = textArray[iNextStart];
            if (ch == CharUtilities.SPACE
                && foText.getWhitespaceTreatment() != Constants.EN_PRESERVE) {
                // normal non preserved space - collect them all
                // advance to the next character
                iThisStart = iNextStart;
                iNextStart++;
                while (iNextStart < textArray.length
                    && textArray[iNextStart] == CharUtilities.SPACE) {
                    iNextStart++;
                }
                // create the AreaInfo object
                ai = new AreaInfo(iThisStart, (short) (iNextStart),
                        (short) (iNextStart - iThisStart), (short) 0,
                        MinOptMax.multiply(wordSpaceIPD, iNextStart - iThisStart),
                        false, true);
                vecAreaInfo.add(ai);

                // create the elements
                sequence.addAll
                    (createElementsForASpace(alignment, ai, vecAreaInfo.size() - 1));

            } else if (ch == CharUtilities.SPACE || ch == CharUtilities.NBSPACE) {
                // preserved space or non-breaking space:
                // create the AreaInfo object
                ai = new AreaInfo(iNextStart, (short) (iNextStart + 1),
                        (short) 1, (short) 0,
                        wordSpaceIPD, false, true);
                vecAreaInfo.add(ai);

                // create the elements
                sequence.addAll
                    (createElementsForASpace(alignment, ai, vecAreaInfo.size() - 1));

                // advance to the next character
                iNextStart++;
            } else if (CharUtilities.isFixedWidthSpace(ch)) {
                // create the AreaInfo object
                MinOptMax ipd = new MinOptMax(font.getCharWidth(ch));
                ai = new AreaInfo(iNextStart, (short) (iNextStart + 1),
                        (short) 0, (short) 0,
                        ipd, false, true);
                vecAreaInfo.add(ai);

                // create the elements
                sequence.addAll
                    (createElementsForASpace(alignment, ai, vecAreaInfo.size() - 1));

                // advance to the next character
                iNextStart++;
            } else if (ch == NEWLINE) {
                // linefeed; this can happen when linefeed-treatment="preserve"
                // add a penalty item to the list and start a new sequence
                if (lineEndBAP != 0) {
                    sequence.add
                        (new KnuthGlue(lineEndBAP, 0, 0,
                                       new LeafPosition(this, -1), true));
                }
                sequence.endSequence();
                sequence = new InlineKnuthSequence();
                returnList.add(sequence);

                // advance to the next character
                iNextStart++;
            } else {
                // the beginning of a word
                iThisStart = iNextStart;
                iTempStart = iNextStart;
                for (; iTempStart < textArray.length
                        && !isSpace(textArray[iTempStart])
                        && textArray[iTempStart] != NEWLINE
                        && !(iTempStart > iNextStart
                             && isBreakChar(textArray[iTempStart - 1]));
                        iTempStart++) {
                    //nop, just find the word boundary
                }
               
                //Word boundary found, process widths and kerning
                int wordLength = iTempStart - iThisStart;
                boolean kerning = font.hasKerning();
                MinOptMax wordIPD = new MinOptMax(0);
                for (int i = iThisStart; i < iTempStart; i++) {
                    char c = textArray[i];
                   
                    //character width
                    int charWidth = font.getCharWidth(c);
                    wordIPD.add(charWidth);
                   
                    //kerning
                    int kern = 0;
                    if (kerning && (i > iThisStart)) {
                        char previous = textArray[i - 1];
                        kern = font.getKernValue(previous, c) * font.getFontSize() / 1000;
                        if (kern != 0) {
                            addToLetterAdjust(i + 1, kern);
                        }
                        wordIPD.add(kern);
                    }
                }
               
                int iLetterSpaces = wordLength - 1;
                // if the last character is '-' or '/' and the next one
                // is not a space, it could be used as a line end;
                // add one more letter space, in case other text follows
                if (isBreakChar(textArray[iTempStart - 1])
                        && iTempStart < textArray.length
                        && !isSpace(textArray[iTempStart])) {
                    iLetterSpaces++;
                }
                wordIPD.add(MinOptMax.multiply(letterSpaceIPD, iLetterSpaces));

                // create the AreaInfo object
                ai = new AreaInfo(iThisStart, iTempStart, (short) 0,
                        (short) iLetterSpaces,
                        wordIPD, false, false);
                vecAreaInfo.add(ai);

                // create the elements
                sequence.addAll(createElementsForAWordFragment(alignment, ai,
                        vecAreaInfo.size() - 1, letterSpaceIPD));

                // advance to the next character
                iNextStart = iTempStart;
            }
View Full Code Here

Examples of org.apache.fop.layoutmgr.InlineKnuthSequence

    /** @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) */
    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
        MinOptMax ipd;
        curArea = get(context);
        KnuthSequence seq = new InlineKnuthSequence();

        if (curArea == null) {
            setFinished(true);
            return null;
        }

        ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter()));

        curArea.setIPD(ipd.opt);
        curArea.setBPD(font.getAscender() - font.getDescender());

        TraitSetter.addFontTraits(curArea, font);
        curArea.addTrait(Trait.COLOR, fobj.getColor());

        // TODO: may need some special handling for fo:character
        alignmentContext = new AlignmentContext(font
                                    , font.getFontSize()
                                    , fobj.getAlignmentAdjust()
                                    , fobj.getAlignmentBaseline()
                                    , fobj.getBaselineShift()
                                    , fobj.getDominantBaseline()
                                    , context.getAlignmentContext());

        addKnuthElementsForBorderPaddingStart(seq);
       
        // create the AreaInfo object to store the computed values
        areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext);

        // node is a fo:Character
        if (letterSpaceIPD.min == letterSpaceIPD.max) {
            // constant letter space, only return a box
            seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
                                        notifyPos(new LeafPosition(this, 0)), false));
        } else {
            // adjustable letter space, return a sequence of elements;
            // at the moment the character is supposed to have no letter spaces,
            // but returning this sequence allows us to change only one element
            // if addALetterSpaceTo() is called
            seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
                                        notifyPos(new LeafPosition(this, 0)), false));
            seq.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
                                            new LeafPosition(this, -1), true));
            seq.add(new KnuthGlue(0, 0, 0,
                                         new LeafPosition(this, -1), true));
            seq.add(new KnuthInlineBox(0, null,
                                        notifyPos(new LeafPosition(this, -1)), true));
        }

        addKnuthElementsForBorderPaddingEnd(seq);

View Full Code Here

Examples of org.apache.fop.layoutmgr.InlineKnuthSequence

        // create the AreaInfo object to store the computed values
        areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext);

        // node is a fo:ExternalGraphic, fo:InstreamForeignObject,
        // fo:PageNumber or fo:PageNumberCitation
        KnuthSequence seq = new InlineKnuthSequence();

        addKnuthElementsForBorderPaddingStart(seq);
       
        seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, alignmentContext,
                                    notifyPos(new LeafPosition(this, 0)), false));

        addKnuthElementsForBorderPaddingEnd(seq);
       
        LinkedList returnList = new LinkedList();
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.