Package org.compiere.print.layout
Class LayoutEngine
java.lang.Object
org.compiere.print.layout.LayoutEngine
Print Engine.
All coordinates are relative to the Page.
The Language setting is maintained in the format.
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
- BF [ 2487307 ] LayoutEngine: NPE when Barcode field is null
- BF [ 2828893 ] Problem with NextPage in Print Format https://sourceforge.net/p/adempiere/bugs/2001/, victor.perez@e-evolution.com, e-Evolution
- BF [ 2011567 ] Implement Background Image for Document printed
- https://sourceforge.net/p/adempiere/feature-requests/477/, Michael Judd (Akuna Ltd)
- BF [ 2695078 ] Country is not translated on invoice
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intContent Areastatic final intFooter Areastatic final intHeader AreaBoolean[]suppress repeat columnsstatic ImageFalse Imagestatic DimensionImage Sizestatic ImageTrue Imagestatic booleanDraw using attributed String vs.Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGESFields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS -
Constructor Summary
ConstructorsConstructorDescriptionLayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info) ConstructorLayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, int windowNo) Detail ConstructorLayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, String trxName) Detail ConstructorLayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, String trxName, int windowNo) Detail Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddX(float xOffset) Add to X Position on current pageprotected voidaddY(int yOffset) Add to Y Position - may cause New PageintgetArea()Get the current Print AreaGet bounds of current AreaGet Document Attributes (Doc Interface)Get child print format detailsgetColor()Get default Colorstatic Boolean[]getColSuppressRepeats(MPrintFormat format) Get suppress repeat columnsintGet the number of printed ColumnsgetCtx()Get PrintLayout (Report) ContextGet the doc flavor (Doc Interface)Get Print Format ModelGet Header and Footer infointGet number of pages (Pageable Interface)getPage(int pageNo) Get PagegetPageable(boolean isCopy) Get Print Interface (Pageable, Printable, Doc)Get Page FormatgetPageFormat(int pageIndex) Get Page Format (Pageable Interface)getPageInfo(int pageNo) Get Page Info for Multi-Page tablesGet Max Page Info for Multi-Page tablesintGet current Page Number (not zero based)getPages()Get PagesgetPaper()Set PaperGet current position on current pagegetPrintable(int pageIndex) Get Printable (PageableInterface)Get Print Data (Doc Interface)Obtains a reader for extracting character print data from this doc.Obtains an input stream for extracting byte print data from this doc.floatgetX()Get X Position on current pagefloatGet remaining X dimension space on current page in current AreafloatgetY()Get Y Position on current pagefloatGet remaining Y dimension space on current page in AreabooleanisCopy()Print CopybooleanisXspaceFor(float width) Is Remaining Space OK for Width in AreabooleanisYspaceFor(float height) Is Remaining Space OK for Height in Areaprotected voidnewLine()Move to New Line (may cause new page)protected intnewPage(boolean force, boolean preserveXPos) Create New Page, set position to top contentvoidShow Dialog and Set Paper.
Optionally re-calculate layout.intprint(Graphics graphics, PageFormat pageFormat, int pageIndex) Print Page (Printable Interface)protected voidsetArea(int area) Set the current Print AreavoidsetChildPrintFormatDetails(MPrintFormatItem printFormatItem, PrintData printData) Set child print format detailsvoidsetCopy(boolean isCopy) Set Copyprotected voidsetPage(int pageNo) Set Current page to Page Noprotected voidSet Paper from Page Format.
PageFormat is derived from CPaper.voidSet PapervoidSet Paper.
If layout exists and page size has change, re-calculate layout.voidsetPrintData(PrintData data, MQuery query, boolean doLayout) Set PrintData.
Optionally re-calculate layout.voidsetPrintData(PrintData data, MQuery query, boolean doLayout, String trxName) Set print data.
Optionally re-calculate layout.voidsetPrintFormat(MPrintFormat format, boolean doLayout) Set Print Format.
Optionally re-calculate layout.voidsetPrintInfo(PrintInfo info) protected voidsetRelativePosition(float x, float y) Set Position on current page (no check)protected voidSet Position on current page (no check)protected voidsetX(float x) Set X Position on current pageprotected voidsetY(int y) Set Y Position on current page
-
Field Details
-
AREA_HEADER
public static final int AREA_HEADERHeader Area- See Also:
-
AREA_CONTENT
public static final int AREA_CONTENTContent Area- See Also:
-
AREA_FOOTER
public static final int AREA_FOOTERFooter Area- See Also:
-
s_FASTDRAW
public static boolean s_FASTDRAWDraw using attributed String vs. Text Layout where possible -
IMAGE_TRUE
True Image -
IMAGE_FALSE
False Image -
IMAGE_SIZE
Image Size -
colSuppressRepeats
suppress repeat columns
-
-
Constructor Details
-
LayoutEngine
Constructor- Parameters:
format-data-query-info-
-
LayoutEngine
public LayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, int windowNo) Detail Constructor- Parameters:
format- Print Formatdata- Print Dataquery- query for parameter infoinfo-windowNo-
-
LayoutEngine
public LayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, String trxName) Detail Constructor- Parameters:
format-data-query-info-trxName-
-
LayoutEngine
public LayoutEngine(MPrintFormat format, PrintData data, MQuery query, PrintInfo info, String trxName, int windowNo) Detail Constructor- Parameters:
format- Print Formatdata- Print Dataquery- query for parameter infoinfo-trxName-windowNo-
-
-
Method Details
-
setPrintFormat
Set Print Format.
Optionally re-calculate layout.- Parameters:
format- print FormatdoLayout- if layout exists, redo it
-
setPrintData
Set PrintData.
Optionally re-calculate layout.- Parameters:
data- dataquery- query for parameterdoLayout- if layout exists, redo it
-
setPrintData
Set print data.
Optionally re-calculate layout.- Parameters:
data-query-doLayout- if layout exists, redo ittrxName-
-
setPaper
Set Paper- Parameters:
paper- Paper
-
setPaper
Set Paper.
If layout exists and page size has change, re-calculate layout.- Parameters:
paper- PaperheaderHeight- header heightfooterHeight- footer height
-
pageSetupDialog
Show Dialog and Set Paper.
Optionally re-calculate layout.- Parameters:
job- printer job
-
setPageFormat
Set Paper from Page Format.
PageFormat is derived from CPaper.- Parameters:
pf- Optional PageFormat. If null, use standard paper Portrait.
-
getPageFormat
Get Page Format- Returns:
- page format
-
getPaper
Set Paper- Returns:
- Paper
-
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
Get 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 farpreserveXPos- 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
Get Page- Parameters:
pageNo- page number (NOT zero based)- Returns:
- Page
-
getPages
Get Pages- Returns:
- Pages in ArrayList
-
setPage
protected void setPage(int pageNo) Set Current page to Page No- Parameters:
pageNo- page number (NOT zero based)
-
getPageInfo
Get Page Info for Multi-Page tables- Parameters:
pageNo- page- Returns:
- info e.g. (1,1)
-
getPageInfoMax
Get Max Page Info for Multi-Page tables- Returns:
- info e.g. (3,2)
-
getFormat
Get Print Format Model- Returns:
- model
-
getPageable
Get Print Interface (Pageable, Printable, Doc)- Parameters:
isCopy- true if it is a document copy- Returns:
- this or null if nothing to print
-
setRelativePosition
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 inchy- y position in 1/72 inch
-
getPosition
Get 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()Get remaining X dimension space on current page in current Area- Returns:
- space in 1/72 inch remaining in line
-
isXspaceFor
public boolean isXspaceFor(float width) Is Remaining Space OK for Width in Area- Parameters:
width- width- Returns:
- true if width fits in area
-
getYspace
public float getYspace()Get remaining Y dimension space on current page in Area- Returns:
- space in 1/72 inch remaining on page
-
isYspaceFor
public boolean isYspaceFor(float height) Is Remaining Space OK for Height in Area- Parameters:
height- height- Returns:
- true if height fits in area
-
getColor
Get default Color- Returns:
- color
-
getNumberOfPages
public int getNumberOfPages()Get number of pages (Pageable Interface)- Specified by:
getNumberOfPagesin interfacePageable- Returns:
- number of pages
-
getPageFormat
Get Page Format (Pageable Interface)- Specified by:
getPageFormatin interfacePageable- Parameters:
pageIndex- page index- Returns:
- Page Format
- Throws:
IndexOutOfBoundsException
-
getPrintable
Get Printable (PageableInterface)- Specified by:
getPrintablein interfacePageable- Parameters:
pageIndex- page index- Returns:
- this
- Throws:
IndexOutOfBoundsException
-
print
Print Page (Printable Interface)- Specified by:
printin interfacePrintable- Parameters:
graphics- graphicspageFormat- 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
Get the doc flavor (Doc Interface)- Specified by:
getDocFlavorin interfaceDoc- Returns:
- SERVICE_FORMATTED.PAGEABLE
-
getPrintData
Get Print Data (Doc Interface)- Specified by:
getPrintDatain interfaceDoc- Returns:
- this
- Throws:
IOException
-
getAttributes
Get Document Attributes (Doc Interface)- Specified by:
getAttributesin interfaceDoc- Returns:
- null to obtain all attribute values from the job's attribute set.
-
getReaderForText
Obtains a reader for extracting character print data from this doc. (Doc Interface)- Specified by:
getReaderForTextin interfaceDoc- Returns:
- null
- Throws:
IOException
-
getStreamForBytes
Obtains an input stream for extracting byte print data from this doc. (Doc Interface)- Specified by:
getStreamForBytesin interfaceDoc- Returns:
- null
- Throws:
IOException
-
setPrintInfo
- Parameters:
info- PrintInfo
-
getPrintInfo
- Returns:
- PrintInfo
-
setChildPrintFormatDetails
Set child print format details- Parameters:
printFormatItem- print format item that reference a child print formatprintData- print data of child print format
-
getChildPrintFormatDetails
Get child print format details- Returns:
- Print Format Item:Print Data of Child Print Format.
-
getColSuppressRepeats
Get suppress repeat columns- Parameters:
format-- Returns:
- columns (true - suppress repeat, false - not suppress repeat)
-