com.jrefinery.report.targets.base.bandlayout
Class AbstractBandLayoutManager

java.lang.Object
  |
  +--com.jrefinery.report.targets.base.bandlayout.AbstractBandLayoutManager
All Implemented Interfaces:
BandLayoutManager
Direct Known Subclasses:
CardLayoutBLayoutManager, GridBLayoutManager, StaticLayoutManager

public abstract class AbstractBandLayoutManager
extends java.lang.Object
implements BandLayoutManager

An abstract band layout manager.

Author:
Thomas Morgner.

Field Summary
 
Fields inherited from interface com.jrefinery.report.targets.base.bandlayout.BandLayoutManager
LAYOUTMANAGER
 
Constructor Summary
protected AbstractBandLayoutManager()
          Default constructor.
 
Method Summary
protected  float align(float value, float boundary)
          Aligns the given value to the boundary.
protected  java.awt.geom.Dimension2D correctDimension(java.awt.geom.Dimension2D dim, java.awt.geom.Dimension2D base, java.awt.geom.Dimension2D retval)
          Corrects the relative (proportional) values.
protected  java.awt.geom.Point2D correctPoint(java.awt.geom.Point2D dim, java.awt.geom.Dimension2D base, java.awt.geom.Point2D retval)
          Corrects the relative (proportional) values.
protected  ElementLayoutInformation createLayoutInfoForDynamics(Element e, java.awt.geom.Dimension2D parentDim)
          Creates a layout information object for a DynamicElement content calculation.
protected  ElementLayoutInformation createLayoutInformationForMinimumSize(Element e, java.awt.geom.Dimension2D containerBounds)
          Creates layout information for the minimum size.
protected  ElementLayoutInformation createLayoutInformationForPreferredSize(Element e, java.awt.geom.Dimension2D containerDims)
          Creates layout information for the preferred size.
protected  java.awt.geom.Dimension2D getElementContentBounds(java.awt.geom.Dimension2D bounds, Element e, java.awt.geom.Dimension2D conBounds)
          Calculates the size of an element by creating the content for this element and then trying to layout that content.
 LayoutSupport getLayoutSupport()
          Returns the output target for the layout manager.
protected  java.awt.geom.Dimension2D getMinimumSize(Element e, java.awt.geom.Dimension2D containerBounds)
          Returns the minimum size for an element.
protected  java.awt.geom.Dimension2D getPreferredSize(Element e, java.awt.geom.Dimension2D containerBounds)
          Calculates the preferred size of an element.
protected  boolean isElementStaticHeight(Element e)
          Returns true if the element has a static height, and false otherwise.
protected  boolean isElementStaticWidth(Element e)
          Returns true if the element has a static width, and false otherwise.
 void setLayoutSupport(LayoutSupport target)
          Sets the output target for the layout manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.report.targets.base.bandlayout.BandLayoutManager
doLayout, invalidateLayout, minimumLayoutSize, preferredLayoutSize
 

Constructor Detail

AbstractBandLayoutManager

protected AbstractBandLayoutManager()
Default constructor.

Method Detail

getMinimumSize

protected java.awt.geom.Dimension2D getMinimumSize(Element e,
                                                   java.awt.geom.Dimension2D containerBounds)
Returns the minimum size for an element.

Parameters:
e - the element.
containerBounds - the bounds of the elements parents.
Returns:
the minimum size.

getPreferredSize

protected java.awt.geom.Dimension2D getPreferredSize(Element e,
                                                     java.awt.geom.Dimension2D containerBounds)
Calculates the preferred size of an element.

Parameters:
e - the element.
containerBounds - the bounds of the element's container.
Returns:
the preferred size of the element.

getElementContentBounds

protected java.awt.geom.Dimension2D getElementContentBounds(java.awt.geom.Dimension2D bounds,
                                                            Element e,
                                                            java.awt.geom.Dimension2D conBounds)
Calculates the size of an element by creating the content for this element and then trying to layout that content. This operation is performed for all "dynamic" elements.

Calculation rules: Take the width of given bounds to calculate a height based on the content. Then cut the content to a maybe defined max-value. todo redefine the context creation process, height or width can be dynamic

Parameters:
bounds - the bounds of the element calculated so far.
e - the element.
conBounds - the bounds of the surrounding container.
Returns:
the new elements dimension.

createLayoutInfoForDynamics

protected ElementLayoutInformation createLayoutInfoForDynamics(Element e,
                                                               java.awt.geom.Dimension2D parentDim)
Creates a layout information object for a DynamicElement content calculation. The maximum height is only limited by the elements max height, not by the parent.

Parameters:
e - the element for that the layout should be done.
parentDim - the dimensions for the parent of the element
Returns:
the created layout information.

createLayoutInformationForMinimumSize

protected ElementLayoutInformation createLayoutInformationForMinimumSize(Element e,
                                                                         java.awt.geom.Dimension2D containerBounds)
Creates layout information for the minimum size.

Parameters:
e - the element.
containerBounds - the bounds of the container.
Returns:
layout information.

createLayoutInformationForPreferredSize

protected ElementLayoutInformation createLayoutInformationForPreferredSize(Element e,
                                                                           java.awt.geom.Dimension2D containerDims)
Creates layout information for the preferred size.

Parameters:
e - the element.
containerDims - the dimensions of the container.
Returns:
layout information.

setLayoutSupport

public void setLayoutSupport(LayoutSupport target)
Sets the output target for the layout manager. The LayoutManager support must be cleared (set to null) after the layouting is complete.

Specified by:
setLayoutSupport in interface BandLayoutManager
Parameters:
target - the target.

getLayoutSupport

public LayoutSupport getLayoutSupport()
Returns the output target for the layout manager.

Specified by:
getLayoutSupport in interface BandLayoutManager
Returns:
the target.

isElementStaticWidth

protected boolean isElementStaticWidth(Element e)
Returns true if the element has a static width, and false otherwise.

Parameters:
e - the element.
Returns:
true or false.

isElementStaticHeight

protected boolean isElementStaticHeight(Element e)
Returns true if the element has a static height, and false otherwise.

Parameters:
e - the element.
Returns:
true or false.

correctDimension

protected java.awt.geom.Dimension2D correctDimension(java.awt.geom.Dimension2D dim,
                                                     java.awt.geom.Dimension2D base,
                                                     java.awt.geom.Dimension2D retval)
Corrects the relative (proportional) values. The values are given in the range from -100 (= 100%) to 0 (0%) and are resolved to the base values.

Parameters:
dim - the dimension that should be corrected.
base - the base to define the 100% limit.
retval - the return value.
Returns:
the corrected dimension.

correctPoint

protected java.awt.geom.Point2D correctPoint(java.awt.geom.Point2D dim,
                                             java.awt.geom.Dimension2D base,
                                             java.awt.geom.Point2D retval)
Corrects the relative (proportional) values. The values are given in the range from -100 (= 100%) to 0 (0%) and are resolved to the base values.

Parameters:
dim - the point that should be corrected.
base - the base to define the 100% limit.
retval - the return value.
Returns:
the corrected point.

align

protected float align(float value,
                      float boundary)
Aligns the given value to the boundary.

Parameters:
value - the value.
boundary - the boundary.
Returns:
The aligned value.