Class BasicGridLookPainter
- java.lang.Object
-
- org.eclipse.nebula.paperclips.core.grid.BasicGridLookPainter
-
- All Implemented Interfaces:
GridLookPainter
- Direct Known Subclasses:
DefaultGridLookPainter
public abstract class BasicGridLookPainter extends java.lang.Object implements GridLookPainter
A abstract GridLookPainter which simplifies implementation of custom GridLooks.Subclasses must have the following methods implemented:
- getMargins() - these margins are referenced by GridPrint for determining proper layout of the cells, as well as by the paint() method.
- paintHeaderCell() - will be called by the paint() method for each header cell.
- paintBodyCell() - will be called by the paint() method for each body cell.
- paintFooterCell() - will be called by the paint() method for each footer cell.
- dispose() - must dispose any SWT resources created by the subclass.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.swt.graphics.Device
device
The printer device on which the look is being painted.
-
Constructor Summary
Constructors Constructor Description BasicGridLookPainter(org.eclipse.swt.graphics.Device device)
Constructs a BasicGridLook painter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
paint(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] headerRows, int[][] headerColSpans, int firstRowIndex, boolean topOpen, int[] bodyRows, int[][] bodyColSpans, boolean bottomOpen, int[] footerRows, int[][] footerColSpans)
Paints the grid look onto the GC.private int
paintBody(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans, int firstRowIndex, boolean topOpen, boolean bottomOpen)
protected abstract void
paintBodyCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan, boolean topOpen, boolean bottomOpen)
Paint the decorations for the described body cell.private void
paintBodyRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int[] colSpans, int rowIndex, boolean topOpen, boolean bottomOpen)
private void
paintFooter(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans)
protected abstract void
paintFooterCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan)
Paint the decorations for the described footer cell.private void
paintFooterRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int rowIndex, int[] colSpans)
private int
paintHeader(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans)
protected abstract void
paintHeaderCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan)
Paint the decorations for the described header cell.private void
paintHeaderRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int rowIndex, int[] colSpans)
private int
sum(int[] elements, int start, int length)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.paperclips.core.grid.GridLookPainter
dispose, getMargins
-
-
-
-
Constructor Detail
-
BasicGridLookPainter
public BasicGridLookPainter(org.eclipse.swt.graphics.Device device)
Constructs a BasicGridLook painter.- Parameters:
device
- the printer device (may not be null). This argument will be saved in the protecteddevice
field.
-
-
Method Detail
-
paint
public void paint(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] headerRows, int[][] headerColSpans, int firstRowIndex, boolean topOpen, int[] bodyRows, int[][] bodyColSpans, boolean bottomOpen, int[] footerRows, int[][] footerColSpans)
Description copied from interface:GridLookPainter
Paints the grid look onto the GC.- Specified by:
paint
in interfaceGridLookPainter
- Parameters:
gc
- the graphics context to paint on.x
- the x coordinate of the top-left of the grid.y
- the y coordinate of the top-left of the grid.columns
- the column widths. The left and right margins of each cell are included in the column widths.headerRows
- the header row heights.headerColSpans
- a two-dimensional array of cell spans in the header. Each element in the outer array is a header row. Each element of an inner array is a cell, where the element value indicates how many columns the cell spans.firstRowIndex
- the zero-based index of the first row displayed on the page.topOpen
- whether the top body row should be drawn with the top edge of the cell border "open." An open top border is a visual indication that the top row is being continued from the previous page.bodyRows
- the body row heights.bodyColSpans
- a two-dimensional array of cell spans in the body. Each element in the outer array is a body row. Each element of an inner array is a cell, where the element value indicates how many columns the cell spans.bottomOpen
- whether the bottom body row should be drawn with the bottom edge of the cell border "open." An open bottom border is a visual indication that the bottom row will be continued on the next page.footerRows
- the footer row heights.footerColSpans
- a two-dimensional array of cell spans in the footer. Each element in the outer array is a footer row. Each element of an inner array is a cell, where the element value indicates how many columns the cell spans.
-
paintHeader
private int paintHeader(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans)
-
paintBody
private int paintBody(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans, int firstRowIndex, boolean topOpen, boolean bottomOpen)
-
paintFooter
private void paintFooter(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int[] rows, int[][] colSpans)
-
paintHeaderRow
private void paintHeaderRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int rowIndex, int[] colSpans)
-
paintBodyRow
private void paintBodyRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int[] colSpans, int rowIndex, boolean topOpen, boolean bottomOpen)
-
paintFooterRow
private void paintFooterRow(org.eclipse.swt.graphics.GC gc, int x, int y, int[] columns, int h, int rowIndex, int[] colSpans)
-
sum
private int sum(int[] elements, int start, int length)
-
paintHeaderCell
protected abstract void paintHeaderCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan)
Paint the decorations for the described header cell.- Parameters:
gc
- the graphics context to use for painting.bounds
- the bounds of the cell, excluding margins.row
- the row offset of the cell within the header.col
- the column offset of the cell within the header.colspan
- the number of columns that this cell spans.
-
paintBodyCell
protected abstract void paintBodyCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan, boolean topOpen, boolean bottomOpen)
Paint the decorations for the described body cell.- Parameters:
gc
- the graphics context to use for painting.bounds
- the bounds of the cell, excluding margins.row
- the row offset of the cell within the header.col
- the column offset of the cell within the header.colspan
- the number of columns that this cell spans.topOpen
- whether the cell should be drawn with the top edge of the cell border "open." An open top border is a visual cue that the cell is being continued from the previous page.bottomOpen
- whether the cell should be drawn with the bottom edge of the cell border "open." An open bottom border is a visual cue that the cell will be continued on the next page.
-
paintFooterCell
protected abstract void paintFooterCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, int row, int col, int colspan)
Paint the decorations for the described footer cell.- Parameters:
gc
- the graphics context to use for painting.bounds
- the bounds of the cell, excluding margins.row
- the row offset of the cell within the header.col
- the column offset of the cell within the header.colspan
- the number of columns that this cell spans.
-
-