Package org.apache.fop.fo.expr

Source Code of org.apache.fop.fo.expr.LabelEndFunction

/*
* $Id: LabelEndFunction.java,v 1.2.2.1 2002/02/17 19:53:36 chrisg Exp $
* 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.fo.expr;

import org.apache.fop.datatypes.*;
import org.apache.fop.fo.Property;
import org.apache.fop.fo.LengthProperty;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.ListItem;

public class LabelEndFunction extends FunctionBase {

    public int nbArgs() {
        return 0;
    }

    public Property eval(Property[] args,
                         PropertyInfo pInfo) throws PropertyException {

        Length distance =
            pInfo.getPropertyList().get("provisional-distance-between-starts").getLength();
        Length separation =
            pInfo.getPropertyList().getNearestSpecified("provisional-label-separation").getLength();

        FObj item = pInfo.getFO();
        while (item != null &&!(item instanceof ListItem)) {
            item = item.getParent();
        }
        if (item == null) {
            throw new PropertyException("label-end() called from outside an fo:list-item");
        }
        Length startIndent = item.properties.get("start-indent").getLength();

        LinearCombinationLength labelEnd = new LinearCombinationLength();

        // Should be CONTAINING_REFAREA but that doesn't work
        LengthBase base = new LengthBase(item, pInfo.getPropertyList(),
                                         LengthBase.CONTAINING_BOX);
        PercentLength refWidth = new PercentLength(1.0, base);

        labelEnd.addTerm(1.0, refWidth);
        labelEnd.addTerm(-1.0, distance);
        labelEnd.addTerm(-1.0, startIndent);
        labelEnd.addTerm(1.0, separation);
       
        // make sure value gets calculated
        labelEnd.computeValue();

        return new LengthProperty(labelEnd);
    }

}
TOP

Related Classes of org.apache.fop.fo.expr.LabelEndFunction

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.