Package org.apache.fop.layoutmgr

Examples of org.apache.fop.layoutmgr.KnuthGlue


        switch (alignment) {
        case EN_CENTER:
            // centered text:
            baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
            baseList.add(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                    auxiliaryPosition, true));
            baseList.add(new KnuthPenalty(hyphIPD, unflagged
                    ? TextLayoutManager.SOFT_HYPHEN_PENALTY
                            : KnuthPenalty.FLAGGED_PENALTY, !unflagged, auxiliaryPosition, false));
            baseList.add(new KnuthGlue(-(lineEndBAP + lineStartBAP),
                    -6 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                    auxiliaryPosition, false));
            baseList.add(makeAuxiliaryZeroWidthBox());
            baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
            baseList.add(new KnuthGlue(lineStartBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH,
                    0, auxiliaryPosition, true));
            break;

        case EN_START: // fall through
        case EN_END:
            // left- or right-aligned text:
            if (lineStartBAP != 0 || lineEndBAP != 0) {
                baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
                baseList.add(new KnuthGlue(lineEndBAP,
                        3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                        auxiliaryPosition, false));
                baseList.add(new KnuthPenalty(widthIfBreakOccurs,
                        unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
                                : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                                auxiliaryPosition, false));
                baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt()
                        - (lineStartBAP + lineEndBAP),
                        -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                        auxiliaryPosition, false));
                baseList.add(makeAuxiliaryZeroWidthBox());
                baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
                baseList.add(new KnuthGlue(lineStartBAP, 0, 0, auxiliaryPosition, false));
            } else {
                baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
                baseList.add(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                        auxiliaryPosition, false));
                baseList.add(new KnuthPenalty(widthIfBreakOccurs,
                        unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
                                : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                                auxiliaryPosition, false));
                baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt(),
                        -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                        auxiliaryPosition, false));
            }
            break;

        default:
            // justified text, or last line justified:
            // just a flagged penalty
            if (lineStartBAP != 0 || lineEndBAP != 0) {
                baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
                baseList.add(new KnuthGlue(lineEndBAP, 0, 0, auxiliaryPosition, false));
                baseList.add(new KnuthPenalty(widthIfBreakOccurs,
                        unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
                                : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                                auxiliaryPosition, false));
                // extra elements representing a letter space that is suppressed
                // if a break occurs
                if (widthIfNoBreakOccurs.isNonZero()) {
                    baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt()
                            - (lineStartBAP + lineEndBAP),
                            widthIfNoBreakOccurs.getStretch(),
                            widthIfNoBreakOccurs.getShrink(),
                            auxiliaryPosition, false));
                } else {
                    baseList.add(new KnuthGlue(-(lineStartBAP + lineEndBAP), 0, 0,
                            auxiliaryPosition, false));
                }
                baseList.add(makeAuxiliaryZeroWidthBox());
                baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
                baseList.add(new KnuthGlue(lineStartBAP, 0, 0,
                        auxiliaryPosition, false));
            } else {
                baseList.add(new KnuthPenalty(widthIfBreakOccurs,
                        unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
                                : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                                auxiliaryPosition, false));
                // extra elements representing a letter space that is suppressed
                // if a break occurs
                if (widthIfNoBreakOccurs.isNonZero()) {
                    baseList.add(new KnuthGlue(widthIfNoBreakOccurs, auxiliaryPosition, false));
                }
            }
        }

    }
View Full Code Here


                    if (!(knuthEl instanceof KnuthGlue)) {
                        fail("Expected KnuthGlue"
                                + " at position " + pos
                                + " but got: " + knuthEl.getClass().getName());
                    }
                    KnuthGlue glue = (KnuthGlue)knuthEl;
                    if (domEl.getAttribute("w").length() > 0) {
                        int w = Integer.parseInt(domEl.getAttribute("w"));
                        if (w != knuthEl.getWidth()) {
                            fail("Expected w=" + w
                                    + " at position " + pos
View Full Code Here

    private KnuthSequence getKnuthSequence1() {
        KnuthSequence seq = new BlockKnuthSequence();
        for (int i = 0; i < 5; i++) {
            seq.add(new KnuthBox(0, null, true));
            seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, true));
            seq.add(new KnuthGlue(5000, 0, 0, null, true));
            seq.add(new KnuthBox(10000, null, false));
            if (i < 4) {
                seq.add(new KnuthPenalty(0, 0, false, null, false));
                seq.add(new KnuthGlue(-5000, 0, 0, null, true));
            }
        }

        seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, false));
        seq.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        seq.add(new KnuthPenalty(0, -KnuthPenalty.INFINITE, false, null, false));
        ElementListObserver.observe(seq, "test", null);
        return seq;
    }
View Full Code Here

        lst.add(new KnuthPenalty(0, 200, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, 0, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaks(lst, 9000);

        assertFalse(res);
View Full Code Here

     * @throws Exception if the test fails
     */
    public void testRemoveElementPenalty2() throws Exception {
        LinkedList lst = new LinkedList();
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaks(lst, 9000);

        assertFalse(res);
View Full Code Here

        lst.add(new KnuthPenalty(0, 200, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, 0, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaksFromEnd(lst, 9000);

        assertFalse(res);
View Full Code Here

        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, 0, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, 200, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaksFromEnd(lst, 9000);

        assertFalse(res);
View Full Code Here

    private KnuthSequence getKnuthSequence1() {
        KnuthSequence seq = new BlockKnuthSequence();
        for (int i = 0; i < 5; i++) {
            seq.add(new KnuthBox(0, null, true));
            seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, true));
            seq.add(new KnuthGlue(5000, 0, 0, null, true));
            seq.add(new KnuthBox(10000, null, false));
            if (i < 4) {
                seq.add(new KnuthPenalty(0, 0, false, null, false));
                seq.add(new KnuthGlue(-5000, 0, 0, null, true));
            }
        }

        seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, false));
        seq.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        seq.add(new KnuthPenalty(0, -KnuthPenalty.INFINITE, false, null, false));
        ElementListObserver.observe(seq, "test", null);
        return seq;
    }
View Full Code Here

        lst.add(new KnuthPenalty(0, 200, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, 0, false, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaks(lst, 9000);

        assertFalse(res);
View Full Code Here

     */
    @Test
    public void testRemoveElementPenalty2() throws Exception {
        LinkedList lst = new LinkedList();
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthGlue(0, 0, 0, null, false));
        lst.add(new KnuthBox(4000, null, false));
        lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
        lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false));
        lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));

        boolean res = ElementListUtils.removeLegalBreaks(lst, 9000);

        assertFalse(res);
View Full Code Here

TOP

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

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.