ca.sqlpower.wabit.report.resultset
Class ReportPositionRenderer

java.lang.Object
  extended by ca.sqlpower.wabit.report.resultset.ReportPositionRenderer

public class ReportPositionRenderer
extends java.lang.Object

This class renders the result set. A new renderer should be created each time a new layout is required.


Field Summary
static int BORDER_LINE_SIZE
          This is extra padding added on to cells where extra space is desired for border/separator lines.
 
Constructor Summary
ReportPositionRenderer(java.awt.Font headerFont, java.awt.Font bodyFont, ResultSetRenderer.BorderStyles borderType, int availableWidth, java.lang.String nullString)
           
 
Method Summary
 java.util.List<java.util.List<ResultSetCell>> createResultSetLayout(java.awt.Graphics2D g, java.sql.ResultSet rs, java.util.List<ColumnInfo> columnInfoList, ContentBox contentBox, boolean isPrintingGrandTotals)
          This method does all of the layout of each section of a result set.
 java.awt.Insets getPadding(ColumnInfo ci)
          This method will return the insets of each cell based on the border type being used.
 java.util.List<ResultSetCell> renderColumnHeader(java.awt.Graphics2D g, java.util.List<ColumnInfo> colInfo, int yPosition)
          Creates new ResultSetCells for each column header.
 java.util.List<ResultSetCell> renderRow(java.awt.Graphics2D g, java.sql.ResultSet rs, java.util.List<ColumnInfo> columnInformation, int yPosition, boolean showGroupsAsRepeat)
          This renders the current row of the result set given based on the graphics and the column information.
 ResultSetCell renderSectionHeader(java.awt.Graphics2D g, java.util.List<java.lang.Object> sectionHeader, java.util.List<ColumnInfo> colInfo, int yPosition)
          This renders each section header above the column headers.
 java.util.List<ResultSetCell> renderTotals(java.awt.Graphics2D g, java.util.List<java.math.BigDecimal> totalsRow, java.util.List<ColumnInfo> colInfo, boolean isGrandTotal, java.lang.String breakText, int breakTextPosition, int yPosition)
          This method will render the totals of a section.
 java.lang.String replaceNull(java.lang.String string)
          This will replace null values with the designated null string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BORDER_LINE_SIZE

public static final int BORDER_LINE_SIZE
This is extra padding added on to cells where extra space is desired for border/separator lines.

See Also:
Constant Field Values
Constructor Detail

ReportPositionRenderer

public ReportPositionRenderer(java.awt.Font headerFont,
                              java.awt.Font bodyFont,
                              ResultSetRenderer.BorderStyles borderType,
                              int availableWidth,
                              java.lang.String nullString)
Method Detail

createResultSetLayout

public java.util.List<java.util.List<ResultSetCell>> createResultSetLayout(java.awt.Graphics2D g,
                                                                           java.sql.ResultSet rs,
                                                                           java.util.List<ColumnInfo> columnInfoList,
                                                                           ContentBox contentBox,
                                                                           boolean isPrintingGrandTotals)
                                                                    throws java.sql.SQLException
This method does all of the layout of each section of a result set. This should be executed any time a part of the result set renderer changes. If all of the properties that defines a layout are set this method will return immediately. This includes but is not limited to: font changes, break changes, new columns being sub-totaled, different graphics in use such as printing vs painting, and changes to the query.

Parameters:
g - This should be a graphics object that is the same as the graphics the result set will be rendered into. If this graphics object is different the components may be laid out in a way that will have text clipped by the bounding ContentBox.
rs - This result set will be iterated over to lay out the result set. If the result set pointer should not be changed a copy of the result set, using a CachedRowSet or calling createShared on a CachedRowSet should be passed instead. The result set should also be sorted by the columns defined as breaks to avoid sections that are identified by the same section.
Throws:
java.sql.SQLException

renderRow

public java.util.List<ResultSetCell> renderRow(java.awt.Graphics2D g,
                                               java.sql.ResultSet rs,
                                               java.util.List<ColumnInfo> columnInformation,
                                               int yPosition,
                                               boolean showGroupsAsRepeat)
                                        throws java.sql.SQLException
This renders the current row of the result set given based on the graphics and the column information. This method will not modify the cursor position in the result set.

Parameters:
g - The graphics to use to determine dimension information.
rs - The result set whose current row will be used to create ResultSetCells. The cursor will not be modified in this result set. The row the cursor is at will be the row rendered.
columnInformation - This defines properties of the columns in the result set. This will define formatting, spacing, alignment, and other values specific to each column.
showGroupsAsRepeat - If true cells that would be blank as they are repeated values will appear but marked as a continued value.
Throws:
java.sql.SQLException

renderSectionHeader

public ResultSetCell renderSectionHeader(java.awt.Graphics2D g,
                                         java.util.List<java.lang.Object> sectionHeader,
                                         java.util.List<ColumnInfo> colInfo,
                                         int yPosition)
This renders each section header above the column headers.

Parameters:
g - Used to define dimension information when defining sizes of the ResultSetCell.
sectionHeader - These objects define a unique section. Each column in the result set should have an entry in this list. If the column is not part of the section header the value should be null. Otherwise the value should be a unique entry in the result set and will be displayed in the header.
colInfo - The column information describing the columns of the result set.

renderColumnHeader

public java.util.List<ResultSetCell> renderColumnHeader(java.awt.Graphics2D g,
                                                        java.util.List<ColumnInfo> colInfo,
                                                        int yPosition)
Creates new ResultSetCells for each column header.


renderTotals

public java.util.List<ResultSetCell> renderTotals(java.awt.Graphics2D g,
                                                  java.util.List<java.math.BigDecimal> totalsRow,
                                                  java.util.List<ColumnInfo> colInfo,
                                                  boolean isGrandTotal,
                                                  java.lang.String breakText,
                                                  int breakTextPosition,
                                                  int yPosition)
This method will render the totals of a section. The section can either be tracking totals for a subtotal or totals for a grand total.

Parameters:
g - Used to define size dimensions of the ResultSetCell.
totalsRow - A list of totals for each column. If the column has no totals the entry in the list should be null.
colInfo - A list of column information for each column in the result set.

replaceNull

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


getPadding

public java.awt.Insets getPadding(ColumnInfo ci)
This method will return the insets of each cell based on the border type being used.



Copyright © 2009. All Rights Reserved.