Package com.reportmill.base
Class RMDocument
java.lang.Object
com.reportmill.base.RMObject
com.reportmill.shape.RMShape
com.reportmill.base.RMDocument
- All Implemented Interfaces:
RMArchiver.Archiving
,Cloneable
- Direct Known Subclasses:
RBDocument
The RMDocument class represents a ReportMill document and is also an RMShape subclass, so it can be a real part of
the document/shape hierarchy. RMDocuments are also what ReportMill refers to as templates, and is commonly used like
this:
RMDocument template = RMDocument.getDoc(aSource); // Load from path String, File, byte array, etc. RMDocument report = template.generateReport(aDataset); // Any Java dataset: EJBs, custom classes, collctns, etc. report.writePDF("MyReport.pdf");
On rare occasions, you may also want to create a document dynamically. Here's an example:
RMDocument doc = new RMDocument(612, 792); // Standard US Letter size (8.5" x 11"), in points RMTable table = new RMTable(); // Create new table ... doc.getPage(0).addChild(table); // ... and add to first page table.setBounds(36, 36, 540, 680); // Position and size table table.getRow("Objects Details").getColumn(0).setText("Title: @getTitle@"); // Configure first text
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An interface to define objects that want to get document notifications. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Locale
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final String[]
static final byte
static final byte
static final byte
static final byte
static final byte
Fields inherited from class com.reportmill.shape.RMShape
WRAP_TYPE_BOTH, WRAP_TYPE_NONE
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a plain empty document.RMDocument
(float aWidth, float aHeight) Creates a document with the given width and height (in printer points).RMDocument
(Object aSource) Creates a new document from the given source (throws error if source was invalid). -
Method Summary
Modifier and TypeMethodDescriptionboolean
Editor method indicates that document accepts children (should probably be false).void
Adds a given page to this document (at end).void
Adds a given page to this document (at the given index).void
Add the page reference shapes from given document to this document.void
addPages
(RMDocument aDoc) Add the pages in the given document to this document (at end) and clears the pages list in the given document.void
Add the given list of pages to this document (at end).void
boundsChanged
(RMShape aShape) Notifies this shape that a given shape's bounds have changed (presumably a descendant).boolean
Editor method indicates that pages super select immediately.clone()
Copies basic document attributes (shallow copy only - no children or pages).Copies the complete document, including document pages and all their children.void
Copies the attributes of the given object.boolean
Standard equals implementation.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.generateReport
(Object objects) Returns a generated report from this template evaluated against the given object.generateReport
(Object objects, boolean paginate) Returns a generated report from this template evaluated against the given object with an option to paginate.generateReport
(Object objects, Object userInfo) Returns a generated report from this template evaluated against the given object and userInfo.generateReport
(Object objects, Object userInfo, boolean paginate) Returns generated report from this template evaluated against given object/userInfo (with option to paginate).getAnimator
(int anIndex) Returns the animator for a specific page.Returns the animator for the last page.byte[]
getBytes()
Returns the document as an XML byte array.byte[]
Returns the document as a byte array of a CSV file.byte[]
getBytesDelimitedAscii
(String fieldDelimiter, String recordDelimiter, boolean quoteFields) Returns the document as a byte array of a delimited ASCII file (using given field, record separator strings).byte[]
Returns the document as a byte array of a Flash file.byte[]
Returns the document as a byte array of an HTML file.byte[]
Returns the document as byte array of a JPEG file.byte[]
Returns the document as a byte array of a PDF file.byte[]
Returns the document as byte array of PNG file.boolean
Returns whether the document should calibrate colors in generated file formats like PDF.boolean
Returns whether the document should compress images in generated file formats like PDF.Returns the RMDataSource associated with this document.Returns the schema for the RMDataSource associated with this document (convenience).static RMDocument
Creates a new document from aSource (returns null if source is invalid).static RMDocument
getDocForPDF
(Object aSource) Creates a new document from a PDF source.Returns the DocListener associated with this document.Returns the document itself (over-ridden from RMShape).Returns the filename associated with this document, if available.float
Returns the grid spacing for the document's grid.boolean
getLoops()
Returns whether the last animator loops.getMapHTML
(String anImageRoot) Returns the document as a Map of an HTML file and image resources.float
Returns the margin rects bottom value.float
Returns the margin rects left value.Returns the margin rect for this document.float
Returns the margin rects right value.float
Returns the margin rects top value.float
Returns the total time needed to animate this document (total of all page animators).Returns the string used to replace any occurrances of null values in a generated report.getPage
(int index) Returns the page at the given index.int
Returns the number of pages in this document.Returns the last page (convenience).byte
Returns the page layout for the document.getPages()
Returns the list of RMPages associated with this document.Returns the size of a document page.Returns whether the document should paginate generated reports by default.float
getPointsFromUnits
(float aValue) Converts given value from document units to printer points (1/72 of an inch).Returns the URL this document should be uploaded to.Returns the currently selected page of this document.int
Returns the current page index of this document.boolean
Returns whether the document should show an alignment grid.boolean
Returns whether the document should show a margin rect.boolean
Returns whether the document should snap to an alignment grid.boolean
Returns whether the document should snap to a margin rect.Returns the document as a string of a CSV file.getStringDelimitedText
(String fieldDelimiter, String recordDelimiter, boolean quoteFields) Returns the document as a string of a delimited text file.Returns the RMUndoer for this document.int
getUnit()
Returns the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS).float
getUnitsFromPoints
(float aValue) Converts given value to document units from printer points (1/72 of an inch).float
Returns the multiplier used to convert printer points to document units.Returns the units used to express sizes in the current document as one of the strings: point, inch or cm.float
Returns the version this document was loaded as.initWithArchiver
(RMArchiver anArchiver) Legacy unarchival.byte[]
pdfBytes()
Obsolete method for old pdfBytes() method.void
rebuild()
Rebuilds the document according to the selected page and page layout.void
removePage
(int anIndex) Removes the page at the given index from this document.void
Performs page substitions on any text fields that were identified as containing @Page@ keys.rpgClone
(ReportMill aReportMill) Report Generation method.void
setCalibrateColors
(boolean aValue) Sets whether the document should calibrate colors in generated file formats like PDF.void
setCompress
(boolean aValue) Sets whether the document should compress images in generated file formats like PDF.void
setDataSource
(RMDataSource aDataSource) Sets the RMDataSource associated with this document.void
setDocListener
(RMDocument.DocListener aListener) Sets the DocListener associated with this document.void
setFilename
(String aPath) Sets the filename associated with this document.void
setGridSpacing
(float aValue) Sets the grid spacing for the document's grid.void
setMarginRect
(RMRect aRect) Sets the margin rect for this document.void
setMargins
(float left, float right, float top, float bottom) Sets the margin rect for this document.void
setNeedsRepaint
(RMShape aShape) This is a notification call for impending visual shape attribute changes.void
setNullString
(String aValue) Sets the string used to replace any occurrances of null values in a generated report.void
setPageLayout
(byte aValue) Sets the page layout for the document.void
Sets the list of RMPages associated with this document.void
setPageSize
(float aWidth, float aHeight) Sets the size of the document (and all of its pages).void
setPaginate
(Boolean aValue) Sets whether the document should paginate generated reports by default.void
setPublishUrl
(String aValue) Sets the URL this document should be uploaded to.void
setSelectedPage
(RMPage aPage) Selects the given page.void
setSelectedPageIndex
(int anIndex) Selects the currently selected page by index.void
setShowGrid
(boolean aValue) Sets whether the document should show an alignment grid.void
setShowMargin
(boolean aValue) Sets whether the document should show a margin rect.void
setSnapGrid
(boolean aValue) Sets whether the document should snap to an alignment grid.void
setSnapMargin
(boolean aValue) Sets whether the document should snap to a margin rect.void
Sets the RMUndoer for this document.void
setUnit
(byte aValue) Sets the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS).void
setUnitString
(String aValue) Sets the units used to express sizes in the current document with one of the strings: point, inch or cm.boolean
Editor method indicates that document is super selectable.toXML
(RXArchiver anArchiver) XML archival.Returns a copy of the document for undo (page list is copied shallow).void
undoerAddDirtyObject
(RMObject anObj) Overrides RMShape implementation to actually add dirty object to notify doc listner and actually add to undoer.void
willChange
(RMShape aShape) This is a notification call-back for impeding shape attribute changes.void
Writes the document out to the given path String (it extracts type from path extension).void
Writes the document to the given path String as a CSV file.void
writeDelimitedAscii
(String fname, String fieldDelimiter, String recordDelimiter, boolean quoteFields) Writes the document to the given path String as a delimited ASCII file.void
writeFlash
(String fname) Writes the document to the given path String as Flash.void
writeFlashHTML
(String fname) Writes the document to the given path String as Flash/HTML.Writes the document to the given path String as HTML.Writes the document to the given path String as HTML (referenced images are written at the given relative path).void
Writes the document to the given path String as a JPEG file.void
Writes the document to the given path String as PDF.Methods inherited from class com.reportmill.shape.RMShape
acceptsDragKeys, acceptsFormat, acceptsMouse, addChild, addChild, addChildBelowLastChild, bounds, boundsChanged, bringShapesToFront, canBeUngrouped, contains, convertedPointFromShape, convertedPointToShape, convertedRectFromShape, convertedRectToShape, convertedSizeFromShape, convertedSizeToShape, convertedVectorFromShape, convertedVectorToShape, convertFromShape, convertPathFromShape, convertPathToShape, convertPointFromShape, convertPointToShape, convertRectFromShape, convertRectToShape, convertSizeFromShape, convertSizeToShape, convertToShape, convertVectorFromShape, convertVectorToShape, copyShape, delete, didChange, divideShapeFromEdge, divideShapeFromTop, dragExit, dragKeyAtPoint, dropKeyAtPoint, fromXMLDeep, get, getActionScript, getAnim, getAnim, getAnimator, getAnimator, getAutosizeHeight, getAutosizing, getBounds, getBoundsInside, getBoundsMarked, getBoundsOfChildren, getBoundsOfChildren, getBoundsSuperSelected, getCausesWrap, getCausesWrapType, getChild, getChildAnimator, getChildAnimator, getChildContaining, getChildCount, getChildLast, getChildren, getChildrenIntersecting, getChildrenWhoCauseWrap, getChildrenWhoDraw, getChildrenWhoHitTest, getChildSortedByX, getChildWithClass, getChildWithName, getColor, getCommonAncestor, getFill, getFill, getFill, getFillCount, getFills, getFont, getFormat, getFrame, getFrame, getFrameMaxX, getFrameMaxY, getFrameX, getFrameXY, getFrameY, getGroupShape, getHeight, getHeightToFit, getImageFill, getLineWidth, getListKey, getListKeyDeep, getListKeyShape, getMaxX, getMaxY, getName, getOpacity, getOpacityDeep, getOutline, getPageShape, getParent, getParentCount, getParents, getPath, getPathInBounds, getPropertyKey, getPropertyKeyCount, getPropertyKeyName, getRoll, getRootShape, getScaleX, getScaleY, getShapesToAncestor, getShapesToDescendant, getShapesToShape, getSize, getSizeP, getSkewX, getSkewY, getStroke, getStrokeColor, getTextColor, getToolClassName, getTransform, getTransformFromShape, getTransformInverse, getTransformToShape, getUrl, getWidth, getWidthToFit, getX, getXY, getXYP, getY, groupShapes, hasPageBreaks, height, indexOf, indexOf, intersects, isAncestor, isDescendant, isLocked, isRoot, isUnderlined, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, notRSS, offsetChildrenXY, offsetXY, page, pageBreakMax, pageBreakPageMax, pageMax, put, putPropertyKey, reclaimChildren, removeChild, removeChild, removeChildren, removeChildren, removeFromParent, resolvePageReferences, rpgCloneBase, rpgCloneChildren, rpgCloneConclude, rpgCloneNotification, rpgClonePrepare, rpgClonePreprocess, rpgCloneUrl, sendShapesToBack, setActionScript, setAnim, setAutosizeHeight, setAutosizing, setBounds, setBounds, setCausesWrapType, setChildren, setColor, setFill, setFont, setFormat, setFrame, setFrame, setFrameSize, setFrameX, setFrameXY, setFrameXY, setFrameY, setHeight, setHeightDeep, setHeightDeep, setHeightToFit, setLineWidth, setListKey, setLocked, setName, setNeedsRepaint, setOpacity, setOutline, setParent, setRoll, setScaleX, setScaleXY, setScaleY, setSize, setSize, setSizeDeep, setSizeP, setSizeToFit, setSizeToFit, setSkewX, setSkewXY, setSkewY, setStroke, setStrokeColor, setTextColor, setTime, setUnderlined, setUrl, setWidth, setWidthDeep, setWidthDeep, setWidthToFit, setX, setXY, setXY, setXYP, setY, sizesToFitChildren, toString, undoCopy, undoEquals, undoerDisable, undoerEnable, undoerSetUndoTitle, width, willChange, x, y
Methods inherited from class com.reportmill.base.RMObject
didUndo, getAnimAttribute, getClassNameShort
-
Field Details
-
PAGE_LAYOUT_SINGLE
public static final byte PAGE_LAYOUT_SINGLE- See Also:
-
PAGE_LAYOUT_DOUBLE
public static final byte PAGE_LAYOUT_DOUBLE- See Also:
-
PAGE_LAYOUT_QUADRUPLE
public static final byte PAGE_LAYOUT_QUADRUPLE- See Also:
-
PAGE_LAYOUT_FACING
public static final byte PAGE_LAYOUT_FACING- See Also:
-
PAGE_LAYOUT_CONTINUOUS
public static final byte PAGE_LAYOUT_CONTINUOUS- See Also:
-
PAGE_LAYOUT_CONTINUOUS_DOUBLE
public static final byte PAGE_LAYOUT_CONTINUOUS_DOUBLE- See Also:
-
UNIT_INCHES
public static final byte UNIT_INCHES- See Also:
-
UNIT_POINTS
public static final byte UNIT_POINTS- See Also:
-
UNIT_CM
public static final byte UNIT_CM- See Also:
-
UNIT_MM
public static final byte UNIT_MM- See Also:
-
UNIT_PICA
public static final byte UNIT_PICA- See Also:
-
SUPPORTED_UNITS
-
_locale
-
-
Constructor Details
-
RMDocument
public RMDocument()Creates a plain empty document. It's really only used by the archiver. -
RMDocument
public RMDocument(float aWidth, float aHeight) Creates a document with the given width and height (in printer points). -
RMDocument
Creates a new document from the given source (throws error if source was invalid).
-
-
Method Details
-
getDoc
Creates a new document from aSource (returns null if source is invalid). -
getDocForPDF
Creates a new document from a PDF source. -
getFilename
Returns the filename associated with this document, if available. -
setFilename
Sets the filename associated with this document. -
getVersion
public float getVersion()Returns the version this document was loaded as. -
getPageCount
public int getPageCount()Returns the number of pages in this document.- Overrides:
getPageCount
in classRMShape
-
getPage
Returns the page at the given index. -
getPageLast
Returns the last page (convenience). -
getPages
Returns the list of RMPages associated with this document. -
setPages
Sets the list of RMPages associated with this document. -
addPage
Adds a given page to this document (at end). -
addPage
Adds a given page to this document (at the given index). -
removePage
public void removePage(int anIndex) Removes the page at the given index from this document. -
addPages
Add the given list of pages to this document (at end). -
addPages
Add the pages in the given document to this document (at end) and clears the pages list in the given document. -
addPageReferenceShapes
Add the page reference shapes from given document to this document. -
getSelectedPageIndex
public int getSelectedPageIndex()Returns the current page index of this document. -
setSelectedPageIndex
public void setSelectedPageIndex(int anIndex) Selects the currently selected page by index. -
getSelectedPage
Returns the currently selected page of this document. -
setSelectedPage
Selects the given page. -
getPageLayout
public byte getPageLayout()Returns the page layout for the document. -
setPageLayout
public void setPageLayout(byte aValue) Sets the page layout for the document. -
getDataSource
Returns the RMDataSource associated with this document. -
setDataSource
Sets the RMDataSource associated with this document. -
getDataSourceSchema
Returns the schema for the RMDataSource associated with this document (convenience). -
getUnit
public int getUnit()Returns the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS). -
setUnit
public void setUnit(byte aValue) Sets the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS). -
getUnitString
Returns the units used to express sizes in the current document as one of the strings: point, inch or cm. -
setUnitString
Sets the units used to express sizes in the current document with one of the strings: point, inch or cm. -
getPointsFromUnits
public float getPointsFromUnits(float aValue) Converts given value from document units to printer points (1/72 of an inch). -
getUnitsFromPoints
public float getUnitsFromPoints(float aValue) Converts given value to document units from printer points (1/72 of an inch). -
getUnitsMultiplier
public float getUnitsMultiplier()Returns the multiplier used to convert printer points to document units. -
getShowGrid
public boolean getShowGrid()Returns whether the document should show an alignment grid. -
setShowGrid
public void setShowGrid(boolean aValue) Sets whether the document should show an alignment grid. -
getSnapGrid
public boolean getSnapGrid()Returns whether the document should snap to an alignment grid. -
setSnapGrid
public void setSnapGrid(boolean aValue) Sets whether the document should snap to an alignment grid. -
getShowMargin
public boolean getShowMargin()Returns whether the document should show a margin rect. -
setShowMargin
public void setShowMargin(boolean aValue) Sets whether the document should show a margin rect. -
getSnapMargin
public boolean getSnapMargin()Returns whether the document should snap to a margin rect. -
setSnapMargin
public void setSnapMargin(boolean aValue) Sets whether the document should snap to a margin rect. -
getMarginRect
Returns the margin rect for this document. -
setMarginRect
Sets the margin rect for this document. -
setMargins
public void setMargins(float left, float right, float top, float bottom) Sets the margin rect for this document. -
getMarginLeft
public float getMarginLeft()Returns the margin rects left value. -
getMarginRight
public float getMarginRight()Returns the margin rects right value. -
getMarginTop
public float getMarginTop()Returns the margin rects top value. -
getMarginBottom
public float getMarginBottom()Returns the margin rects bottom value. -
getGridSpacing
public float getGridSpacing()Returns the grid spacing for the document's grid. -
setGridSpacing
public void setGridSpacing(float aValue) Sets the grid spacing for the document's grid. -
getPublishUrl
Returns the URL this document should be uploaded to. -
setPublishUrl
Sets the URL this document should be uploaded to. -
getNullString
Returns the string used to replace any occurrances of null values in a generated report. -
setNullString
Sets the string used to replace any occurrances of null values in a generated report. -
getPaginate
Returns whether the document should paginate generated reports by default. -
setPaginate
Sets whether the document should paginate generated reports by default. -
getCompress
public boolean getCompress()Returns whether the document should compress images in generated file formats like PDF. -
setCompress
public void setCompress(boolean aValue) Sets whether the document should compress images in generated file formats like PDF. -
getCalibrateColors
public boolean getCalibrateColors()Returns whether the document should calibrate colors in generated file formats like PDF. -
setCalibrateColors
public void setCalibrateColors(boolean aValue) Sets whether the document should calibrate colors in generated file formats like PDF. -
getDocListener
Returns the DocListener associated with this document. -
setDocListener
Sets the DocListener associated with this document. -
generateReport
Returns a generated report from this template evaluated against the given object. -
generateReport
Returns a generated report from this template evaluated against the given object and userInfo. -
generateReport
Returns a generated report from this template evaluated against the given object with an option to paginate. -
generateReport
Returns generated report from this template evaluated against given object/userInfo (with option to paginate). -
getBytes
public byte[] getBytes()Returns the document as an XML byte array. -
getBytesPDF
public byte[] getBytesPDF()Returns the document as a byte array of a PDF file. -
getBytesHTML
public byte[] getBytesHTML()Returns the document as a byte array of an HTML file. -
getBytesFlash
public byte[] getBytesFlash()Returns the document as a byte array of a Flash file. -
getBytesCSV
public byte[] getBytesCSV()Returns the document as a byte array of a CSV file. -
getBytesDelimitedAscii
public byte[] getBytesDelimitedAscii(String fieldDelimiter, String recordDelimiter, boolean quoteFields) Returns the document as a byte array of a delimited ASCII file (using given field, record separator strings). -
getBytesJPEG
public byte[] getBytesJPEG()Returns the document as byte array of a JPEG file. -
getBytesPNG
public byte[] getBytesPNG()Returns the document as byte array of PNG file. -
getMapHTML
Returns the document as a Map of an HTML file and image resources. -
getStringCSV
Returns the document as a string of a CSV file. -
getStringDelimitedText
public String getStringDelimitedText(String fieldDelimiter, String recordDelimiter, boolean quoteFields) Returns the document as a string of a delimited text file. -
write
Writes the document out to the given path String (it extracts type from path extension). -
writePDF
Writes the document to the given path String as PDF. -
writeHTML
Writes the document to the given path String as HTML. -
writeHTML
Writes the document to the given path String as HTML (referenced images are written at the given relative path). -
writeFlash
Writes the document to the given path String as Flash. -
writeFlashHTML
Writes the document to the given path String as Flash/HTML. -
writeCSV
Writes the document to the given path String as a CSV file. -
writeDelimitedAscii
public void writeDelimitedAscii(String fname, String fieldDelimiter, String recordDelimiter, boolean quoteFields) Writes the document to the given path String as a delimited ASCII file. -
writeJPG
Writes the document to the given path String as a JPEG file. -
rebuild
public void rebuild()Rebuilds the document according to the selected page and page layout. -
getPageSize
Returns the size of a document page. -
setPageSize
public void setPageSize(float aWidth, float aHeight) Sets the size of the document (and all of its pages). -
getMaxTime
public float getMaxTime()Returns the total time needed to animate this document (total of all page animators). -
getDocument
Returns the document itself (over-ridden from RMShape).- Overrides:
getDocument
in classRMShape
-
getAnimator
Returns the animator for a specific page. -
getAnimatorLast
Returns the animator for the last page. -
getLoops
public boolean getLoops()Returns whether the last animator loops. -
getUndoer
Returns the RMUndoer for this document. -
setUndoer
Sets the RMUndoer for this document. -
undoerAddDirtyObject
Overrides RMShape implementation to actually add dirty object to notify doc listner and actually add to undoer.- Overrides:
undoerAddDirtyObject
in classRMShape
-
willChange
This is a notification call-back for impeding shape attribute changes.- Overrides:
willChange
in classRMShape
-
setNeedsRepaint
This is a notification call for impending visual shape attribute changes.- Overrides:
setNeedsRepaint
in classRMShape
-
boundsChanged
Notifies this shape that a given shape's bounds have changed (presumably a descendant).- Overrides:
boundsChanged
in classRMShape
-
resolvePageReferences
public void resolvePageReferences()Performs page substitions on any text fields that were identified as containing @Page@ keys. -
equals
Standard equals implementation. -
clone
Copies basic document attributes (shallow copy only - no children or pages). -
cloneDeep
Copies the complete document, including document pages and all their children. -
undoClone
Returns a copy of the document for undo (page list is copied shallow). -
copy
Copies the attributes of the given object. -
toXML
XML archival. -
fromXML
XML unarchival. -
initWithArchiver
Legacy unarchival.- Specified by:
initWithArchiver
in interfaceRMArchiver.Archiving
- Overrides:
initWithArchiver
in classRMShape
-
rpgClone
Report Generation method. -
superSelectable
public boolean superSelectable()Editor method indicates that document is super selectable.- Overrides:
superSelectable
in classRMShape
-
childrenSuperSelectImmediately
public boolean childrenSuperSelectImmediately()Editor method indicates that pages super select immediately.- Overrides:
childrenSuperSelectImmediately
in classRMShape
-
acceptsChildren
public boolean acceptsChildren()Editor method indicates that document accepts children (should probably be false).- Overrides:
acceptsChildren
in classRMShape
-
pdfBytes
public byte[] pdfBytes()Obsolete method for old pdfBytes() method.
-