PageLayout is a Java Bean that subclasses java.awt.Canvas, giving you the possibility to draw an empty page (with many bells and whistles) where to draw at a later time your reports.
In the following diagram you can see the role of PageLayout in the reports drawing process:
What is the relationship between LineViewMockup and PageLayout? I have tried to make each one independent from the other, so you can benefit from greater flexibility (you can easily replace one of the two steps of the process of printing -- drawing the page layout and drawing the actual data --with your own code). This comes with a price, of course: you have to setup and call methods for two distinct objects but, as you will see, this is no rocket science. Everything has been thought to be as intuitive as possible.
The icon for this JavaBean is the following:
It allows you to do the following things:
- Set margins for the report.
- Set information for header and footer: foreground and background colors, alignment, fonts, text (with macros that expand into current page number, total number of pages, current date and time).
- Set information for the blank page: foreground and background colors, alignment, watermark (centered, maximized, tiled).
- Draw all of the above in a Graphics object.
Use in IBM VisualAge for Java: you can connect PageLayout features to other beans events and properties, just like you would do with any other bean. However, since this bean inherits from java.awt.Canvas, you can use its Graphics space to draw a preview of the page layout.
Use in Symantec Visual Café: you can use PageLayout both as a normal class (using its methods) or as a visual component (this bean inherits from java.awt.Canvas). You should be warned, however, that PageLayout doesn't do anything with its Graphics object, and if you don't draw on it, it will remain blank.
Use of the PageLayout class with plain Jdk import nrio.reports.PageLayout; Is required in your Java source file.
Constructor:
PageLayout()
Methods:
drawPage(Graphics, int) Draws a page into a Graphics object, using current settings. drawPage(Graphics, int, PageSettings) Draws a page into a Graphics object, using specified settings getGeneralSettings() Gets the current settings for this PageLayout object. getNumOfPages() Gets the total number of pages for this report. getPageHeight() Gets the page height in pixels. getPageSize() Gets the page size (same as page height and width, but returned as a Dimension object instead of two integers). getPageWidth() Gets the page width in pixels. setGeneralSettings(PageSettings) Sets the current settings for this PageLayout object. setNumOfPages(int) Sets the total number of pages for this report. setPageHeight(int) Sets the page height in pixels. setPageSize(Dimension) Sets the page size (same as page height and width, but passed as a Dimension object instead of two integers). setPageWidth(int) Sets the page width in pixels.
Constructor:
PageLayout
public PageLayout()
Methods:
drawPage
public void drawPage(Graphics g, int pageNumber)
Draws a page into a Graphics object, using current settings.
drawPage
public void drawPage(Graphics g, int pageNumber, PageSettings genSettings)
Draws a page into a Graphics object, using specified settings.
getGeneralSettings
public PageSettings getGeneralSettings()
Gets the current settings for this PageLayout object.
getNumOfPages
public int getNumOfPages()
Gets the total number of pages for this report.
getPageHeight
public int getPageHeight()
Gets the page height in pixels.
getPageSize
public Dimension getPageSize()
Gets the page size (same as page height and width, but returned as a Dimension object instead of two integers).
getPageWidth
public int getPageWidth()
Gets the page width in pixels.
setGeneralSettings
public void setGeneralSettings(PageSettings generalSettings)
Sets the current settings for this PageLayout object.
setNumOfPages
public void setNumOfPages(int numOfPages)
Sets the total number of pages for this report.
setPageHeight
public void setPageHeight(int pageHeight)
Sets the page height in pixels.
setPageSize
public void setPageSize(Dimension pageSize)
Sets the page size (same as page height and width, but passed as a Dimension object instead of two integers).
setPageWidth
public void setPageWidth(int pageWidth)
Sets the page width in pixels.
|