Jump to content
Changes to the Jaspersoft community edition download ×

How to impliment a fluid layout, and what do "Stretch" and "Split" mean in Jaspersoft?


Create
Go to solution Solved by Create,

Recommended Posts

Hi guys,

I'm trying to understand how to control run-time vertical spacing, especially with embedded sub-reports which can display a variable number of records.

I'm also confused by the terms 'Stretch' and 'Split' as used in the Jaspersoft documentation.  Either I don't understand them, or they don't work as expected.  To me 'Stretch' is like stretch-jeans, they get bigger when you put your legs in.  Then there's a 'split' if things get too big inside.  LOL.  Ok, enough kidding, what do these terms mean in the Jaspersoft context?

I'm already familair with the ability to vertically flow data from a variable number of input records with MS Access, HTML, Word, LibreOffice Writer, etc.  So I'm hoping for similar functionality in Jaspersoft.  It seems to work only some of the time.  In Access for example, almost all controls have 'Can Grow' and 'Can Shrink' options to control page flow:

* When Can Grow   is true, and if there is more content                 then the bounding box grows larger,     and everything below it is pushed down. 
* When Can Shrink is true, and if there is less   content, or none, then the bounding box shrinks smaller, and everything below it scoots up.

In HTML you can fix the size of a <div> .. </div> container, or you can let it's content determine the size.  Everything that follows below it depends on it's run time vertical size.

Does Jaspersoft have this sort of functionality, and if so how does one control it?  For example a sub-report's appearance properties have "Stretch Type", but I can't seem to make this do anything.  (I'm working on a sub-report with 1 to 4 possible lines in my Title band.)

Bonus points if you will say what these mean under Size:

Stretch type:   No Stretch  Relative to Talles Object (depreciated)  Relative to Band Height (depreciated)  ElementGroupHeight  ElementGroupBottom  ContainerHeight  Container Bottom[/code]

Thanks

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

First, use Position Type: Fixed to Top and the control will stay put and not be pushed down if things above it overflow.  Or set it to Float to allow it to be pushed down by things above getting bigger.  Fixed to Bottom is similar to Fixed to Top.

Next, splitting appears to refer to how data is split, from one page to the next.  It's discussed in The jasperreports-library-ultimate-guide   page 118, in PREVENTING BAND SPLIT.

In some cases it is desirable to keep the whole contents of a given band in one piece to
prevent page breaks when the band stretches beyond its initial specified height. To do
this, use the splitType attribute, as follows:


 Split stretched content: The band never splits within its declared height. The band
will not start rendering on the current page if the remaining available space is not at
least equal to the band's declared height. However, if the band stretches on the
current page, the region that is added to the original height is allowed to split onto
the next page ( splitType="Stretch" ).


Prevent split on first attempt: The band starts to render normally, but if the bottom
of the page is reached without finishing the band, the whole contents of the band
that are already being laid out are moved to the next page. If the band does not fit
on the next page, the split occurs normally, as band split prevention is effective
only on first split attempt ( splitType="Prevent" ).


 Split immediately: The band is allowed to split anywhere except above its topmost
element ( splitType="Immediate" ).


If a split type is not specified, the default is given by the
net.sf.jasperreports.band.split.type configuration property.

 

Finally, from: http://jasperreports.sourceforge.net/schema.reference.html#reportElement

 
stretchType
 Specifies the element stretch behavior relative to its element group siblings or element container stretch.
 Use: optional
 Base Type: string
 Values
 
NoStretch The element won't stretch vertically beyond its natural stretch height, when the container stretches to display other elements.
RelativeToTallestObject Deprecated. Replaced by ElementGroupHeight value.
RelativeToBandHeight Deprecated. Replaced by ContainerHeight value.
ElementGroupBottom The element will stretch to accommodate the overall natural growth of its group, but also taking into account the shifting Y position of the element within its group. See the elementGroup element, to see how to group elements.
ElementGroupHeight The element will stretch to accommodate the overall natural growth of its group, without taking into account the shifting Y position of the element within its group. See the elementGroup element, to see how to group elements.
ContainerBottom The element will stretch to fit the container height, while taking into account its new Y position. This results in the element preserving its distance to the container's bottom edge.
ContainerHeight The element will stretch to fit the container height, but without taking into account its new Y position. This might results in the element being shifted up (due to collapsing elements above) or down (due to stretching elements above that push it downards) relative to the container bottom edge. In case the element its already pushed downwards, the additional stretch imposed by the container might actually throw it beyond the container's bottom edge, in which case the element will not render at all.
 Default: NoStretch
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...