public class Report extends Object implements Printable, Pageable
Can be used as Printable or Pageable. If used as Pageable the number of
pages will be determined in dummy pass first and then printed in a second pass.
If used as a Printable there is only one pass.
The report is implemented as a statemachine and gets its data
from a ReportSource.
| Modifier and Type | Field and Description |
|---|---|
static int |
CENTER
center panel
|
static int |
EAST
align right
|
static int |
NORTH
align top
|
static int |
NORTHEAST
align top right
|
static int |
NORTHWEST
align top left (default)
|
static int |
SCALE_FIXED
fixed scaling (default = 1.0)
|
static int |
SCALE_IF_WIDER
scale (make smaller) to fit if wider than paper
|
static int |
SCALE_TO_FIT
scale to paper-width (enlarge or shrink)
|
static int |
SOUTH
align bottom
|
static int |
SOUTHEAST
align bottom right
|
static int |
SOUTHWEST
align bottom left
|
static int |
WEST
align left
|
NO_SUCH_PAGE, PAGE_EXISTSUNKNOWN_NUMBER_OF_PAGES| Constructor and Description |
|---|
Report(ReportSource source,
PageFormat pageFormat)
Creates a standard report which honors the imageable size
and has no sublevels.
|
Report(ReportSource source,
PageFormat pageFormat,
boolean imageable,
int subLevels)
Creates a report.
|
| Modifier and Type | Method and Description |
|---|---|
int |
currentPage()
Get the current page-number.
|
int |
currentState()
Gets the current state.
|
int |
getAdvance()
Gets last returned code.
|
int |
getAutoScale()
Gets the autoscale mode.
|
int |
getLevel()
Get the current logical group level.
|
int |
getMoveAfter()
Gets the pending pixels to move after printing the next panel.
|
int |
getMoveBefore()
Gets the pending pixels to move before printing the next panel.
|
int |
getNumberOfPages()
Determines the number of pages *before* running the report.
|
PageFormat |
getPageFormat(int pageIndex) |
Printable |
getPrintable(int pageIndex) |
Runnable |
getRunAfter()
Gets
therunnable to be executed once after printing the next panel
|
Runnable |
getRunBefore()
Gets the runnable to be executed once before printing the next panel.
|
double |
getScale()
Gets the current scaling
|
int |
getYMax()
Retrieves the maximum printed y position so far for current page.
|
int |
getYOffset()
Retrieves the maximum printed y offset so far for current page.
|
int |
print(Graphics graphics,
PageFormat pageFormat,
int pageIndex)
Runs the report.
This implements the interface Printable. |
void |
setAutoScale(int autoScale)
Sets the automatic scaling.
|
void |
setFooter(PrintPanel footer)
Sets the footer panel.
|
void |
setFooterAlignment(int align)
Sets the aligment of the footer.
|
void |
setFooterSize(Dimension size)
Optionally sets the size of the footer if
not derived from the print panel.
|
void |
setHeader(PrintPanel header)
Sets the header panel.
|
void |
setHeaderAlignment(int align)
Sets the aligment of the header.
|
void |
setHeaderSize(Dimension size)
Optionally sets the size of the header if
not derived from the print panel.
|
void |
setIntro(PrintPanel intro)
Sets the intro panel.
|
void |
setIntroAlignment(int align)
Sets the aligment of the intro.
|
void |
setIntroSize(Dimension size)
Optionally sets the size of the intro if
not derived from the print panel.
|
void |
setLine(PrintPanel line)
Sets the panel for printing the data line.
|
void |
setLineAlignment(int align)
Sets the aligment of the data line.
|
void |
setLineSize(Dimension size)
Optionally sets the size of the data line if
not derived from the print panel.
|
void |
setMoveAfter(int moveAfter)
Sets the pixels to move after printing the next panel.
The attribute will be cleared when used. |
void |
setMoveBefore(int moveBefore)
Sets the pixels to move before printing the next panel.
The attribute will be cleared when used. |
void |
setRunAfter(Runnable runAfter)
Sets a runnable to be executed once after printing the next panel
|
void |
setRunBefore(Runnable runBefore)
Sets a runnable to be executed once before printing the next panel.
|
void |
setScale(double scale)
Sets the scaling.
|
void |
setSubFooter(PrintPanel[] subFooter)
Sets the subfooters.
|
void |
setSubFooterAlignment(int[] align)
Sets the aligment of the subfooters.
|
void |
setSubFooterSize(Dimension[] sizes)
Optionally sets the size of the subfooters if
not derived from the print panel.
|
void |
setSubHeader(PrintPanel[] subHeader)
Sets the subheaders.
|
void |
setSubHeaderAlignment(int[] align)
Sets the aligment of the subheaders.
|
void |
setSubHeaderSize(Dimension[] sizes)
Optionally sets the size of the subheaders if
not derived from the print panel.
|
void |
setTrailer(PrintPanel trailer)
Sets the trailer panel.
|
void |
setTrailerAlignment(int align)
Sets the aligment of the trailer.
|
void |
setTrailerSize(Dimension size)
Optionally sets the size of the trailer if
not derived from the print panel.
|
void |
triggerPrintAgain()
Triggers the last panel to be printed again.
|
public static final int NORTHWEST
public static final int NORTHEAST
public static final int SOUTHWEST
public static final int SOUTHEAST
public static final int CENTER
public static final int EAST
public static final int WEST
public static final int SOUTH
public static final int NORTH
public static final int SCALE_FIXED
public static final int SCALE_IF_WIDER
public static final int SCALE_TO_FIT
public Report(ReportSource source, PageFormat pageFormat, boolean imageable, int subLevels)
source - the data source for this reportpageFormat - the pageformatimageable - true if honor the imageable size, else full page sizesubLevels - number of sublevels, default is 0 (no groups)public Report(ReportSource source, PageFormat pageFormat)
source - the data source for this reportpageFormat - the pageformatpublic void setIntro(PrintPanel intro) throws PrinterException
intro - the intro panel, null for none (i.e. print header instead)PrinterException - if failedpublic void setTrailer(PrintPanel trailer) throws PrinterException
trailer - the trailer panel, null for none (i.e. print footer instead)PrinterException - if failedpublic void setHeader(PrintPanel header) throws PrinterException
header - the header panel, null for none.PrinterException - if failedpublic void setFooter(PrintPanel footer) throws PrinterException
footer - the footer panel, null for none.PrinterException - if failedpublic void setLine(PrintPanel line) throws PrinterException
line - the line panel, null if nonePrinterException - if failedpublic void setSubHeader(PrintPanel[] subHeader) throws PrinterException
subHeader - the array of subheaders (size must match levels)PrinterException - if failedpublic void setSubFooter(PrintPanel[] subFooter) throws PrinterException
subFooter - the array of subfooter (size must match levels)PrinterException - if failedpublic void setIntroAlignment(int align)
throws PrinterException
align - the alignmentPrinterException - if failedpublic void setTrailerAlignment(int align)
throws PrinterException
align - the alignmentPrinterException - if failedpublic void setHeaderAlignment(int align)
throws PrinterException
align - the alignmentPrinterException - if failedpublic void setFooterAlignment(int align)
throws PrinterException
align - the alignmentPrinterException - if failedpublic void setLineAlignment(int align)
throws PrinterException
align - the alignmentPrinterException - if failedpublic void setSubHeaderAlignment(int[] align)
throws PrinterException
align - the array of alignments (size must match levels)PrinterException - if failedpublic void setSubFooterAlignment(int[] align)
throws PrinterException
align - the array of alignments (size must match levels)PrinterException - if failedpublic void setIntroSize(Dimension size) throws PrinterException
size - the dimensionPrinterException - if failedpublic void setTrailerSize(Dimension size) throws PrinterException
size - the dimensionPrinterException - if failedpublic void setHeaderSize(Dimension size) throws PrinterException
size - the dimensionPrinterException - if failedpublic void setFooterSize(Dimension size) throws PrinterException
size - the dimensionPrinterException - if failedpublic void setLineSize(Dimension size) throws PrinterException
size - the dimensionPrinterException - if failedpublic void setSubHeaderSize(Dimension[] sizes) throws PrinterException
sizes - the array of dimensions (must match levels)PrinterException - if failedpublic void setSubFooterSize(Dimension[] sizes) throws PrinterException
sizes - the array of dimensions (must match levels)PrinterException - if failedpublic int getLevel()
public int currentState()
ReportSource.advance(org.tentackle.swing.print.Report)public int currentPage()
public void setScale(double scale)
scale - the scalingpublic double getScale()
public void setAutoScale(int autoScale)
autoScale - the scale modepublic int getAutoScale()
public void setMoveBefore(int moveBefore)
moveBefore - the number of pixels (> 0 to move down)public int getMoveBefore()
public void setMoveAfter(int moveAfter)
moveAfter - the number of pixels (> 0 to move down)public int getMoveAfter()
public void setRunBefore(Runnable runBefore)
runBefore - the runnablepublic Runnable getRunBefore()
public void setRunAfter(Runnable runAfter)
runAfter - the runnablepublic Runnable getRunAfter()
public void triggerPrintAgain()
public int getYMax()
public int getYOffset()
public int getAdvance()
ReportSource.advance(org.tentackle.swing.print.Report)public int getNumberOfPages()
getNumberOfPages in interface Pageablepublic int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
Printable.print in interface PrintablePrinterExceptionpublic PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException
getPageFormat in interface PageableIndexOutOfBoundsExceptionpublic Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException
getPrintable in interface PageableIndexOutOfBoundsExceptionTentackle - distributed, domain- and model-driven