org.jfree.report
Class Band

java.lang.Object
  |
  +--org.jfree.report.Element
        |
        +--org.jfree.report.Band
Direct Known Subclasses:
GroupFooter, GroupHeader, ItemBand, NoDataBand, PageFooter, PageHeader, ReportFooter, ReportHeader, Watermark

public class Band
extends Element
implements java.io.Serializable, java.lang.Cloneable

A report band is a collection of other elements and bands, similiar to an AWT-Container.

This implementation is not synchronized, to take care that you externally synchronize it when using multiple threads to modify instances of this class.

Bands automaticly inherit their style data to all their assigned childs.

Trying to add a parent of an band as child to the band, will result in an exception.

Author:
David Gilbert, Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String ANONYMOUS_BAND_PREFIX
          The prefix for anonymous bands, bands without an userdefined name.
static java.lang.String CONTENT_TYPE
          the defined content type for the band.
 
Fields inherited from class org.jfree.report.Element
ANONYMOUS_ELEMENT_PREFIX
 
Constructor Summary
Band()
          Constructs a new band (initially empty).
Band(boolean pagebreakBefore, boolean pagebreakAfter)
          Constructs a new band with the given pagebreak attributes.
 
Method Summary
 void addElement(Element element)
          Adds a report element to the band.
 void addElement(int position, Element element)
          Adds a report element to the band.
 void addElements(java.util.Collection elements)
          Adds a collection of elements to the band.
 java.lang.Object clone()
          Clones this band and all elements contained in this band.
protected  ElementDefaultStyleSheet createGlobalDefaultStyle()
          Returns the global stylesheet for all bands.
 java.lang.String getContentType()
          Returns the content type of the element.
 Element getElement(int index)
          Returns the element stored add the given index.
 Element getElement(java.lang.String name)
          Returns the first element in the list that is known by the given name.
 Element[] getElementArray()
          Returns an array of the elements in the band.
 int getElementCount()
          Returns the number of elements in this band.
 java.util.List getElements()
          Deprecated. use getElementArray() instead.
 BandLayoutManager getLayout()
          Returns the layout manager for the band.
 boolean isPagebreakAfterPrint()
          Returns, whether the page layout manager should perform a pagebreak before this page is printed.
 boolean isPagebreakBeforePrint()
          Returns, whether the page layout manager should perform a pagebreak before this page is printed.
 void removeElement(Element e)
          Removes an element from the band.
 void setLayout(BandLayoutManager layoutManager)
          Sets the band layout manager.
 void setPagebreakAfterPrint(boolean pagebreakAfterPrint)
          Defines, whether the page layout manager should perform a pagebreak before this page is printed.
 void setPagebreakBeforePrint(boolean pagebreakBeforePrint)
          Defines, whether the page layout manager should perform a pagebreak before this page is printed.
protected  void setReportDefinition(ReportDefinition reportDefinition)
          Assigns the report definition to this band.
 java.lang.String toString()
          Returns a string representation of the band and all the elements it contains, useful mainly for debugging purposes.
 
Methods inherited from class org.jfree.report.Element
connectDataSource, disconnectDataSource, getDataSource, getHRefTarget, getMaximumSize, getMinimumSize, getName, getObjectID, getParent, getPreferredSize, getReportDefinition, getStyle, getTreeLock, getValue, isDynamicContent, isLayoutCacheable, isVisible, setDataSource, setDynamicContent, setHRefTarget, setLayoutCacheable, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setVisible
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
the defined content type for the band. The content type is used when selecting the correct display-method for an element.

ANONYMOUS_BAND_PREFIX

public static final java.lang.String ANONYMOUS_BAND_PREFIX
The prefix for anonymous bands, bands without an userdefined name.
Constructor Detail

Band

public Band()
Constructs a new band (initially empty).

Band

public Band(boolean pagebreakBefore,
            boolean pagebreakAfter)
Constructs a new band with the given pagebreak attributes. Pagebreak attributes have no effect on subbands.
Parameters:
pagebreakAfter - defines, whether a pagebreak should be done after that band was printed.
pagebreakBefore - defines, whether a pagebreak should be done before that band gets printed.
Method Detail

createGlobalDefaultStyle

protected ElementDefaultStyleSheet createGlobalDefaultStyle()
Returns the global stylesheet for all bands. This stylesheet provides the predefined default values for some of the stylekeys.
Overrides:
createGlobalDefaultStyle in class Element
Returns:
the global default stylesheet.

getLayout

public BandLayoutManager getLayout()
Returns the layout manager for the band. Unless defined otherwise, the StaticBandLayoutManager is returned.
Returns:
The layout manager.

setLayout

public void setLayout(BandLayoutManager layoutManager)
Sets the band layout manager.
Parameters:
layoutManager - the layout manager.

addElement

public void addElement(Element element)
Adds a report element to the band.
Parameters:
element - the element that should be added
Throws:
java.lang.NullPointerException - if the given element is null
java.lang.IllegalArgumentException - if the position is invalid, either negative or greater than the number of elements in this band or if the given element is a parent of this element.

addElement

public void addElement(int position,
                       Element element)
Adds a report element to the band. The element will be inserted at the specified position.
Parameters:
position - the position where to insert the element
element - the element that should be added
Throws:
java.lang.NullPointerException - if the given element is null
java.lang.IllegalArgumentException - if the position is invalid, either negative or greater than the number of elements in this band or if the given element is a parent of this element.

addElements

public void addElements(java.util.Collection elements)
Adds a collection of elements to the band.
Parameters:
elements - the element collection.
Throws:
java.lang.NullPointerException - if one of the given elements is null
java.lang.IllegalArgumentException - if one of the given element is a parent of this element.

getElement

public Element getElement(java.lang.String name)
Returns the first element in the list that is known by the given name.
Parameters:
name - the element name.
Returns:
the first element with the specified name, or null if there is no such element.
Throws:
java.lang.NullPointerException - if the given name is null.

removeElement

public void removeElement(Element e)
Removes an element from the band.
Parameters:
e - the element to be removed.
Throws:
java.lang.NullPointerException - if the given element is null.

getElements

public java.util.List getElements()
Deprecated. use getElementArray() instead.

Returns all child-elements of this band as immutable list.
Returns:
an immutable list of all registered elements for this band.

getElementCount

public int getElementCount()
Returns the number of elements in this band.
Returns:
the number of elements of this band.

getElementArray

public Element[] getElementArray()
Returns an array of the elements in the band. If the band is empty, an empty array is returned.

For performance reasons, a shared cached instance is returned. Do not modify the returned array or live with the consquences.

Returns:
the elements.

getElement

public Element getElement(int index)
Returns the element stored add the given index.
Parameters:
index - the element position within this band
Returns:
the element
Throws:
java.lang.IndexOutOfBoundsException - if the index is invalid.

toString

public java.lang.String toString()
Returns a string representation of the band and all the elements it contains, useful mainly for debugging purposes.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this band.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this band and all elements contained in this band. After the cloning the band is no longer connected to a report definition.
Overrides:
clone in class Element
Returns:
the clone of this band.
Throws:
java.lang.CloneNotSupportedException - if this band or an element contained in this band does not support cloning.

getContentType

public java.lang.String getContentType()
Returns the content type of the element. For bands, the content type is by default "X-container".
Overrides:
getContentType in class Element
Returns:
the content type

isPagebreakBeforePrint

public boolean isPagebreakBeforePrint()
Returns, whether the page layout manager should perform a pagebreak before this page is printed. This will have no effect on empty pages or if the band is no root-level band.
Returns:
true, if to force a pagebreak before this band is printed, false otherwise

setPagebreakBeforePrint

public void setPagebreakBeforePrint(boolean pagebreakBeforePrint)
Defines, whether the page layout manager should perform a pagebreak before this page is printed. This will have no effect on empty pages or if the band is no root-level band.
Parameters:
pagebreakBeforePrint - set to true, if to force a pagebreak before this band is printed, false otherwise

isPagebreakAfterPrint

public boolean isPagebreakAfterPrint()
Returns, whether the page layout manager should perform a pagebreak before this page is printed. This will have no effect on empty pages or if the band is no root-level band.
Returns:
true, if to force a pagebreak before this band is printed, false otherwise

setPagebreakAfterPrint

public void setPagebreakAfterPrint(boolean pagebreakAfterPrint)
Defines, whether the page layout manager should perform a pagebreak before this page is printed. This will have no effect on empty pages or if the band is no root-level band.
Parameters:
pagebreakAfterPrint - set to true, if to force a pagebreak before this band is printed, false otherwise

setReportDefinition

protected void setReportDefinition(ReportDefinition reportDefinition)
Assigns the report definition to this band.
Overrides:
setReportDefinition in class Element
Parameters:
reportDefinition - the report definition or null, if the band is not part of a valid report definition.