aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
blob: 9c9a05a56a2ff6db0de0e6d0c461105adb559ef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.layoutmgr;

import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.Constants;
import org.apache.fop.area.*;

/**
 * LayoutManager for an fo:flow object.
 * Its parent LM is the PageLayoutManager.
 * This LM is responsible for getting columns of the appropriate size
 * and filling them with block-level areas generated by its children.
 */
public class FlowLayoutManager extends BlockStackingLayoutManager {

    /** Array of areas currently being filled stored by area class */
    private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];

    /**
     * This is the top level layout manager.
     * It is created by the PageSequence FO.
     */
    public FlowLayoutManager(FObj fobj) {
        super(fobj);
    }



    /**
     * Add child area to a the correct container, depending on its
     * area class. A Flow can fill at most one area container of any class
     * at any one time. The actual work is done by BlockStackingLM.
     */
    public void addChild(Area childArea) {
        addChildToArea(childArea,
                       this.currentAreas[childArea.getAreaClass()]);
    }

    public Area getParentArea(Area childArea) {
        // Get an area from the Page
        BlockParent parentArea =
          (BlockParent) parentLM.getParentArea(childArea);
        this.currentAreas[parentArea.getAreaClass()] = parentArea;
        setCurrentArea(parentArea);
        return parentArea;
    }


}