com.davisor.graphics.chart
Class AbstractTableRenderer

java.lang.Object
  extended bycom.davisor.graphics.chart.AbstractTableRenderer
All Implemented Interfaces:
com.davisor.core.MIMETypes, com.davisor.core.Public, TableRenderer
Direct Known Subclasses:
CSSTableRenderer

public abstract class AbstractTableRenderer
extends java.lang.Object
implements com.davisor.core.MIMETypes, TableRenderer

AbstractTableRenderer provides a base class for all TableFactory table renderers. This base class provides the basic table iteration and information extraction functionality, while sub-classes implement expected content type spesific rendering functions.

Table layout

Table renderer arranges input data into a table where data X -axis (the "category" axis) runs vertically, and Y -axis (the "value" axis) runs horizontally. Data labels, if present, run vertically on the left or right side of data. Data channel names, if present, run horizontally above or below the data. X -axis title, if present, lies above or below the labels, and Y -axis title, if present, lies above or below data channel names.
 .-------------------------------------.
 |(empty)|           Y-Title           |
 |-------|-----------------------------|
 |X-Title|Channel Name|...|Channel Name|
 |-------|------------|---|------------|
 | Label | Data Value |...| Data Value |
 |-------|------------|---|------------|
 |   :   |     :      | : |     :      |
 |-------|------------|---|------------|
 | Label | Data Value |...| Data Value |
 '-------------------------------------'
 
Sub-channels, if any, appear as recursive columns inside their parent parent channel columns.

Render attributes

Table rendering is capable of giving limited support for chart visual rendering attributes. In particular, the following axis attributes are supported:

X -axis attributes controls appearance of data labels that are rendered in the leftmost or rightmost table column. Y -axis attributes control the appearance of data values, rendered in remaining columns

Markup rendering

AbstracTableRenderer leaves the details of table output markup rendering for sub-classes which are expected to override the table event interface this class defines with appropriate markup generator implementations. In particular, this class generates the following table events:

Since:
JDK1.4
See Also:
ChartAttributes, ChartData, TableFactory

Field Summary
 
Fields inherited from interface com.davisor.core.MIMETypes
FILETYPE_BMP, FILETYPE_CSS, FILETYPE_DOC, FILETYPE_ECMA, FILETYPE_GIF, FILETYPE_HTML, FILETYPE_HTML_CSS, FILETYPE_INDEX, FILETYPE_INDEX_DOC, FILETYPE_INDEX_HTML, FILETYPE_INDEX_HTML_CSS, FILETYPE_INDEX_PDF, FILETYPE_INDEX_PPT, FILETYPE_INDEX_SVG, FILETYPE_INDEX_XHTML, FILETYPE_INDEX_XLS, FILETYPE_INDEX_XMSE, FILETYPE_INDEX_XMSP, FILETYPE_INDEX_XMSW, FILETYPE_INDEX_XSLFO, FILETYPE_JPEG, FILETYPE_PDF, FILETYPE_PNG, FILETYPE_PNG_WBMP, FILETYPE_PPM, FILETYPE_PPT, FILETYPE_SVG, FILETYPE_TEXT, FILETYPE_WBMP, FILETYPE_XHTML, FILETYPE_XLS, FILETYPE_XML, FILETYPE_XMSE, FILETYPE_XMSP, FILETYPE_XMSW, FILETYPE_XSLFO, FILETYPE_XSLFO_CSS, MIME_BMP, MIME_CSS, MIME_DOC, MIME_ECMA, MIME_GIF, MIME_HTML, MIME_HTML_CSS, MIME_INDEX, MIME_INDEX_DOC, MIME_INDEX_HTML, MIME_INDEX_HTML_CSS, MIME_INDEX_PDF, MIME_INDEX_PPT, MIME_INDEX_SVG, MIME_INDEX_XHTML, MIME_INDEX_XLS, MIME_INDEX_XMSE, MIME_INDEX_XMSP, MIME_INDEX_XMSW, MIME_INDEX_XSLFO, MIME_JPEG, MIME_OTHER, MIME_PDF, MIME_PNG, MIME_PNG_WBMP, MIME_PPM, MIME_PPT, MIME_SVG, MIME_TEXT, MIME_WBMP, MIME_XHTML, MIME_XLS, MIME_XML, MIME_XMSE, MIME_XMSP, MIME_XMSW, MIME_XSLFO, MIME_XSLFO_CSS
 
Constructor Summary
AbstractTableRenderer()
          Creates a new table factory.
 
Method Summary
protected abstract  java.lang.String characters(java.lang.String characters)
           
protected abstract  java.lang.String column(int number, java.lang.Number totalWidth, float relativeWidth, java.lang.Number resolution)
           
protected  void emitCell(java.lang.StringBuffer buffer, DataValue value, ChannelAttributes channelAttributes, PlotRenderAttributes valueRender, java.lang.Number axisGap, java.awt.Paint catAxisGridColor, java.awt.Stroke catAxisGridStroke, java.awt.Paint valAxisGridColor, java.awt.Stroke valAxisGridStroke, boolean top, boolean left)
          Recursively emits data value cells.
protected  int emitColumn(java.lang.StringBuffer buffer, Type type, ChannelAttributes channelAttributes, int columnIndex, java.lang.Number totalWidth, float relativeWidth, java.lang.Number resolution)
          Recursively emits data column declarations.
protected  int emitHeader(int depth, java.lang.StringBuffer buffer, Type type, ChannelAttributes channelAttributes, java.awt.Paint color, java.awt.Paint paint, java.awt.Font font, int alignment, java.lang.Number axisGap, java.awt.Paint axisLineColor, java.awt.Stroke axisLineStroke, java.awt.Paint axisGridColor, java.awt.Stroke axisGridStroke, boolean top, boolean left)
          Emits data column header component.
protected abstract  java.lang.String endBody()
           
protected abstract  java.lang.String endDataCell()
           
protected abstract  java.lang.String endHeaderCell()
           
protected abstract  java.lang.String endRow()
           
protected abstract  java.lang.String endTable()
           
 Chart renderTableChart(ChartAttributes attr, ChartData data, Chart chart)
          Renders a table chart from given chart attributes and data.
protected abstract  java.lang.String startBody()
           
protected abstract  java.lang.String startDataCell(java.awt.Paint color, java.awt.Paint paint, java.awt.Font font, int alignment, java.lang.Number gap, java.awt.Paint line1Color, java.awt.Stroke line1Stroke, boolean line1Horizontal, boolean line1BottomOrRight, java.awt.Paint line2Color, java.awt.Stroke line2Stroke, boolean line2Horizontal, boolean line2BottomOrRight)
           
protected abstract  java.lang.String startHeaderCell(int colSpan, int rowSpan, java.awt.Paint color, java.awt.Paint paint, java.awt.Font font, int alignment, java.lang.Number gap, java.awt.Paint line1Color, java.awt.Stroke line1Stroke, boolean line1Horizontal, boolean line1BottomOrRight, java.awt.Paint line2Color, java.awt.Stroke line2Stroke, boolean line2Horizontal, boolean line2BottomOrRight)
          Starts a new header cell tag.
protected abstract  java.lang.String startRow()
           
protected abstract  java.lang.String startTable(java.awt.Paint color, java.awt.Paint paint, java.awt.Stroke stroke)
          Starts a new table tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTableRenderer

public AbstractTableRenderer()
Creates a new table factory.

Method Detail

characters

protected abstract java.lang.String characters(java.lang.String characters)

column

protected abstract java.lang.String column(int number,
                                           java.lang.Number totalWidth,
                                           float relativeWidth,
                                           java.lang.Number resolution)

endBody

protected abstract java.lang.String endBody()

endDataCell

protected abstract java.lang.String endDataCell()

endHeaderCell

protected abstract java.lang.String endHeaderCell()

endRow

protected abstract java.lang.String endRow()

endTable

protected abstract java.lang.String endTable()

startBody

protected abstract java.lang.String startBody()

startDataCell

protected abstract java.lang.String startDataCell(java.awt.Paint color,
                                                  java.awt.Paint paint,
                                                  java.awt.Font font,
                                                  int alignment,
                                                  java.lang.Number gap,
                                                  java.awt.Paint line1Color,
                                                  java.awt.Stroke line1Stroke,
                                                  boolean line1Horizontal,
                                                  boolean line1BottomOrRight,
                                                  java.awt.Paint line2Color,
                                                  java.awt.Stroke line2Stroke,
                                                  boolean line2Horizontal,
                                                  boolean line2BottomOrRight)

startHeaderCell

protected abstract java.lang.String startHeaderCell(int colSpan,
                                                    int rowSpan,
                                                    java.awt.Paint color,
                                                    java.awt.Paint paint,
                                                    java.awt.Font font,
                                                    int alignment,
                                                    java.lang.Number gap,
                                                    java.awt.Paint line1Color,
                                                    java.awt.Stroke line1Stroke,
                                                    boolean line1Horizontal,
                                                    boolean line1BottomOrRight,
                                                    java.awt.Paint line2Color,
                                                    java.awt.Stroke line2Stroke,
                                                    boolean line2Horizontal,
                                                    boolean line2BottomOrRight)
Starts a new header cell tag. The cell has a number of attributes that affect cell content appearance, and zero to two colored edge lines (out of four).

Parameters:
colSpan - the number of columns the header cell spans
rowSpan - the number of rows the header cell spans
color - foreground paint
paint - background paint
font - text font
alignment - text alignment (as defined by RenderAttributes)
gap - cell padding (percentages)
line1Color - first cell edge color
line1Stroke - first cell edge stroke
line1Horizontal - is first cell edge horizontal or vertical
line1BottomOrRight - is first cell edge bottom or right edge
line2Color - second cell edge color
line2Stroke - second cell edge stroke
line2Horizontal - is second cell edge horizontal or vertical
line2BottomOrRight - is first cell edge bottom or right edge

startRow

protected abstract java.lang.String startRow()

startTable

protected abstract java.lang.String startTable(java.awt.Paint color,
                                               java.awt.Paint paint,
                                               java.awt.Stroke stroke)
Starts a new table tag. The table cell has a number of attributes that affect table border and background.

Parameters:
color - table borderline paint (may be null)
paint - table background paint (may be null)
stroke - table borderline style (may be null)

emitCell

protected void emitCell(java.lang.StringBuffer buffer,
                        DataValue value,
                        ChannelAttributes channelAttributes,
                        PlotRenderAttributes valueRender,
                        java.lang.Number axisGap,
                        java.awt.Paint catAxisGridColor,
                        java.awt.Stroke catAxisGridStroke,
                        java.awt.Paint valAxisGridColor,
                        java.awt.Stroke valAxisGridStroke,
                        boolean top,
                        boolean left)
Recursively emits data value cells. In particular, if the data value contains sub-values, sub-sub-values, and so on, each of them is emitted now.

Parameters:
buffer - string buffer to emit the column declarations to
value - data cell value (may be TupleData)
channelAttributes - data column attributes
valueRender - data cell value render attributes
axisGap - data cell padding
catAxisGridColor - category axis horizontal grid line color
catAxisGridStroke - category axis horizontal grid line style
valAxisGridColor - value axis vertical grid line color
valAxisGridStroke - value axis vertical grid line style
top - draw horizontal cell border at top or bottom cell edge
left - draw vertical cell border at left or right cell edge
See Also:
startDataCell(java.awt.Paint, java.awt.Paint, java.awt.Font, int, java.lang.Number, java.awt.Paint, java.awt.Stroke, boolean, boolean, java.awt.Paint, java.awt.Stroke, boolean, boolean)

emitColumn

protected int emitColumn(java.lang.StringBuffer buffer,
                         Type type,
                         ChannelAttributes channelAttributes,
                         int columnIndex,
                         java.lang.Number totalWidth,
                         float relativeWidth,
                         java.lang.Number resolution)
Recursively emits data column declarations. In particular, if the data column contains sub-columns, sub-sub-columns, and so on, each of them is emitted now.

Parameters:
buffer - string buffer to emit the column declarations to
type - data column type (may be TupleType)
channelAttributes - data column attributes
columnIndex - data column index in table (starting from zero)
totalWidth - total table width, in millimeters (may be null)
relativeWidth - column relative width, on range [0,1]
resolution - pixels-per-millimeter resolution (may be null)
Returns:
the number of columns emitted
See Also:
column(int, java.lang.Number, float, java.lang.Number)

emitHeader

protected int emitHeader(int depth,
                         java.lang.StringBuffer buffer,
                         Type type,
                         ChannelAttributes channelAttributes,
                         java.awt.Paint color,
                         java.awt.Paint paint,
                         java.awt.Font font,
                         int alignment,
                         java.lang.Number axisGap,
                         java.awt.Paint axisLineColor,
                         java.awt.Stroke axisLineStroke,
                         java.awt.Paint axisGridColor,
                         java.awt.Stroke axisGridStroke,
                         boolean top,
                         boolean left)
Emits data column header component. In particular, if the data column contains sub-columns, sub-sub-columns, and so on, only those header components on particular recursion depth level are emitted now.

Parameters:
depth - recursion depth to emit
buffer - string buffer to emit the column declarations to
type - data column type (may be TupleType)
channelAttributes - data column attributes
color - header cell text color
paint - header cell background paint
font - header cell text font
alignment - header cell text alignment
axisGap - data cell padding
axisLineColor - horizontal axis line color
axisLineStroke - horizontal axis ine style
axisGridColor - vertical grid line color
axisGridStroke - vertical grid line style
top - draw horizontal cell border at top or bottom cell edge
left - draw vertical cell border at left or right cell edge
Returns:
the number of columns emitted
See Also:
column(int, java.lang.Number, float, java.lang.Number)

renderTableChart

public Chart renderTableChart(ChartAttributes attr,
                              ChartData data,
                              Chart chart)
                       throws InvalidDataException
Renders a table chart from given chart attributes and data.

Specified by:
renderTableChart in interface TableRenderer
Parameters:
attr - chart attributes
data - chart data
chart - chart to store the result into (may be null)
Returns:
resulting chart
Throws:
InvalidDataException - if data is invalid for chart rendering


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.