Adempiere 3.5.2a

org.compiere.print.layout
Class LayoutEngine

java.lang.Object
  extended by org.compiere.print.layout.LayoutEngine
All Implemented Interfaces:
Pageable, Printable, Doc

public class LayoutEngine
extends Object
implements Pageable, Printable, Doc

Adempiere Print Engine. All coordinates are relative to the Page. The Language setting is maintained in the format

Version:
$Id: LayoutEngine.java,v 1.3 2006/07/30 00:53:02 jjanke Exp $
Author:
Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL
  • BF [ 1673505 ] BarCode/Image problem when print format is not form
  • BF [ 1673542 ] Can't add static image in report table cell
  • BF [ 1673548 ] Image is not scaled in a report table cell
  • BF [ 1807917 ] Layout positioning issue with m_maxHeightSinceNewLine
  • BF [ 1825876 ] Layout boxes with auto width not working
  • FR [ 1966406 ] Report Engine: AD_PInstance_Logs should be displayed

  • Field Summary
    static int AREA_CONTENT
              Content Area
    static int AREA_FOOTER
              Footer Area
    static int AREA_HEADER
              Header Area
    static Image IMAGE_FALSE
              False Image
    static Dimension IMAGE_SIZE
              Image Size
    static Image IMAGE_TRUE
              True Image
    static boolean s_FASTDRAW
              Draw using attributed String vs.
     
    Fields inherited from interface java.awt.print.Pageable
    UNKNOWN_NUMBER_OF_PAGES
     
    Fields inherited from interface java.awt.print.Printable
    NO_SUCH_PAGE, PAGE_EXISTS
     
    Constructor Summary
    LayoutEngine(MPrintFormat format, PrintData data, MQuery query)
              Detail Constructor
    LayoutEngine(MPrintFormat format, PrintData data, MQuery query, String trxName)
              Detail Constructor
     
    Method Summary
    protected  void addX(float xOffset)
              Add to X Position on current page
    protected  void addY(int yOffset)
              Add to Y Position - may cause New Page
     int getArea()
              Get the current Print Area
     Rectangle getAreaBounds()
              Return bounds of current Area
     DocAttributeSet getAttributes()
              Get Document Attributes (Doc Interface)
     Color getColor()
              Get default Color
     int getColumnCount()
              Get the number of printed Columns
     Properties getCtx()
              Get PrintLayout (Report) Context
     DocFlavor getDocFlavor()
              Get the doc flavor (Doc Interface)
     MPrintFormat getFormat()
              Get Format Model
     HeaderFooter getHeaderFooter()
              Get Header & Footer info
     int getNumberOfPages()
              Get number of pages (Pageable Interface)
     Page getPage(int pageNo)
              Get Page No
     LayoutEngine getPageable(boolean isCopy)
              Get Print Interface (Pageable, Printable, Doc)
     PageFormat getPageFormat()
              Get Page Format
     PageFormat getPageFormat(int pageIndex)
              Get Page Format (Pageable Interface)
     String getPageInfo(int pageNo)
              Get Page Info for Multi-Page tables
     String getPageInfoMax()
              Get Max Page Info for Multi-Page tables
     int getPageNo()
              Get current Page Number (not zero based)
     ArrayList getPages()
              Get Pages
     CPaper getPaper()
              Set Paper
     Point2D getPosition()
              Get the current position on current page
     Printable getPrintable(int pageIndex)
              Get Printable (PageableInterface)
     Object getPrintData()
              Get Print Data (Doc Interface)
     Reader getReaderForText()
              Obtains a reader for extracting character print data from this doc.
     InputStream getStreamForBytes()
              Obtains an input stream for extracting byte print data from this doc.
     float getX()
              Get X Position on current page
     float getXspace()
              Return remaining X dimension space _ on current page in Area
     float getY()
              Get Y Position on current page
     float getYspace()
              Return remaining Y dimension space | on current page in Area
     boolean isCopy()
              Print Copy
     boolean isXspaceFor(float width)
              Remaining Space is OK for Width in Area
     boolean isYspaceFor(float height)
              Remaining Space is OK for Height in Area
    protected  void newLine()
              Move to New Line (may cause new page)
    protected  int newPage(boolean force, boolean preserveXPos)
              Create New Page, set position to top content
     void pageSetupDialog(PrinterJob job)
              Show Dialog and Set Paper Optionally re-calculate layout
     int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
              Print Page (Printable Interface)
    protected  void setArea(int area)
              Set the current Print Area
     void setCopy(boolean isCopy)
              Set Copy
    protected  void setPage(int pageNo)
              Set Current page to Page No
    protected  void setPageFormat(PageFormat pf)
              Set Paper from Page Format.
     void setPaper(CPaper paper)
              Set Paper
     void setPaper(CPaper paper, int headerHeight, int footerHeight)
              Set Paper Optionally re-calculate layout
     void setPrintData(PrintData data, MQuery query, boolean doLayout)
              Set PrintData.
     void setPrintData(PrintData data, MQuery query, boolean doLayout, String trxName)
               
     void setPrintFormat(MPrintFormat format, boolean doLayout)
              Set Print Format Optionally re-calculate layout
    protected  void setRelativePosition(float x, float y)
              Set Position on current page (no check)
    protected  void setRelativePosition(Point2D p)
              Set Position on current page (no check)
    protected  void setX(float x)
              Set X Position on current page
    protected  void setY(int y)
              Set Y Position on current page
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    AREA_HEADER

    public static final int AREA_HEADER
    Header Area

    See Also:
    Constant Field Values

    AREA_CONTENT

    public static final int AREA_CONTENT
    Content Area

    See Also:
    Constant Field Values

    AREA_FOOTER

    public static final int AREA_FOOTER
    Footer Area

    See Also:
    Constant Field Values

    s_FASTDRAW

    public static boolean s_FASTDRAW
    Draw using attributed String vs. Text Layout where possible


    IMAGE_TRUE

    public static Image IMAGE_TRUE
    True Image


    IMAGE_FALSE

    public static Image IMAGE_FALSE
    False Image


    IMAGE_SIZE

    public static Dimension IMAGE_SIZE
    Image Size

    Constructor Detail

    LayoutEngine

    public LayoutEngine(MPrintFormat format,
                        PrintData data,
                        MQuery query)
    Detail Constructor

    Parameters:
    format - Print Format
    data - Print Data
    query - query for parameter info

    LayoutEngine

    public LayoutEngine(MPrintFormat format,
                        PrintData data,
                        MQuery query,
                        String trxName)
    Detail Constructor

    Parameters:
    format - Print Format
    data - Print Data
    query - query for parameter info
    trxName -
    Method Detail

    setPrintFormat

    public void setPrintFormat(MPrintFormat format,
                               boolean doLayout)
    Set Print Format Optionally re-calculate layout

    Parameters:
    doLayout - if layout exists, redo it
    format - print Format

    setPrintData

    public void setPrintData(PrintData data,
                             MQuery query,
                             boolean doLayout)
    Set PrintData. Optionally re-calculate layout

    Parameters:
    data - data
    doLayout - if layout exists, redo it
    query - query for parameter

    setPrintData

    public void setPrintData(PrintData data,
                             MQuery query,
                             boolean doLayout,
                             String trxName)

    setPaper

    public void setPaper(CPaper paper)
    Set Paper

    Parameters:
    paper - Paper

    setPaper

    public void setPaper(CPaper paper,
                         int headerHeight,
                         int footerHeight)
    Set Paper Optionally re-calculate layout

    Parameters:
    paper - Paper
    headerHeight - header height
    footerHeight - footer height

    pageSetupDialog

    public void pageSetupDialog(PrinterJob job)
    Show Dialog and Set Paper Optionally re-calculate layout

    Parameters:
    job - printer job

    setPageFormat

    protected void setPageFormat(PageFormat pf)
    Set Paper from Page Format. PageFormat is derived from CPaper

    Parameters:
    pf - Optional PageFormat - if null standard paper Portrait

    getPageFormat

    public PageFormat getPageFormat()
    Get Page Format

    Returns:
    page format

    getPaper

    public CPaper getPaper()
    Set Paper

    Returns:
    Paper

    getCtx

    public Properties getCtx()
    Get PrintLayout (Report) Context

    Returns:
    context

    getColumnCount

    public int getColumnCount()
    Get the number of printed Columns

    Returns:
    no of printed columns

    setArea

    protected void setArea(int area)
    Set the current Print Area

    Parameters:
    area - see HEADER_.. constants

    getArea

    public int getArea()
    Get the current Print Area

    Returns:
    area see HEADER_.. constants

    getAreaBounds

    public Rectangle getAreaBounds()
    Return bounds of current Area

    Returns:
    rectangle with bounds

    newPage

    protected int newPage(boolean force,
                          boolean preserveXPos)
    Create New Page, set position to top content

    Parameters:
    force - if false will check if nothing printed so far
    preserveXPos - preserve X Position of content area
    Returns:
    new page no

    newLine

    protected void newLine()
    Move to New Line (may cause new page)


    getPageNo

    public int getPageNo()
    Get current Page Number (not zero based)

    Returns:
    Page No

    getPage

    public Page getPage(int pageNo)
    Get Page No

    Parameters:
    pageNo - page number (NOT zero based)
    Returns:
    Page

    getPages

    public ArrayList getPages()
    Get Pages

    Returns:
    Pages in ArrayList

    getHeaderFooter

    public HeaderFooter getHeaderFooter()
    Get Header & Footer info

    Returns:
    Header&Footer

    setPage

    protected void setPage(int pageNo)
    Set Current page to Page No

    Parameters:
    pageNo - page number (NOT zero based)

    getPageInfo

    public String getPageInfo(int pageNo)
    Get Page Info for Multi-Page tables

    Parameters:
    pageNo - page
    Returns:
    info e.g. (1,1)

    getPageInfoMax

    public String getPageInfoMax()
    Get Max Page Info for Multi-Page tables

    Returns:
    info e.g. (3,2)

    getFormat

    public MPrintFormat getFormat()
    Get Format Model

    Returns:
    model

    getPageable

    public LayoutEngine getPageable(boolean isCopy)
    Get Print Interface (Pageable, Printable, Doc)

    Parameters:
    isCopy - true if it is a document copy
    Returns:
    this if nothing to print

    setRelativePosition

    protected void setRelativePosition(Point2D p)
    Set Position on current page (no check)

    Parameters:
    p - point relative in area

    setRelativePosition

    protected void setRelativePosition(float x,
                                       float y)
    Set Position on current page (no check)

    Parameters:
    x - x position in 1/72 inch
    y - y position in 1/72 inch

    getPosition

    public Point2D getPosition()
    Get the current position on current page

    Returns:
    current position

    setX

    protected void setX(float x)
    Set X Position on current page

    Parameters:
    x - x position in 1/72 inch

    addX

    protected void addX(float xOffset)
    Add to X Position on current page

    Parameters:
    xOffset - add offset to x position in 1/72 inch

    getX

    public float getX()
    Get X Position on current page

    Returns:
    x position in 1/72 inch

    setY

    protected void setY(int y)
    Set Y Position on current page

    Parameters:
    y - y position in 1/72 inch

    addY

    protected void addY(int yOffset)
    Add to Y Position - may cause New Page

    Parameters:
    yOffset - add offset to y position in 1/72 inch

    getY

    public float getY()
    Get Y Position on current page

    Returns:
    y position in 1/72 inch

    getXspace

    public float getXspace()
    Return remaining X dimension space _ on current page in Area

    Returns:
    space in 1/72 inch remaining in line

    isXspaceFor

    public boolean isXspaceFor(float width)
    Remaining Space is OK for Width in Area

    Parameters:
    width - width
    Returns:
    true if width fits in area

    getYspace

    public float getYspace()
    Return remaining Y dimension space | on current page in Area

    Returns:
    space in 1/72 inch remaining on page

    isYspaceFor

    public boolean isYspaceFor(float height)
    Remaining Space is OK for Height in Area

    Parameters:
    height - height
    Returns:
    true if height fits in area

    getColor

    public Color getColor()
    Get default Color

    Returns:
    color

    getNumberOfPages

    public int getNumberOfPages()
    Get number of pages (Pageable Interface)

    Specified by:
    getNumberOfPages in interface Pageable
    Returns:
    number of pages

    getPageFormat

    public PageFormat getPageFormat(int pageIndex)
                             throws IndexOutOfBoundsException
    Get Page Format (Pageable Interface)

    Specified by:
    getPageFormat in interface Pageable
    Parameters:
    pageIndex - page index
    Returns:
    Page Format
    Throws:
    IndexOutOfBoundsException

    getPrintable

    public Printable getPrintable(int pageIndex)
                           throws IndexOutOfBoundsException
    Get Printable (PageableInterface)

    Specified by:
    getPrintable in interface Pageable
    Parameters:
    pageIndex - page index
    Returns:
    this
    Throws:
    IndexOutOfBoundsException

    print

    public int print(Graphics graphics,
                     PageFormat pageFormat,
                     int pageIndex)
              throws PrinterException
    Print Page (Printable Interface)

    Specified by:
    print in interface Printable
    Parameters:
    graphics - graphics
    pageFormat - page format (ignored)
    pageIndex - page index
    Returns:
    PageExists/NoSuchPage
    Throws:
    PrinterException

    isCopy

    public boolean isCopy()
    Print Copy

    Returns:
    true if copy

    setCopy

    public void setCopy(boolean isCopy)
    Set Copy

    Parameters:
    isCopy - if true document is a copy

    getDocFlavor

    public DocFlavor getDocFlavor()
    Get the doc flavor (Doc Interface)

    Specified by:
    getDocFlavor in interface Doc
    Returns:
    SERVICE_FORMATTED.PAGEABLE

    getPrintData

    public Object getPrintData()
                        throws IOException
    Get Print Data (Doc Interface)

    Specified by:
    getPrintData in interface Doc
    Returns:
    this
    Throws:
    IOException

    getAttributes

    public DocAttributeSet getAttributes()
    Get Document Attributes (Doc Interface)

    Specified by:
    getAttributes in interface Doc
    Returns:
    null to obtain all attribute values from the job's attribute set.

    getReaderForText

    public Reader getReaderForText()
                            throws IOException
    Obtains a reader for extracting character print data from this doc. (Doc Interface)

    Specified by:
    getReaderForText in interface Doc
    Returns:
    null
    Throws:
    IOException

    getStreamForBytes

    public InputStream getStreamForBytes()
                                  throws IOException
    Obtains an input stream for extracting byte print data from this doc. (Doc Interface)

    Specified by:
    getStreamForBytes in interface Doc
    Returns:
    null
    Throws:
    IOException

    Adempiere 3.5.2a

    Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.