Have you looked at the addAreas() method? You probably also want to extend BlockStackingLayoutManager instead of ALM.

On 6/20/13 3:44 PM, sdridi wrote:
Thanks for the links Glenn. I've already read Knuth's paper and I understand
how it works. FOP implementation is also clear to me, more or less...I'm not
trying to reinvent Knuth algorithm neither to modify it, all I want is to
know how to create a layout manager for my <fox:best-fit-block> element. The
latter is too simple, it doesn't have any FO properties and can only contain
a single <fo:block>.

I managed to write the following class but it doesn't generate any content
in the output document:


public class BestFitBlockLayoutManager extends AbstractLayoutManager {

        static Log log = LogFactory.getLog(BestFitBlockLayoutManager.class);
        
        public BestFitBlockLayoutManager(BestFitBlock node) {
                super(node);
        }
/** {@inheritDoc} */
     public List getNextKnuthElements(LayoutContext context, int alignment) {
        if (isFinished())
                return null;
        List returnList = null;
        if (getChildLM() != null) {
                returnList = getChildLM().getNextKnuthElements(context, 
alignment);
             // add a penalty element, representing a forced page break
             returnList.add(new BreakElement(new NonLeafPosition(this, new
Position(this)),
                        Constants.EN_PAGE, -KnuthElement.INFINITE, EN_PAGE, 
context));

        }
         setFinished(true);
         notifyEndOfLayout();
         return returnList;
     }
}



--
View this message in context: 
http://apache-fop.1065347.n5.nabble.com/Adding-a-new-layout-manager-tp38757p38769.html
Sent from the FOP - Dev mailing list archive at Nabble.com.

Reply via email to