com.jrefinery.report.targets.pageable.physicals
Class LogicalPageImpl

java.lang.Object
  |
  +--com.jrefinery.report.targets.pageable.physicals.LogicalPageImpl
All Implemented Interfaces:
LogicalPage

public class LogicalPageImpl
extends java.lang.Object
implements LogicalPage

A simple logical page implementation. Does work with a single physical page and is not yet able to distribute its contents.

Author:
Thomas Morgner

Constructor Summary
LogicalPageImpl(java.awt.print.PageFormat format)
          Creates a new logical page, where the physical page format is equal to the logical page format.
LogicalPageImpl(java.awt.print.PageFormat log, java.awt.print.PageFormat phys)
          Creates a new logical page.
 
Method Summary
 void addBand(java.awt.geom.Rectangle2D bounds, Band band)
          Add all elements from the band to this logical page.
 void close()
          Close this logical page and all physical pages.
protected  OperationFactory createOperationFactory()
          Initializes the operations factory.
 float getHeight()
          Get the height of this logical page.
 OperationFactory getOperationFactory()
          Gets the local instance of the operations factory.
 OutputTarget getOutputTarget()
          Returns the OutputTarget used to display the contents of this logical page.
 java.awt.print.PageFormat getPageFormat()
          Returns the logical page format.
 PhysicalPage getPhysicalPage(int x, int y)
          Returns the physical page at a particular row and column of the PageGrid.
 java.awt.print.PageFormat getPhysicalPageFormat()
          Returns the physical page format.
 float getWidth()
          Get the width of this logical page.
 boolean isEmpty()
          Test whether this page is empty.
 boolean isOpen()
          Test whether is logical page is opened and bands can be added to the page.
 LogicalPage newInstance()
          Returns a new instance of this logical page, fully initialized as this page, but without this pages state cloned.
 void open()
          Opens the logical page.
 void replaySpool(Spool operations)
          Replays a previously recorded spool.
 void setOutputTarget(OutputTarget ot)
          Defines the OutputTarget that is used to finally print the content.
 void setPageFormat(java.awt.print.PageFormat format)
          Sets the logical page format.
 void setPhysicalPageFormat(java.awt.print.PageFormat format)
          Sets the physical page format.
 Spool spoolBand(java.awt.geom.Rectangle2D bounds, Band band)
          Creates a spool made up of the contents generated from the given Band.
protected  void spoolBand(java.awt.geom.Rectangle2D bounds, Band band, Spool spool)
          Creates a spool made up of the contents generated from the given Band.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogicalPageImpl

public LogicalPageImpl(java.awt.print.PageFormat format)
Creates a new logical page, where the physical page format is equal to the logical page format.

Parameters:
format - the page format.

LogicalPageImpl

public LogicalPageImpl(java.awt.print.PageFormat log,
                       java.awt.print.PageFormat phys)
Creates a new logical page. This creates a set of physical pages to receive the content generated by the logical page.

Parameters:
log - the logical page format.
phys - the physical page format.
Method Detail

getOperationFactory

public OperationFactory getOperationFactory()
Gets the local instance of the operations factory. The operation factory is responsible for converting content into basic operations, which can be executed on the OutputTarget.

Returns:
the local operation factory.

createOperationFactory

protected OperationFactory createOperationFactory()
Initializes the operations factory. The operation factory is responsible for converting content into basic operations, which can be executed on the OutputTarget.

Returns:
the local operation factory.

getPhysicalPage

public PhysicalPage getPhysicalPage(int x,
                                    int y)
Returns the physical page at a particular row and column of the PageGrid. The logical page can be split into multiple physical pages to display content that would not fit on a single page.

Parameters:
x - the X-Coordinate in the page grid.
y - the Y-Coordinate in the page grid.
Returns:
the physical page.

setOutputTarget

public void setOutputTarget(OutputTarget ot)
Defines the OutputTarget that is used to finally print the content.

Specified by:
setOutputTarget in interface LogicalPage
Parameters:
ot - the outputTarget, must not be null
Throws:
java.lang.NullPointerException - if the given OutputTarget is null

getOutputTarget

public OutputTarget getOutputTarget()
Returns the OutputTarget used to display the contents of this logical page.

Specified by:
getOutputTarget in interface LogicalPage
Returns:
the defined OutputTarget

getPageFormat

public java.awt.print.PageFormat getPageFormat()
Returns the logical page format.

Returns:
the page format.

setPageFormat

public void setPageFormat(java.awt.print.PageFormat format)
Sets the logical page format.

Parameters:
format - the page format (null not permitted).

getPhysicalPageFormat

public java.awt.print.PageFormat getPhysicalPageFormat()
Returns the physical page format.

Specified by:
getPhysicalPageFormat in interface LogicalPage
Returns:
the page format.

setPhysicalPageFormat

public void setPhysicalPageFormat(java.awt.print.PageFormat format)
Sets the physical page format.

Parameters:
format - the page format.

addBand

public void addBand(java.awt.geom.Rectangle2D bounds,
                    Band band)
             throws OutputTargetException
Add all elements from the band to this logical page. The content is also distributed over the assigned physical pages.

Specified by:
addBand in interface LogicalPage
Parameters:
bounds - where to add the band. The bands were calculated by the PageLayouter
band - the band which will be added to the page
Throws:
OutputTargetException - if the band addition failed

replaySpool

public void replaySpool(Spool operations)
Replays a previously recorded spool. The spool is a collection of PhysicalOperations.

Specified by:
replaySpool in interface LogicalPage
Parameters:
operations - the operations.

spoolBand

public Spool spoolBand(java.awt.geom.Rectangle2D bounds,
                       Band band)
                throws OutputTargetException
Creates a spool made up of the contents generated from the given Band. The band is printed at the location and with the dimensions specified in bounds.

Spooling is the process of creating operations suitable for the physical pages.

ToDo: Support distribution over multiple pages ...

Specified by:
spoolBand in interface LogicalPage
Parameters:
bounds - the bounds that define where to print the given band on this logical page
band - the band that should be spooled/printed
Returns:
the generated spool for the given band
Throws:
OutputTargetException - if there is a problem with the output target.

spoolBand

protected void spoolBand(java.awt.geom.Rectangle2D bounds,
                         Band band,
                         Spool spool)
                  throws OutputTargetException
Creates a spool made up of the contents generated from the given Band. The band is printed at the location and with the dimensions specified in bounds.

Spooling is the process of creating operations suitable for the physical pages. The generated operations are added to the given spool.

ToDo: Support distribution over multiple pages ...

Parameters:
bounds - the bounds that define where to print the given band on this logical page
band - the band that should be spooled/printed
spool - the spool which collects the generated operations.
Throws:
OutputTargetException - if there is a problem with the output target.

close

public void close()
Close this logical page and all physical pages. Write the content to the OutputTarget. todo how to handle multiple physical pages? How to specify which page should be printed ...

Specified by:
close in interface LogicalPage

isOpen

public boolean isOpen()
Test whether is logical page is opened and bands can be added to the page.

Specified by:
isOpen in interface LogicalPage
Returns:
true if the page is open, false otherwise

open

public void open()
Opens the logical page. Prepare everything to get bands added.

Specified by:
open in interface LogicalPage

isEmpty

public boolean isEmpty()
Test whether this page is empty. A logical page is empty, when all physical pages are empty (no operations were executed there).

Specified by:
isEmpty in interface LogicalPage
Returns:
true, if the page is empty and nothing was printed, false otherwise.

getWidth

public float getWidth()
Get the width of this logical page. Logical pages start at coordinate (0,0) and have no borders. Borders should be handled by the Physical Pages.

Specified by:
getWidth in interface LogicalPage
Returns:
the defined width of this logical page.

getHeight

public float getHeight()
Get the height of this logical page. Logical pages start at coordinate (0,0) and have no borders. Borders should be handled by the Physical Pages.

Specified by:
getHeight in interface LogicalPage
Returns:
the defined height of this logical page.

newInstance

public LogicalPage newInstance()
Returns a new instance of this logical page, fully initialized as this page, but without this pages state cloned.

Specified by:
newInstance in interface LogicalPage
Returns:
a new instance of this LogicalPage