ca.sqlpower.wabit.report
Class Page

java.lang.Object
  extended by ca.sqlpower.object.AbstractSPObject
      extended by ca.sqlpower.wabit.AbstractWabitObject
          extended by ca.sqlpower.wabit.report.Page
All Implemented Interfaces:
ca.sqlpower.object.SPObject, WabitObject

public class Page
extends AbstractWabitObject

A page is an arrangement of boxes and guides (usually page margins) on a container of a particular size. Boxes have data provided to them by content renderers, which can be fed by database queries, labels with variable substitution, or anything else. The actual report will be rendered to one or more pages--the content renderers specify whether or not they need another page to finish rendering their data.


Nested Class Summary
static class Page.PageOrientation
          Indicates the transformation that should be applied when this page is rendered.
static class Page.WabitObjectOrder
          FIXME This enum defines the WabitObject child classes a Page takes as well as the ordinal order of these child classes such that the class going before does not depend on the class that goes after.
 
Field Summary
static int DPI
          This is the Graphics2D standard for pixels-to-inches conversions.
 
Fields inherited from class ca.sqlpower.object.AbstractSPObject
uuid
 
Constructor Summary
Page(Page page)
          Copy constructor
Page(java.lang.String name, int width, int height, Page.PageOrientation orientation, boolean startWithGuides)
          Creates a page with the given custom width and height, and 1-inch margins.
Page(java.lang.String name, java.awt.print.PageFormat pageFormat)
          Creates a new page whose dimensions and orientation are equivalent to the values in the pageFormat.
 
Method Summary
protected  void addChildImpl(ca.sqlpower.object.SPObject child, int index)
           
 void addContentBox(ContentBox addme)
          Adds a content box to this page at the end of the list of content boxes.
 void addContentBox(ContentBox addme, int index)
          Adds a content box to this page at the given index in the list of content boxes.
 void addGuide(Guide addme)
          Adds a guide to the end of the list of guides.
 void addGuide(Guide addme, int index)
          Adds a guide to the list of guides at the given index.
 boolean allowsChildren()
           
 void applyPageFormat(java.awt.print.PageFormat pageFormat)
          Applies the given Java print API page format to this page object.
 int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
           
 java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()
           
 WabitObject getChildByName(java.lang.String getMe)
           
 java.util.List<WabitObject> getChildren()
          Returns an unmodifiable view of this page's boxes.
 java.util.List<ContentBox> getContentBoxes()
          Returns an unmodifiable view of this page's content boxes.
 java.awt.Font getDefaultFont()
           
 java.util.List<WabitObject> getDependencies()
           
 int getHeight()
          Returns the apparent height of the page.
 double getLeftMarginOffset()
           
 double getLowerMarginOffset()
           
 Page.PageOrientation getOrientation()
           
 java.awt.print.PageFormat getPageFormat()
          Gets a page format instance that describes this page's geometry in terms of the Java print API.
 double getRightMarginOffset()
           
 double getUpperMarginOffset()
           
 int getWidth()
          Returns the apparent width of the page.
protected  boolean removeChildImpl(ca.sqlpower.object.SPObject child)
           
 void removeContentBox(ContentBox removeme)
           
 void removeDependency(ca.sqlpower.object.SPObject dependency)
           
 boolean removeGuide(Guide removeme)
          Removes the first instance of this guide from the Page.
 void setDefaultFont(java.awt.Font defaultFont)
           
 void setHeight(int height)
          Sets the apparent height of the page.
 void setOrientation(Page.PageOrientation orientation)
           
 void setUniqueName(WabitObject addme, java.lang.String maybeUniqueName)
          If the name passed is already taken by children of this page (which at present, are Guides and ContentBoxes)then this method will generate a unique name for the WabitObject
 void setWidth(int width)
          Sets the apparent width of the page.
 
Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject
cleanup, commit, equals, generateNewUUID, getParent, getSession, isForegroundThread, removeChild, rollback, runInBackground, runInForeground, toString
 
Methods inherited from class ca.sqlpower.object.AbstractSPObject
addChild, addSPListener, begin, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, getChildren, getName, getUUID, removeSPListener, setName, setParent, setUUID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ca.sqlpower.object.SPObject
addChild, addSPListener, begin, getChildren, getName, getUUID, removeSPListener, setName, setParent, setUUID
 

Field Detail

DPI

public static final int DPI
This is the Graphics2D standard for pixels-to-inches conversions.

See Also:
Constant Field Values
Constructor Detail

Page

public Page(java.lang.String name,
            int width,
            int height,
            Page.PageOrientation orientation,
            boolean startWithGuides)
Creates a page with the given custom width and height, and 1-inch margins. The units for width and height are 1/72 of an inch, which correspond well with screen pixels in Java 2D (72 pixels = 1 inch).

Parameters:
width - The page width in units of 1/72 inch. The is the real apparent width of the page. If you are creating a landscape page, this value should be larger than the one you specify for height.
height - The page height in units of 1/72 inch. The is the real apparent height of the page. If you are creating a landscape page, this value should be smaller than the one you specify for width.
orientation - The page orientation. This value has a fun interplay with width and height, so be sure to specify this correctly based on the type of page you are creating.
startWithGuides - If true guides will be added to the page defining a 1 inch margin. If false the page will start guideless.

Page

public Page(Page page)
Copy constructor


Page

public Page(java.lang.String name,
            java.awt.print.PageFormat pageFormat)
Creates a new page whose dimensions and orientation are equivalent to the values in the pageFormat. The width of the page will be the apparent width of the visual page and the same will be true of the height.

Parameters:
name - The name for this WabitObject.
pageFormat - The Java printing API page format from which to read the dimensions and orientation. This object is not retained by this class, so subsequent changes you make to the pageFormat object will not affect this page.
Method Detail

getWidth

public int getWidth()
Returns the apparent width of the page. If this is a portrait page, this will usually be the smaller dimension.


setWidth

public void setWidth(int width)
Sets the apparent width of the page. If this is a portrait page, this should usually be the smaller dimension.


getHeight

public int getHeight()
Returns the apparent height of the page. If this is a portrait page, this will usually be the larger dimension.


setHeight

public void setHeight(int height)
Sets the apparent height of the page. If this is a portrait page, this should usually be the larger dimension.


getDefaultFont

public java.awt.Font getDefaultFont()

setDefaultFont

public void setDefaultFont(java.awt.Font defaultFont)

getOrientation

public Page.PageOrientation getOrientation()

setOrientation

public void setOrientation(Page.PageOrientation orientation)

addContentBox

public void addContentBox(ContentBox addme)
Adds a content box to this page at the end of the list of content boxes.

Parameters:
addme - The content box to add.

addContentBox

public void addContentBox(ContentBox addme,
                          int index)
Adds a content box to this page at the given index in the list of content boxes.

Parameters:
addme - The content box to add.
index - The index to add the content box at. This cannot be greater than the number of content boxes currently in the page.

removeContentBox

public void removeContentBox(ContentBox removeme)

setUniqueName

public void setUniqueName(WabitObject addme,
                          java.lang.String maybeUniqueName)
If the name passed is already taken by children of this page (which at present, are Guides and ContentBoxes)then this method will generate a unique name for the WabitObject

Parameters:
addme -
maybeUniqueName -

getChildByName

public WabitObject getChildByName(java.lang.String getMe)

getContentBoxes

public java.util.List<ContentBox> getContentBoxes()
Returns an unmodifiable view of this page's content boxes.


addGuide

public void addGuide(Guide addme)
Adds a guide to the end of the list of guides.

Parameters:
addme - The guide to add as a child of this page.

addGuide

public void addGuide(Guide addme,
                     int index)
Adds a guide to the list of guides at the given index.

Parameters:
addme - The guide to add to this page.
index - The index in the list of guides to add this guide to. This cannot be greater than the number of guides currently in the page.

getLeftMarginOffset

public double getLeftMarginOffset()

getRightMarginOffset

public double getRightMarginOffset()

getUpperMarginOffset

public double getUpperMarginOffset()

getLowerMarginOffset

public double getLowerMarginOffset()

allowsChildren

public boolean allowsChildren()

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)

getChildren

public java.util.List<WabitObject> getChildren()
Returns an unmodifiable view of this page's boxes.


removeGuide

public boolean removeGuide(Guide removeme)
Removes the first instance of this guide from the Page. Returns true if the guide was successfully removed. Returns false otherwise.

Parameters:
guide -
Returns:

getPageFormat

public java.awt.print.PageFormat getPageFormat()
Gets a page format instance that describes this page's geometry in terms of the Java print API.

Returns:
A throwaway PageFormat object that describes this page's current geometry. Changes to the returned PageFormat object will not affect this page in any way.

applyPageFormat

public void applyPageFormat(java.awt.print.PageFormat pageFormat)
Applies the given Java print API page format to this page object. The aspects that are affected are: If any changes are made to the page as a result of this operation, property change events for the individually affected properties will be fired as if those methods had been called directly.

Parameters:
pageFormat - The page format to apply to this page.

getDependencies

public java.util.List<WabitObject> getDependencies()

removeDependency

public void removeDependency(ca.sqlpower.object.SPObject dependency)

removeChildImpl

protected boolean removeChildImpl(ca.sqlpower.object.SPObject child)
Specified by:
removeChildImpl in class ca.sqlpower.object.AbstractSPObject

addChildImpl

protected void addChildImpl(ca.sqlpower.object.SPObject child,
                            int index)
Overrides:
addChildImpl in class ca.sqlpower.object.AbstractSPObject

getAllowedChildTypes

public java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()


Copyright © 2009. All Rights Reserved.