You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by Apache Wiki <wi...@apache.org> on 2006/08/07 22:07:00 UTC

[Xmlgraphics-fop Wiki] Update of "GoogleSummerOfCode2006/FloatsImplementationProgress/ImplementingSideFloats" by VincentHennebert

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xmlgraphics-fop Wiki" for change notification.

The following page has been changed by VincentHennebert:
http://wiki.apache.org/xmlgraphics-fop/GoogleSummerOfCode2006/FloatsImplementationProgress/ImplementingSideFloats

The comment on the change is:
An algorithm for side-floats placement

------------------------------------------------------------------------------
  
  I'll first implement the "line" value, as this is probably the most expected by users. I'll forget "block" and "indent" for now if after a quick look they turn out to be too complicated to implement.
  
+ = An Algorithm for Placing Side-floats =
+ Have you ever played with Lego^tm^? Well, here's an opportunity.
+ 
+ We will use here the relative terms for area placement: before, after, start, end. As a convenience, we will use the words "beforer" (higher in lr-tb writing-mode), "beforest" (highest), "starter" (more on the left than), "startest" (the most on the left), etc., for comparing the placement of areas between each other.
+ 
+ We consider the common ancestor reference-area as a containing box in which bricks have to be placed. There is a jagged line (green, below) which will serve as a guide for placing floats. This jagged line will be made, among others, of three guide lines. The "before-guide" will correspond to:
+  * the before-edge of the current line-area's allocation-rectangle, or
+  * the after-edge of the previous block-area's, if there is no current line-area, or
+  * the before-edge of the "afterest" placed side-float, if it is afterer than the previous lines.
+ 
+ There will also be one "start-guide", representing the afterest after-edge of start-floats, and one "end-guide", for the afterest after-edge of end-floats.
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-start.png
+ 
+ Now let's suppose we want to place a new start-float; the idea is to place it at the after-end corner of the reference-area. Then we pull it toward the before-edge until it touches one of the guide lines.
+ 
+ While continuing to pull towards the before, we will start pulling also towards the start; the float will progress along the jagged line until it is blocked; it has reached its final placement. The guide lines are updated as should be.
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float1_1.png
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float1_2.png
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float1_3.png
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float1_4.png
+ 
+ Now we will place an end-float; there is no more place on the current line, so the float will be placed after the last placed start-float:
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float2_1.png
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float2_2.png
+ 
+ Note that the before-guide no longer corresponds to the current line-area, as the last float has been placed afterer. Note also that there is a hole below the third end-float from the right: its after-edge no longer serves for the guide as there is an end-float placed to its start (left), whose after-edge is afterer. (This was the same case for the first start-float.)
+ 
+ Let's place a new start-float:
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float3.png
+ 
+ And then a new end-float:
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-float4.png
+ 
+ 
+ Side-floats are boxes which may allow some shrinking/stretching in the block-progression-dimension. Me may take advantage of this possibility to place floats which otherwise wouldn't fit on the page. On the figure below, the second start-float has the "clear" property set to "start":
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-shrink.png
+ 
+ == Properties of the Model ==
+ By nature, this model should respect all of the rules for side-floats placement:
+  1. A start-float starts at the end-edge and is pulled to the start until it touches the start-edge of the ref-area's content-rectangle. So this rule is always followed. Same for end-floats.
+  2. The guiding jagged line is designed to follow the afterest and endest edges of start-floats, and the afterest and startest edges of end-floats. So the area into which a start-float may evolve is such that all already placed start-floats are to its start or to its before. (That's why there may be holes above the start-guide or the end-guide, as showed above.)
+  3. The model ensures that side-floats don't inter-penetrate each other.
+  4. As for 1., the before-edge of the ref-area is the upper limit.
+  5. This is ensured by the way the before-guide is computed.
+  6. idem
+  7. a start-float is pulled towards the before until it touches one of the 3 guide-lines; if this is the start-guide this corresponds to the triggering of this rule:
+ 
+ http://atvaark.dyndns.org/~vincent/side-floats_placement-rule7.png
+ 
+  8.#8 the side-float is pulled towards the before as much as possible
+  9. the side-float is pulled towards the start/end as much as possible, but after having been pulled towards the before
+  10. if "clear" = "start" or "both", we place the before-guide at least at the level of the start-guide.
+  if "clear" = "end" or "both", we place the before-guide at least at the level of the end-guide.
+ 
+ So this model should provide a rather simple way to place side-floats. The most difficult part will be to find a suitable data structure for representing the guide snagged line, in order to easily compute it and update it.
+ 
+ Now I have to look at how to integrate such a model into Fop's code.
+ 
+ 
+ '''Credits'''
+ 
+ A huge thanks to [http://www.inkscape.org/ Inkscape], who made the drawing of all those figures so easy.
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org