Re: Adding a new layout manager

2013-06-21 Thread sdridi
I completely agree. They often say the best way to assess your understanding
of a subject is to try to explain it to someone else. Maybe the time has
come to give something back to this great community :)

Actually, I have been thinking to write a general introduction tutorial to
FOP, because let's say it the current code-base could be quite intimidating
to new developers.









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


Re: Adding a new layout manager

2013-06-21 Thread Vincent Hennebert
On 21/06/13 09:21, sdridi wrote:
> OK, now I have something working. I borrowed some code from
> ListBlockLayoutManager, which is simple enough to understand. 
> 
> Luis, is it okay to inherit from BlockStackinLayoutManager even though my
> extension does not have any FO properties? What's the best approach that you
> would recommend?

I guess I’d subclass whatever LM helps me to get something working the
quickest. Then you can refine it and move it where it fits the best.
Eventually a sub-class of AbstractLM indeed looks like a good candidate,
perhaps even AbstractBaseLM.


> Thanks


Vincent


Re: Adding a new layout manager

2013-06-21 Thread Vincent Hennebert
On 20/06/13 15:56, sdridi wrote:
> Glenn Adams-2 wrote
>> I would suggest you not just read code but run it with Eclipse or NetBeans
>> to trace the execution process. That is one of the best ways to learn
>> actual code behavior.
> 
> Yes of course, debugging is my only way to break FOP mystery
> 
> 
> Glenn Adams-2 wrote
>> Maybe that somebody is you! :)
> 
> That would be an honor, but not before I master how FOP works

You don’t need to master FOP to write documentation. Doing it may
actually help you to refine your understanding of the code because it
forces you to write down what is in your mind, which you’ll find out is
not always as clear as you thought.

After that exercise you will not only have a better understanding of the
code, you will also have made a welcome contribution to the project. We
can always correct any mistake that may creep in.


> Back to my main topic of discussion, if anyone can shed some light on FOP
> layout engine, I'd be very grateful.


Vincent


Re: Adding a new layout manager

2013-06-21 Thread sdridi
OK, now I have something working. I borrowed some code from
ListBlockLayoutManager, which is simple enough to understand. 

Luis, is it okay to inherit from BlockStackinLayoutManager even though my
extension does not have any FO properties? What's the best approach that you
would recommend?

Thanks



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


Re: Adding a new layout manager

2013-06-20 Thread Luis Bernardo


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  element. The
latter is too simple, it doesn't have any FO properties and can only contain
a single .

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.




Re: Adding a new layout manager

2013-06-20 Thread sdridi
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  element. The
latter is too simple, it doesn't have any FO properties and can only contain
a single .

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.


RE: Adding a new layout manager

2013-06-20 Thread Jonathan Levinson
I found the following essay in Knuth’s Digital Typography informative:

“Breaking Paragraphs Into Lines”.

HTH,
Jonathan

From: Glenn Adams [mailto:gl...@skynav.com]
Sent: Thursday, June 20, 2013 10:11 AM
To: FOP Developers
Subject: Re: Adding a new layout manager


On Thu, Jun 20, 2013 at 9:56 PM, sdridi 
mailto:sdr...@iptech-group.com>> wrote:
Glenn Adams-2 wrote
> I would suggest you not just read code but run it with Eclipse or NetBeans
> to trace the execution process. That is one of the best ways to learn
> actual code behavior.
Yes of course, debugging is my only way to break FOP mystery


Glenn Adams-2 wrote
> Maybe that somebody is you! :)
That would be an honor, but not before I master how FOP works

Back to my main topic of discussion, if anyone can shed some light on FOP
layout engine, I'd be very grateful.

You can start by reading [1]. Then, if you are really dedicated and want to 
delve further, read the relevant parts of TeX: The Program [2]. Or, if you 
prefer to read Lisp (Scheme), then you can find a faithful transcription of the 
TeX line breaker at [3], which I wrote in 1990 or so. Once you've internalized 
this information, you are ready to tackle the FOP line breaker.

Good luck! Glenn

[1] 
http://bowman.infotech.monash.edu.au/~pmoulder/line-breaking/knuth-plass-breaking.pdf
[2] http://yaojingguo.blogspot.com/2009/02/produce-tex-program-from-texweb.html
[3] http://people.apache.org/~gadams/random/tex.scm.txt




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



Re: Adding a new layout manager

2013-06-20 Thread Glenn Adams
On Thu, Jun 20, 2013 at 9:56 PM, sdridi  wrote:

> Glenn Adams-2 wrote
> > I would suggest you not just read code but run it with Eclipse or
> NetBeans
> > to trace the execution process. That is one of the best ways to learn
> > actual code behavior.
>
> Yes of course, debugging is my only way to break FOP mystery
>
>
> Glenn Adams-2 wrote
> > Maybe that somebody is you! :)
>
> That would be an honor, but not before I master how FOP works
>
> Back to my main topic of discussion, if anyone can shed some light on FOP
> layout engine, I'd be very grateful.
>

You can start by reading [1]. Then, if you are really dedicated and want to
delve further, read the relevant parts of TeX: The Program [2]. Or, if you
prefer to read Lisp (Scheme), then you can find a faithful transcription of
the TeX line breaker at [3], which I wrote in 1990 or so. Once you've
internalized this information, you are ready to tackle the FOP line breaker.

Good luck! Glenn

[1]
http://bowman.infotech.monash.edu.au/~pmoulder/line-breaking/knuth-plass-breaking.pdf
[2]
http://yaojingguo.blogspot.com/2009/02/produce-tex-program-from-texweb.html
[3] http://people.apache.org/~gadams/random/tex.scm.txt


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


Re: Adding a new layout manager

2013-06-20 Thread sdridi
Glenn Adams-2 wrote
> I would suggest you not just read code but run it with Eclipse or NetBeans
> to trace the execution process. That is one of the best ways to learn
> actual code behavior.

Yes of course, debugging is my only way to break FOP mystery


Glenn Adams-2 wrote
> Maybe that somebody is you! :)

That would be an honor, but not before I master how FOP works

Back to my main topic of discussion, if anyone can shed some light on FOP
layout engine, I'd be very grateful.



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


Re: Adding a new layout manager

2013-06-20 Thread Glenn Adams
On Thu, Jun 20, 2013 at 7:03 PM, sdridi  wrote:

> You have no idea what many hours I spend everyday reading FOP code :). I
> understand the big picture of FOP layout engine, but some details are still
> blurry in my head. Anyway, I'll continue tinkering with the code until I
> figure out what I need exactly.
>

I would suggest you not just read code but run it with Eclipse or NetBeans
to trace the execution process. That is one of the best ways to learn
actual code behavior.


>
> Thanks for the link btw, but these articles are indeed outdated, maybe it's
> time for someone to write a good documentation about FOP' execution
> pipeline.
>

Maybe that somebody is you! :)


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


Re: Adding a new layout manager

2013-06-20 Thread sdridi
You have no idea what many hours I spend everyday reading FOP code :). I
understand the big picture of FOP layout engine, but some details are still
blurry in my head. Anyway, I'll continue tinkering with the code until I
figure out what I need exactly.

Thanks for the link btw, but these articles are indeed outdated, maybe it's
time for someone to write a good documentation about FOP' execution
pipeline.



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


Re: Adding a new layout manager

2013-06-20 Thread Glenn Adams
Sorry, you're just going to have to read code to understand the current
implementation. There are some (dated) design notes under
http://wiki.apache.org/xmlgraphics-fop/DeveloperPages that may help you get
started. FOP is a DIY exercise, especially if you want to make a major
change like you suggest.

Regards,
Glenn


On Thu, Jun 20, 2013 at 6:46 PM, sdridi  wrote:

> Hello people,
>
> I'm working on an extension for FOP similar to  Whitespace management
>   . I want to
> start as simple as possible, so my XML extension ** is
> only allowed to contain one ** which has an **.
> The layout manager should be simple to implement and most calls will be
> delegated to the appropriate children, but I'm not sure which methods to
> implement in /AbstractLayoutManager/. Also, could you briefly explain how
> to
> implement /getNextKnuthElements()/? And do I even need to implement
> /getChangedKnuthElements()/?
>
> Thank you in advance for your time
>
> Best Regards
>
> Seifeddine Dridi
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-fop.1065347.n5.nabble.com/Adding-a-new-layout-manager-tp38757.html
> Sent from the FOP - Dev mailing list archive at Nabble.com.
>