aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/area/inline/InlineArea.java
blob: 701f98c094da5e33d6c90a91f223c8d08c159123 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * $Id$
 * Copyright (C) 2002 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.area.inline;

import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.render.Renderer;
import org.apache.fop.traits.BorderProps;

import java.util.ArrayList;

/**
 * Inline Area
 * This area is for all inline areas that can be placed
 * in a line area.
 * Extensions of this class should render themselves with the
 * requested renderer.
 */
public class InlineArea extends Area {
    // int width;
    private int height;
    protected int contentIPD = 0;

    // offset position from top of parent area
    int verticalPosition = 0;

    // store properties in array list, need better solution
    private ArrayList props = null;

    /**
     * Render this inline area.
     * Inline areas that extend this class are expected
     * to implement this method to render themselves in
     * the renderer.
     *
     * @param renderer the renderer to render this inline area
     */
    public void render(Renderer renderer) {
    }

    public void setWidth(int w) {
        contentIPD = w;
    }

    public int getWidth() {
        return contentIPD;
    }

    public void setIPD(int ipd) {
        this.contentIPD = ipd;
    }

    public int getIPD() {
        return this.contentIPD;
    }

    public void increaseIPD(int ipd) {
        this.contentIPD += ipd;
    }

    public void setHeight(int h) {
        height = h;
    }

    public int getHeight() {
        return height;
    }

    public int getAllocIPD() {
        // If start or end border or padding is non-zero, add to content IPD
        int iBP = contentIPD;
        Object t;
        if ((t = getTrait(Trait.PADDING_START)) != null) {
            iBP += ((Integer) t).intValue();
        }
        if ((t = getTrait(Trait.PADDING_END)) != null) {
            iBP += ((Integer) t).intValue();
        }
        if ((t = getTrait(Trait.BORDER_START)) != null) {
            iBP += ((BorderProps) t).width;
        }
        if ((t = getTrait(Trait.BORDER_END)) != null) {
            iBP += ((BorderProps) t).width;
        }
        return iBP;
    }

    public void setOffset(int v) {
        verticalPosition = v;
    }

    public int getOffset() {
        return verticalPosition;
    }
}