ca.sqlpower.wabit.report
Class Page

java.lang.Object
  extended by ca.sqlpower.wabit.AbstractWabitObject
      extended by ca.sqlpower.wabit.report.Page
All Implemented Interfaces:
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.
 
Field Summary
static int DPI
          This is the Graphics2D standard for pixels-to-inches conversions.
 
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(WabitObject child, int index)
          This is the object specific implementation of #addChild(WabitObject).
 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()
          Returns true if this object may contain children.
 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 WabitObject> childType)
          Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.
 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()
          Returns a list of all WabitObjects that this Wabit object is dependent on.
 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(WabitObject child)
          This is the object specific implementation of removeChild.
 void removeContentBox(ContentBox removeme)
           
 void removeDependency(WabitObject dependency)
          Removes the given object as a dependency of this object.
 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
addChild, addWabitListener, begin, beginTransaction, cleanup, commit, commitTransaction, equals, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, generateNewUUID, getChildren, getName, getParent, getSession, getUUID, isForegroundThread, removeChild, removeWabitListener, rollback, rollbackTransaction, runInBackground, runInForeground, setName, setParent, setUUID, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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()
Description copied from interface: WabitObject
Returns true if this object may contain children. Not all types of WabitObjects can be a child to any WabitObject.

See Also:
WabitObject.childPositionOffset(Class)

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
Description copied from interface: WabitObject
Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.


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()
Description copied from interface: WabitObject
Returns a list of all WabitObjects that this Wabit object is dependent on. Children of a WabitObject are not dependencies and will not be returned in this list. If there are no objects this Wabit object is dependent on an empty list should be returned. These are only the immediate dependencies of this object. If you want to find the dependencies of this object's dependencies as well it may be useful to look at WorkspaceGraphModel to make a full graph of all of the dependencies.


removeDependency

public void removeDependency(WabitObject dependency)
Description copied from interface: WabitObject
Removes the given object as a dependency of this object. For this object to no longer be dependent on the given dependency all of its children must also not be dependent on the given dependency when this method returns. This may remove this object from its parent if necessary.


removeChildImpl

protected boolean removeChildImpl(WabitObject child)
Description copied from class: AbstractWabitObject
This is the object specific implementation of removeChild. There are checks in the removeChild method to ensure the child being removed has no dependencies and is a child of this object.

Specified by:
removeChildImpl in class AbstractWabitObject
See Also:
AbstractWabitObject.removeChild(WabitObject)

addChildImpl

protected void addChildImpl(WabitObject child,
                            int index)
Description copied from class: AbstractWabitObject
This is the object specific implementation of #addChild(WabitObject). There are checks in the #addChild(WabitObject) method to ensure that the object given here is a valid child type of this object.

This method should be overwritten if children are allowed.

Overrides:
addChildImpl in class AbstractWabitObject
Parameters:
child - The child to add to this object.
index - The index to add the child at.


Copyright © 2009. All Rights Reserved.