Re: Knuth linebreaking questions

2004-11-30 Thread Glen Mazza
[Finn]
3) What is the reasoning for doing hyphenation only after threshold=1
fails. Naive common sense tells me that if the user specify hyphenation
we should do hyphenation before finding line breaks.
   

 

[Luca]
Finding hyphenation points is time-expansive (all words must be
hyphenated, not only the ones "near a line's end"), the sequence of
elements becomes longer, there are more feasible breaking points, and a
line ending with a "-" is less beautiful; so I thought that if a set of
breaking points could be find without hyphenation.
 

I've just started to read Knuth's chapter on breaking paragraphs into 
lines, and from what I've read, he considers excessive hyphenation a bad 
form.  The main benefits he gives for taking the entire paragraph into 
account when deciding where to break lines (as opposed to the more 
traditional just-look-at-the-current-line analysis) are a reduced need 
for hyphenation and a reduced number of over-spaced lines (i.e., too few 
words on a line requiring large spaces between them for the line to be 
justified.)

Glen


Re: cvs commit: xml-fop/src/java/org/apache/fop/fo/flow Marker.java

2004-11-30 Thread Glen Mazza
Finn (or anyone else), given that FOText nodes (and possibly other 
non-formatting object nodes in the future) also have properties, any 
objections if we move FObj.bind() to FONode.bind()?   That would 
simplify the below code a bit.

Thanks,
Glen
[EMAIL PROTECTED] schrieb:
spepping2004/11/30 12:20:59
 Modified:src/java/org/apache/fop/fo/flow Marker.java
 Log:
 Fixed a ClassCastException in rebind
 
 Revision  ChangesPath
 1.20  +7 -2  xml-fop/src/java/org/apache/fop/fo/flow/Marker.java
 
 Index: Marker.java
 ===
 RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Marker.java,v
 retrieving revision 1.19
 retrieving revision 1.20
 diff -u -r1.19 -r1.20
 --- Marker.java	28 Oct 2004 10:00:21 -	1.19
 +++ Marker.java	30 Nov 2004 20:20:59 -	1.20
 @@ -26,6 +26,7 @@
  import org.apache.fop.apps.FOPException;
  import org.apache.fop.fo.FOEventHandler;
  import org.apache.fop.fo.FONode;
 +import org.apache.fop.fo.FOText;
  import org.apache.fop.fo.FObj;
  import org.apache.fop.fo.FObjMixed;
  import org.apache.fop.fo.PropertyList;
 @@ -69,9 +70,13 @@
  // Set a new parent property list and bind all the children again.
  propertyList.setParentPropertyList(parentPropertyList);
  for (Iterator i = children.keySet().iterator(); i.hasNext(); ) {
 -FObj child = (FObj) i.next();
 +Object child = i.next();
  PropertyList childList = (PropertyList) children.get(child);
 -child.bind(childList);
 +if (child instanceof FObj) {
 +((FObj) child).bind(childList);
 +} else if (child instanceof FOText) {
 +((FOText) child).bind(childList);
 +}
  }
  }
  
 
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




DO NOT REPLY [Bug 32253] - Marker bugs

2004-11-30 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32253





--- Additional Comments From [EMAIL PROTECTED]  2004-11-30 21:23 ---
Committed a fix in Marker, which cures the ClassCastException in
Marker.rebind(). Now all markers lead to a ClassCastException in
RetrieveMarkerLM.getNextKnuthElements(), line 81. This should be cured by
removing the LMs for fo:marker and for fo:retrieve-marker:

at the moment, RetrieveMarkerLM tries to achieve this (in the LM tree):

 ...
  |
   parentLM
  |
  RetrieveMarkerLM
  |
  InlineStackingLM
   ---+---
   | |
  chldLM1   chldLM2

but, as a marker can only have children which could replace its
retrieve-marker, wouldn't it be better to have just:

 ...
  |
   parentLM
   ---+---
   | |
  chldLM1   chldLM2

(Luca Furini at fop-dev)


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.


Re: Knuth linebreaking questions

2004-11-30 Thread Luca Furini
Finn Bock wrote:

> 1) What is the purpose of 2 glues for a normal space in END and START
> alignment:
>
> new KnuthGlue(0, 3 * wordSpaceIPD.opt, 0, , false));
> new KnuthPenalty(0, 0, false, , true));
> new KnuthGlue(wordSpaceIPD.opt, - 3 * wordSpaceIPD.opt, 0, , true));

The purpose is to give each line (but the last one) the same
stretchability, regardless of the number of spaces in it.

If the penalty is not used (there is no line ending there) the overall
effect of the 2 glues is a 0 stretchability and does not modify the line
total; if the penalty is used (a line ends there) then the stretchability
of the previous glue is added to the line total, which becomes 3 *
wordSpaceIPD.opt because the previous space, as said before, added 0 (the
following glue is suppressed).

In justified text, a line with many spaces can be adjusted in order to be
much shorter, or much longer.
If left-aligned text used the same elements, the algorithm would find the
same breaking points; but this time adjustment ratios are not used, so a
line with many spaces would be too much longer, or too much shorter, than
the other lines.
Using these elements, the algorithm creates lines whose unadjusted width is
quite the same.

> and why isn't the min and max of wordspaceIPD used.

Well, you just made me notice there is a little bug,
LineLayoutManager.DEFAULT_SPACE_WIDTH should be used insted! :-)

It's just a "magic number": the point is that every TextLM should use the
same value.

> 2) What does the threshold parameter to findBreakingPoints controll?
> It seems to be a performance parameter which control the number of
> active nodes, rather than a quality parameter.
> Or to frame my question
> differently, if threshold=1 finds a set of breaks, will threshold=5
> always pick the same set of breaks? Or can threshold=5 find a better set
> of breaks?

It controls both performance and quality: minimum quality.

If threshold = 1 finds a set of breaks, it is the best possible set of
breaks, because the adjustment ratio of each break is <= 1 which means
that spaces and other adjustable objects will not need to be longer than
their .max width.

But with this optimal threshold the algorithm could fail, and find no set
of breaking points; so, a try with a higher threshold must be done.

If with threshold = 1 a set is found, with threshold = 5 the same set
would be found, but it would take more time, because a greater number of
active nodes are used.

> 3) What is the reasoning for doing hyphenation only after threshold=1
> fails. Naive common sense tells me that if the user specify hyphenation
> we should do hyphenation before finding line breaks.

Finding hyphenation points is time-expansive (all words must be
hyphenated, not only the ones "near a line's end"), the sequence of
elements becomes longer, there are more feasible breaking points, and a
line ending with a "-" is less beautiful; so I thought that if a set of
breaking points could be find without hyphenation.

I just took the "hyphenate" property as a suggestion instead of an order! :-)

Note that the same algorithm with the same threshold could find a
different set of breaking points with and without hyphenation, because the
elements are different. Without hyphenation, spaces could need a little
higher adjustment, for example.

> 4) I've compared your code to tex_wrap
> http://oedipus.sourceforge.net/texlib/
> and the main difference is in the way new KnuthNodes are added to the
> active list. Is the BestRecords part of Knuth or is it your own
> invention? Why is it only fitness_class'es in BestRecord that is higher
> then minDemerits + incompatibleFitnessDemerit that is added to
> activeList? Why not all fitness_class'es in BestRecords?

At the moment I don't have the book at hand, but I am quite sure it's
*not* an invention of mine! :-)

As far as I can remember, the Knuth book uses 4 different variables, named
C1, ... C4 :-( (or maybe D or A, anyway not a very self-documenting name!)
and I just created this structure to store them.

I'll try and find some time to look at this ...

Thanks for your interest and your comments, they are most welcome!

Regards
Luca





Re: Printing PDF on the client default printer.

2004-11-30 Thread Charles Ohana



wow!!! sounds great... Where can we get that 
???  Thanx.

  - Original Message - 
  From: 
  [EMAIL PROTECTED] 
  To: [EMAIL PROTECTED] 
  Cc: [EMAIL PROTECTED] 
  Sent: Tuesday, November 30, 2004 9:02 
  AM
  Subject: Printing PDF on the client 
  default printer.
  
  Just wanted everyone to know that I have successfully implemented client 
  side printing using FOP
   
  Eg: If the XML file gets created on the webserver which is located in Los 
  Angeles and the user in London, then the XML is converted to PDF and the PDF 
  file is printed on the clients default printer in London.
   
  Thanks
  Manoj
   -Forwarded by Manoj Nair/LA/SPE 
  on 11/30/2004 09:00AM -To: [EMAIL PROTECTED]From: [EMAIL PROTECTED]Date: 
  10/21/2004 10:13AMSubject: Printing PDF on the client default 
  printer.**I had posted this in the fop-user group and the responses indicated thatthere is no way this can be implemented currently. Just wanted an opinionfrom the fop-dev crowd.Thanks**My requirement is to render an XML as  a PDF and then print the PDF on theclients default printer. I dont want the PDF to prompt user to open theacrobat reader.I already have an applet on the client side which uses PrinterJob class topopup the printer selection box on client side.Now how do I redirect the content from server to this printer?Should I use Driver.RENDER_PRINT / Driver.RENDER_PCL set in the fop driverrenderer ? and what content type should the response object return?ThanksManojPS: I have successfully use the FopPrinter example ( FopPrintServlet ) toprint pdfs on the app servers default printer but what I need is to be ableto print on the clients default printer and not on servers printer.


Printing PDF on the client default printer.

2004-11-30 Thread Manoj_Nair
Just wanted everyone to know that I have successfully implemented client side printing using FOP Eg: If the XML file gets created on the webserver which is located in Los Angeles and the user in London, then the XML is converted to PDF and the PDF file is printed on the clients default printer in London. ThanksManoj -Forwarded by Manoj Nair/LA/SPE on 11/30/2004 09:00AM -To: [EMAIL PROTECTED]From: [EMAIL PROTECTED]Date: 10/21/2004 10:13AMSubject: Printing PDF on the client default printer.**I had posted this in the fop-user group and the responses indicated thatthere is no way this can be implemented currently. Just wanted an opinionfrom the fop-dev crowd.Thanks**My requirement is to render an XML as  a PDF and then print the PDF on theclients default printer. I dont want the PDF to prompt user to open theacrobat reader.I already have an applet on the client side which uses PrinterJob class topopup the printer selection box on client side.Now how do I redirect the content from server to this printer?Should I use Driver.RENDER_PRINT / Driver.RENDER_PCL set in the fop driverrenderer ? and what content type should the response object return?ThanksManojPS: I have successfully use the FopPrinter example ( FopPrintServlet ) toprint pdfs on the app servers default printer but what I need is to be ableto print on the clients default printer and not on servers printer.

Knuth linebreaking questions

2004-11-30 Thread Finn Bock
Hi Luca (and others),
I've been trying to get my head around the line breaking code and during
that process some questions has come up. I urge you *not* to take
anything I ask as a sign of criticism or as a request for changes. I 
don't have the Knuth paper where the algorithm is described so perhaps 
the answers would be obvious if I read it.

1) What is the purpose of 2 glues for a normal space in END and START 
alignment:

new KnuthGlue(0, 3 * wordSpaceIPD.opt, 0, , false));
new KnuthPenalty(0, 0, false, , true));
new KnuthGlue(wordSpaceIPD.opt, - 3 * wordSpaceIPD.opt, 0, , true));
and why isn't the min and max of wordspaceIPD used.
2) What does the threshold parameter to findBreakingPoints controll?
It seems to be a performance parameter which control the number of 
active nodes, rather than a quality parameter. Or to frame my question 
differently, if threshold=1 finds a set of breaks, will threshold=5 
always pick the same set of breaks? Or can threshold=5 find a better set 
of breaks?

3) What is the reasoning for doing hyphenation only after threshold=1 
fails. Naive common sense tells me that if the user specify hyphenation 
we should do hyphenation before finding line breaks.

4) I've compared your code to tex_wrap
   http://oedipus.sourceforge.net/texlib/
and the main difference is in the way new KnuthNodes are added to the 
active list. Is the BestRecords part of Knuth or is it your own 
invention? Why is it only fitness_class'es in BestRecord that is higher 
then minDemerits + incompatibleFitnessDemerit that is added to 
activeList? Why not all fitness_class'es in BestRecords?

regards,
finn