aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/traits/SpaceVal.java
blob: 763ac00ebc1e666c2911033297700bd7c27de006 (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
/*
 * $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.traits;

import org.apache.fop.datatypes.Space;
import org.apache.fop.area.MinOptMax;
import org.apache.fop.fo.Property;
import org.apache.fop.fo.properties.Constants;

/**
 * Store a single Space property value in simplified form, with all
 * Length values resolved.
 */
public class SpaceVal {
    public final MinOptMax space;
    public final boolean bConditional;
    public final boolean bForcing;
    public final int iPrecedence; //  Numeric only, if forcing, set to 0

    public SpaceVal(Space spaceprop) {
        space = new MinOptMax( spaceprop.getMinimum().getLength().mvalue(),
                               spaceprop.getOptimum().getLength().mvalue(),
                               spaceprop.getMaximum().getLength().mvalue());
        bConditional = (spaceprop.getConditionality().getEnum() ==
                        Constants.DISCARD);
        Property precProp = spaceprop.getPrecedence();
        if (precProp.getNumber() != null) {
            iPrecedence = precProp.getNumber().intValue();
            bForcing = false;
        } else {
            bForcing = (precProp.getEnum() == Constants.FORCE);
            iPrecedence = 0;
        }
    }

    public SpaceVal(MinOptMax space, boolean bConditional,
                    boolean bForcing, int iPrecedence) {
        this.space = space;
        this.bConditional = bConditional;
        this.bForcing = bForcing;
        this.iPrecedence = iPrecedence;
    }

}