ca.sqlpower.wabit.report
Class ResultSetRenderer

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

public class ResultSetRenderer
extends AbstractWabitObject
implements WabitObjectReportRenderer

Renders a JDBC result set using configurable absolute column widths.


Nested Class Summary
static class ResultSetRenderer.BorderStyles
          These border styles gives a border to the result set.
 
Nested classes/interfaces inherited from interface ca.sqlpower.wabit.report.ReportContentRenderer
ReportContentRenderer.BackgroundColours
 
Field Summary
static int BORDER_INDENT
          This is the number of pixels each cell will be indented by if there is a border to the left of the cell.
protected static java.lang.String QUERY
          Notes a change to the query has occurred that would require a refresh to the renderer
 
Fields inherited from class ca.sqlpower.object.AbstractSPObject
uuid
 
Constructor Summary
ResultSetRenderer(QueryCache query)
           
ResultSetRenderer(QueryCache query, java.util.List<ColumnInfo> columnInfoList)
           
ResultSetRenderer(ResultSetRenderer resultSetRenderer)
          Copy constructor
 
Method Summary
protected  void addChildImpl(ca.sqlpower.object.SPObject child, int index)
           
 boolean allowsChildren()
           
 int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
           
 ca.sqlpower.object.CleanupExceptions cleanup()
          Default cleanup method that does nothing.
 void clearResultSetLayout()
          Call this method if something changes in the result set that causes the need to redefine the layout of the result set.
 boolean defineColumnBeingDragged(double mouseXPos)
          This method will look for a column edge that is near the given x location.
 java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()
           
 java.awt.Color getBackgroundColour()
           
 java.awt.Font getBodyFont()
           
 ResultSetRenderer.BorderStyles getBorderType()
           
 java.util.List<? extends WabitObject> getChildren()
           
 java.util.List<ColumnInfo> getColumnInfoList()
           
 QueryCache getContent()
          Returns the WabitObject that this is rendering
 java.util.List<WabitObject> getDependencies()
           
 java.awt.Font getHeaderFont()
           
 java.lang.String getNullString()
           
 ContentBox getParent()
          Returns the parent of this WabitObject.
 void initColumns(java.sql.ResultSet rs)
          Constructor subroutine.
 boolean isPrintingGrandTotals()
           
 boolean moveColumnBeingDragged(double moveDelta)
          This will move the edge of the column defined to be dragged by the delta.
 void refresh()
          Refreshes the data being rendered by this ReportContentRenderer so that it has the most recent data.
protected  boolean removeChildImpl(ca.sqlpower.object.SPObject child)
           
 void removeDependency(ca.sqlpower.object.SPObject dependency)
           
 boolean renderFailure(java.awt.Graphics2D g, ContentBox contentBox, double scaleFactor, int pageIndex)
           
 boolean renderReportContent(java.awt.Graphics2D g, ContentBox contentBox, double scaleFactor, int pageIndex, boolean printing)
          Renders as much report content as will fit within the bounds of the given content box.
 boolean renderSuccess(java.awt.Graphics2D g, ContentBox contentBox, double scaleFactor, int pageIndex, boolean printing)
           
 java.lang.String replaceNull(java.lang.String string)
          This will replace null values with the designated null string.
 void resetToFirstPage()
          Tells this content renderer that the next call to #renderReportContent(Graphics2D, ContentBox, double) should produce the first page of output again.
 void setBackgroundColour(java.awt.Color backgroundColour)
           
 void setBodyFont(java.awt.Font bodyFont)
           
 void setBorderType(ResultSetRenderer.BorderStyles borderType)
           
 void setColBeingDragged(ColumnInfo colBeingDragged)
           
 void setHeaderFont(java.awt.Font headerFont)
           
 void setNullString(java.lang.String nullString)
           
 void setParent(ca.sqlpower.object.SPObject parent)
           
 void setPrintingGrandTotals(boolean isPrintingGrandTotals)
           
 
Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject
commit, equals, generateNewUUID, 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, 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, commit, generateNewUUID, getChildren, getName, getSession, getUUID, removeChild, removeSPListener, rollback, setName, setUUID
 

Field Detail

BORDER_INDENT

public static final int BORDER_INDENT
This is the number of pixels each cell will be indented by if there is a border to the left of the cell. If no indent is given then the left part of the text will be overwritten by the border itself.

See Also:
Constant Field Values

QUERY

protected static final java.lang.String QUERY
Notes a change to the query has occurred that would require a refresh to the renderer

See Also:
Constant Field Values
Constructor Detail

ResultSetRenderer

public ResultSetRenderer(@Nonnull
                         QueryCache query)

ResultSetRenderer

public ResultSetRenderer(@Nonnull
                         QueryCache query,
                         @Nonnull
                         java.util.List<ColumnInfo> columnInfoList)

ResultSetRenderer

public ResultSetRenderer(ResultSetRenderer resultSetRenderer)
Copy constructor

Method Detail

getContent

public QueryCache getContent()
Description copied from interface: WabitObjectReportRenderer
Returns the WabitObject that this is rendering

Specified by:
getContent in interface WabitObjectReportRenderer

cleanup

public ca.sqlpower.object.CleanupExceptions cleanup()
Description copied from class: AbstractWabitObject
Default cleanup method that does nothing. Override and implement this method if cleanup is necessary.

Specified by:
cleanup in interface ca.sqlpower.object.SPObject
Overrides:
cleanup in class AbstractWabitObject

initColumns

public void initColumns(java.sql.ResultSet rs)
                 throws java.sql.SQLException
Constructor subroutine.

Parameters:
rs - The RS to map onto
Throws:
java.sql.SQLException - If the resultset metadata methods fail.

resetToFirstPage

public void resetToFirstPage()
Description copied from interface: ReportContentRenderer
Tells this content renderer that the next call to #renderReportContent(Graphics2D, ContentBox, double) should produce the first page of output again.

Specified by:
resetToFirstPage in interface ReportContentRenderer

renderReportContent

public boolean renderReportContent(java.awt.Graphics2D g,
                                   ContentBox contentBox,
                                   double scaleFactor,
                                   int pageIndex,
                                   boolean printing)
Description copied from interface: ReportContentRenderer
Renders as much report content as will fit within the bounds of the given content box.

Report content renderers can be implemented in two different ways:


renderFailure

public boolean renderFailure(java.awt.Graphics2D g,
                             ContentBox contentBox,
                             double scaleFactor,
                             int pageIndex)

renderSuccess

public boolean renderSuccess(java.awt.Graphics2D g,
                             ContentBox contentBox,
                             double scaleFactor,
                             int pageIndex,
                             boolean printing)

clearResultSetLayout

public void clearResultSetLayout()
Call this method if something changes in the result set that causes the need to redefine the layout of the result set.


replaceNull

public java.lang.String replaceNull(java.lang.String string)
This will replace null values with the designated null string.


allowsChildren

public boolean allowsChildren()
Specified by:
allowsChildren in interface ca.sqlpower.object.SPObject

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
Specified by:
childPositionOffset in interface ca.sqlpower.object.SPObject

getChildren

public java.util.List<? extends WabitObject> getChildren()
Specified by:
getChildren in interface ca.sqlpower.object.SPObject

getHeaderFont

public java.awt.Font getHeaderFont()

setHeaderFont

public void setHeaderFont(java.awt.Font headerFont)

getBodyFont

public java.awt.Font getBodyFont()

setBodyFont

public void setBodyFont(java.awt.Font bodyFont)

getNullString

public java.lang.String getNullString()

setNullString

public void setNullString(java.lang.String nullString)

getParent

public ContentBox getParent()
Description copied from interface: WabitObject
Returns the parent of this WabitObject. This will be null when the object is first created until it is added as a child to another object. If this object is never added as a child to another object this will remain null and the object may be treated as the root node of a WabitObject tree.

Specified by:
getParent in interface ca.sqlpower.object.SPObject
Specified by:
getParent in interface WabitObject
Overrides:
getParent in class AbstractWabitObject
Returns:
The parent of this object.

setBackgroundColour

public void setBackgroundColour(java.awt.Color backgroundColour)

getBackgroundColour

public java.awt.Color getBackgroundColour()
Specified by:
getBackgroundColour in interface ReportContentRenderer

getBorderType

public ResultSetRenderer.BorderStyles getBorderType()

setBorderType

public void setBorderType(ResultSetRenderer.BorderStyles borderType)

getColumnInfoList

public java.util.List<ColumnInfo> getColumnInfoList()

defineColumnBeingDragged

public boolean defineColumnBeingDragged(double mouseXPos)
This method will look for a column edge that is near the given x location. If the edge of a column is close to this value it will be defined as the column edge to be dragged. This is to support the operation of defining column widths by clicking and dragging.

Parameters:
mouseXPos - The distance from the left side of the parent content box to look for an edge of a column. This cannot be null.
Returns:
True if a column is now able to be dragged, false otherwise.

moveColumnBeingDragged

public boolean moveColumnBeingDragged(double moveDelta)
This will move the edge of the column defined to be dragged by the delta. To shrink the column give a negative value as the delta. If no column is being dragged this will do nothing.

Parameters:
moveDelta - The amount to resize the column width. Cannot be null.
Returns:
True if a column was resized. False otherwise.

getDependencies

public java.util.List<WabitObject> getDependencies()
Specified by:
getDependencies in interface ca.sqlpower.object.SPObject

removeDependency

public void removeDependency(ca.sqlpower.object.SPObject dependency)
Specified by:
removeDependency in interface ca.sqlpower.object.SPObject

setParent

public void setParent(ca.sqlpower.object.SPObject parent)
Specified by:
setParent in interface ca.sqlpower.object.SPObject
Overrides:
setParent in class ca.sqlpower.object.AbstractSPObject

setColBeingDragged

public void setColBeingDragged(ColumnInfo colBeingDragged)

setPrintingGrandTotals

public void setPrintingGrandTotals(boolean isPrintingGrandTotals)

isPrintingGrandTotals

public boolean isPrintingGrandTotals()

refresh

public void refresh()
Description copied from interface: ReportContentRenderer
Refreshes the data being rendered by this ReportContentRenderer so that it has the most recent data. If the data this renderer renders is static, then it doesn't need to do anything (no-op).

Specified by:
refresh in interface ReportContentRenderer

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.