Compiere 3.1

org.compiere.print.layout
Class TableElement

java.lang.Object
  extended by org.compiere.print.layout.PrintElement
      extended by org.compiere.print.layout.TableElement
All Implemented Interfaces:
ImageObserver

public class TableElement
extends PrintElement

Table Print Element. Maintains a logical cross page table, which is "broken up" when printing

  The table is 3 pages wide, 2 pages high
                +-----+-----+-----+
      | 1.1 | 1.2 | 1.3 |
                +-----+-----+-----+
      | 2.1 | 2.2 | 2.3 |
                +-----+-----+-----+
  Printed
                +-----+-----+-----+
      |  1  |  2  |  3  |
                +-----+-----+-----+
      |  4  |  5  |  6  |
                +-----+-----+-----+
  

Version:
$Id: TableElement.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $
Author:
Jorg Janke

Field Summary
static int ALL
          Header Row Indicator
static int HEADER_ROW
          Header Row Indicator
 
Fields inherited from class org.compiere.print.layout.PrintElement
LINK_COLOR, log, p_FieldAlignmentType, p_height, p_info, p_maxHeight, p_maxWidth, p_pageLocation, p_sizeCalculated, p_width
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableElement(ValueNamePair[] columnHeader, int[] columnMaxWidth, int[] columnMaxHeight, String[] columnJustification, boolean[] fixedWidth, ArrayList<Integer> functionRows, boolean multiLineHeader, Object[][] data, KeyNamePair[] pk, String pkColumnName, int pageNoStart, Rectangle firstPage, Rectangle nextPages, int repeatedColumns, HashMap<Integer,Integer> additionalLines, HashMap<Point,Font> rowColFont, HashMap<Point,Color> rowColColor, HashMap<Point,Color> rowColBackground, MPrintTableFormat tFormat, ArrayList<Integer> pageBreak)
          Constructor.
 
Method Summary
protected  boolean calculateSize()
          Layout and Calculate Size.
 Rectangle getBounds(int pageNo)
          Get relative Bounds of Element.
 Query getDrillAcross(Point relativePoint, int pageNo)
          Get Drill Across value
 Query getDrillDown(Point relativePoint, int pageNo)
          Get Drill Down value
 float getHeight(int pageNo)
          Get Calculated Height on page
 int getPageCount()
          Get number of "real" pages.
protected  int getPageIndex(int pageNo)
          Get zero based Page Index within Layout
protected  int getPageNo(int pageIndex)
          Get "real" page Number within Layout
protected  int getPageXCount()
          Get X - Page Count
protected  int getPageXIndex(int pageIndex)
          Get X - Page Index.
protected  int getPageYCount()
          Get Y | Page Count
protected  int getPageYIndex(int pageIndex)
          Get Y | Page Index.
 float getWidth(int pageNo)
          Get Calculated Height on page
 void paint(Graphics2D g2D, int pageNo, Point2D pageStart, Ctx ctx, boolean isView)
          Paint/Print.
 void setHeightToLastPage()
          For Multi-Page Tables, set Height to Height of last Page
 
Methods inherited from class org.compiere.print.layout.PrintElement
getAbsoluteLocation, getBounds, getHeight, getLocation, getWidth, imageUpdate, isTranslated, layout, setLocation, setMaxHeight, setMaxWidth, toString, translate, waitForLoad
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_ROW

public static final int HEADER_ROW
Header Row Indicator

See Also:
Constant Field Values

ALL

public static final int ALL
Header Row Indicator

See Also:
Constant Field Values
Constructor Detail

TableElement

public TableElement(ValueNamePair[] columnHeader,
                    int[] columnMaxWidth,
                    int[] columnMaxHeight,
                    String[] columnJustification,
                    boolean[] fixedWidth,
                    ArrayList<Integer> functionRows,
                    boolean multiLineHeader,
                    Object[][] data,
                    KeyNamePair[] pk,
                    String pkColumnName,
                    int pageNoStart,
                    Rectangle firstPage,
                    Rectangle nextPages,
                    int repeatedColumns,
                    HashMap<Integer,Integer> additionalLines,
                    HashMap<Point,Font> rowColFont,
                    HashMap<Point,Color> rowColColor,
                    HashMap<Point,Color> rowColBackground,
                    MPrintTableFormat tFormat,
                    ArrayList<Integer> pageBreak)
Constructor. Created in LayoutEngine. The rowCol.. maps are organized as follows - Point (row,col) row - data if 0..m - if -1 for the entire column column - data if 0..n - if -1 for the entire row i.e. Point (-1, -1) is the default for the table

Parameters:
columnHeader - array with column headers (Key=ColumnName)
columnMaxWidth - array with column max width - 0=no restrictions - negative=supress if null
columnMaxHeight - array with row max height for a column - 0=no restrictions; -1=one row only
columnJustification - field justification for column
fixedWidth - array with column fixed width
functionRows - list of function rows
multiLineHeader - if true, the header is not truncated at maxWidth
data - 2D array with data to be printed [row][col]
pk - array of primary keys
pkColumnName - primary key name
pageNoStart - page number of starting page
firstPage - bounds on first page
nextPages - bounds on following pages
repeatedColumns - repeat first x columns on - X Axis follow pages
additionalLines - map of old colum to below printed column
rowColFont - HashMap with Point as key with Font overwrite
rowColColor - HashMap with Point as key with foreground Color overwrite
rowColBackground - HashMap with Point as key with background Color overwrite
tFormat - table format
pageBreak - Arraylist of rows with page break
Method Detail

calculateSize

protected boolean calculateSize()
Layout and Calculate Size. Set p_width & p_height

Specified by:
calculateSize in class PrintElement
Returns:
true if calculated

setHeightToLastPage

public void setHeightToLastPage()
For Multi-Page Tables, set Height to Height of last Page


getHeight

public float getHeight(int pageNo)
Get Calculated Height on page

Overrides:
getHeight in class PrintElement
Parameters:
pageNo - layout page number
Returns:
Height

getWidth

public float getWidth(int pageNo)
Get Calculated Height on page

Parameters:
pageNo - page number
Returns:
Height

getPageCount

public int getPageCount()
Get number of "real" pages.

Overrides:
getPageCount in class PrintElement
Returns:
page count

getPageIndex

protected int getPageIndex(int pageNo)
Get zero based Page Index within Layout

Parameters:
pageNo - real page no
Returns:
page index

getPageNo

protected int getPageNo(int pageIndex)
Get "real" page Number within Layout

Parameters:
pageIndex - zero based page index
Returns:
page number

getPageXIndex

protected int getPageXIndex(int pageIndex)
Get X - Page Index. Zero Based; Page No is the "real" page No
  The table is 3 pages wide, 2 pages high - index
                +-----+-----+-----+
      | 0.0 | 0.1 | 0.2 |
                +-----+-----+-----+
      | 1.0 | 1.1 | 1.2 |
                +-----+-----+-----+
  Page Index
                +-----+-----+-----+
      |  0  |  1  |  2  |
                +-----+-----+-----+
      |  3  |  4  |  5  |
                +-----+-----+-----+
  

Parameters:
pageIndex - zero based page index
Returns:
page index on X axis

getPageXCount

protected int getPageXCount()
Get X - Page Count

Returns:
X page count

getPageYIndex

protected int getPageYIndex(int pageIndex)
Get Y | Page Index. Zero Based; Page No is the "real" page No
  The table is 3 pages wide, 2 pages high - index
                +-----+-----+-----+
      | 0.0 | 0.1 | 0.2 |
                +-----+-----+-----+
      | 1.0 | 1.1 | 1.2 |
                +-----+-----+-----+
  Page Index
                +-----+-----+-----+
      |  0  |  1  |  2  |
                +-----+-----+-----+
      |  3  |  4  |  5  |
                +-----+-----+-----+
  

Parameters:
pageIndex - zero based page index
Returns:
page index on Y axis

getPageYCount

protected int getPageYCount()
Get Y | Page Count

Returns:
Y page count

getDrillDown

public Query getDrillDown(Point relativePoint,
                          int pageNo)
Get Drill Down value

Overrides:
getDrillDown in class PrintElement
Parameters:
relativePoint - relative Point
pageNo - page number
Returns:
if found Qyery or null

getDrillAcross

public Query getDrillAcross(Point relativePoint,
                            int pageNo)
Get Drill Across value

Overrides:
getDrillAcross in class PrintElement
Parameters:
relativePoint - relative Point
pageNo - page number
Returns:
if found Query or null

getBounds

public Rectangle getBounds(int pageNo)
Get relative Bounds of Element. (entire page, not just used portion)

Parameters:
pageNo - pageNo
Returns:
bounds relative position on page

paint

public void paint(Graphics2D g2D,
                  int pageNo,
                  Point2D pageStart,
                  Ctx ctx,
                  boolean isView)
Paint/Print.

Specified by:
paint in class PrintElement
Parameters:
g2D - Graphics
pageNo - page number for multi page support (0 = header/footer)
pageStart - top left Location of page
ctx - context
isView - true if online view (IDs are links)

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.