ca.sqlpower.wabit.report
Class Layout

java.lang.Object
  extended by ca.sqlpower.wabit.AbstractWabitObject
      extended by ca.sqlpower.wabit.report.Layout
All Implemented Interfaces:
WabitObject, java.awt.print.Pageable, java.awt.print.Printable
Direct Known Subclasses:
Report, Template

public abstract class Layout
extends AbstractWabitObject
implements java.awt.print.Pageable, java.awt.print.Printable


Nested Class Summary
 class Layout.LayoutVarContext
           
 
Field Summary
protected  Page page
          The page size and margin info.
static java.lang.String PAGE_NUMBER
          A property that defines which page is currently being printed.
static java.lang.String PROPERTY_ZOOM
           
 Layout.LayoutVarContext varContext
           
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
Layout(Page page)
           
Layout(java.lang.String uuid)
           
Layout(java.lang.String uuid, Page page)
           
 
Method Summary
protected  void addChildImpl(WabitObject child, int index)
          This is the object specific implementation of #addChild(WabitObject).
 boolean allowsChildren()
          Returns true if this object may contain children.
 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.
 boolean compareAndSetCurrentlyPrinting(boolean expected, boolean updateValue)
           
 java.util.List<Page> getChildren()
          Returns an unmodifiable list of the children in this WabitObject.
 java.util.List<WabitObject> getDependencies()
          Returns a list of all WabitObjects that this Wabit object is dependent on.
 int getNumberOfPages()
          Before getting the page count the currentlyPrinting flag should be set.
 Page getPage()
           
 java.awt.print.PageFormat getPageFormat(int pageIndex)
           
 java.awt.print.Printable getPrintable(int pageIndex)
           
 Layout.LayoutVarContext getVarContext()
           
 int getZoomLevel()
           
 boolean isCurrentlyPrinting()
           
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
          Prints a page of this report to the given graphics context.
protected  boolean removeChildImpl(WabitObject child)
          This is the object specific implementation of removeChild.
 void removeDependency(WabitObject dependency)
          Removes the given object as a dependency of this object.
 void setPage(Page page)
           
 void setVariable(java.lang.String name, java.lang.Object value)
           
 void setZoomLevel(int zoomLevel)
           
 java.lang.String toString()
           
protected  void updateBuiltinVariables()
           
 
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_ZOOM

public static final java.lang.String PROPERTY_ZOOM
See Also:
Constant Field Values

PAGE_NUMBER

public static final java.lang.String PAGE_NUMBER
A property that defines which page is currently being printed.

See Also:
Constant Field Values

varContext

public Layout.LayoutVarContext varContext

page

protected Page page
The page size and margin info.

TODO: In future versions, a Layout can have many pages so you can accomplish left and right masters, cover pages, and so on. For now, a Layout can only have one arrangement of page content, and this is it.

Constructor Detail

Layout

public Layout(java.lang.String uuid)

Layout

public Layout(Page page)

Layout

public Layout(java.lang.String uuid,
              Page page)
Method Detail

getVarContext

public Layout.LayoutVarContext getVarContext()

updateBuiltinVariables

protected void updateBuiltinVariables()

getPage

public Page getPage()

setPage

public void setPage(Page page)

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)

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.

Specified by:
childPositionOffset in interface WabitObject

getChildren

public java.util.List<Page> getChildren()
Description copied from interface: WabitObject
Returns an unmodifiable list of the children in this WabitObject. If there are no children in this WabitObject an empty list should be returned.

Specified by:
getChildren in interface WabitObject

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.

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.

Specified by:
allowsChildren in interface WabitObject
See Also:
WabitObject.childPositionOffset(Class)

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Prints a page of this report to the given graphics context. Before printing the currentlyPrinting flag should be set.

Specified by:
print in interface java.awt.print.Printable
Parameters:
pageIndex - the zero-based page number to print
Throws:
java.awt.print.PrinterException

getNumberOfPages

public int getNumberOfPages()
Before getting the page count the currentlyPrinting flag should be set.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Specified by:
getPageFormat in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
                                      throws java.lang.IndexOutOfBoundsException
Specified by:
getPrintable in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

setZoomLevel

public void setZoomLevel(int zoomLevel)

getZoomLevel

public int getZoomLevel()

compareAndSetCurrentlyPrinting

public boolean compareAndSetCurrentlyPrinting(boolean expected,
                                              boolean updateValue)

isCurrentlyPrinting

public boolean isCurrentlyPrinting()

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.

Specified by:
getDependencies in interface WabitObject

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.

Specified by:
removeDependency in interface WabitObject

toString

public java.lang.String toString()
Overrides:
toString in class AbstractWabitObject


Copyright © 2009. All Rights Reserved.