/**
 * Created by IntelliJ IDEA.
 * User: Owner
 * Date: Sep 1, 2003
 * Time: 8:04:24 PM
 * To change this template use Options | File Templates.
 */
package org.apache.fop.batik;

import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.TreeBuilder;
import org.apache.fop.fo.DirectPropertyListBuilder;
import org.apache.fop.apps.Driver;
import org.apache.batik.util.XMLResourceDescriptor;

import java.util.HashMap;

public class BatikElementMapping implements ElementMapping {
    static final public String NAMESPACE_URI = "http://xml.apache.org/batik/ext";;
    private static HashMap foObjs = null;

    private static synchronized void setupBatik() {

        if (foObjs == null) {
            // this sets the parser that will be used
            // by default (SVGBrokenLinkProvider)
            // normally the user agent value is used
            XMLResourceDescriptor.setXMLParserClassName(Driver.getParserClassName());

            foObjs = new HashMap();
            foObjs.put("flowText", BatikElement.maker());
            foObjs.put("flowDiv",  BatikObj.maker("flowDiv"));
            foObjs.put("flowRegion", BatikObj.maker("flowRegion"));
            foObjs.put("flowLine", BatikObj.maker("flowLine"));
            foObjs.put("flowPara", BatikObj.maker("flowPara"));
            foObjs.put("flowSpan", BatikObj.maker("flowSpan"));

        }
    }

    public void addToBuilder(TreeBuilder builder) {
        setupBatik();
        builder.addMapping(NAMESPACE_URI, foObjs);

        builder.addPropertyListBuilder(NAMESPACE_URI, new DirectPropertyListBuilder());
    }
}
