Package org.apache.fop.afp
Class DataStream
java.lang.Object
org.apache.fop.afp.DataStream
A data stream is a continuous ordered stream of data elements and objects
conforming to a given format. Application programs can generate data streams
destined for a presentation service, archive library, presentation device or
another application program. The strategic presentation data stream
architectures used is Mixed Object Document Content Architecture (MO:DCA).
The MO:DCA architecture defines the data stream used by applications to
describe documents and object envelopes for interchange with other
applications and application services. Documents defined in the MO:DCA format
may be archived in a database, then later retrieved, viewed, annotated and
printed in local or distributed systems environments. Presentation fidelity
is accommodated by including resource objects in the documents that reference
them.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.Log
Static logging instance -
Constructor Summary
ConstructorDescriptionDataStream
(Factory factory, AFPPaintingState paintingState, OutputStream outputStream) Default constructor for the AFPDocumentStream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFontsToCurrentPage
(Map pageFonts) Creates the given page fonts in the current pagevoid
createFont
(int fontReference, AFPFont font, int size) Helper method to create a map coded font object on the current page, this method delegates the construction of the map coded font object to the active environment group on the current page.void
createIncludePageOverlay
(String name, int x, int y) Helper method which allows creation of the MPO object, via the AEG.void
createIncludePageSegment
(String name, int x, int y, int width, int height) Creates an IncludePageSegment on the current page.void
createInvokeMediumMap
(String name) Helper method which allows creation of the IMM object.void
createLine
(AFPLineDataInfo lineDataInfo) Method to create a line on the current page.void
createNoOperation
(String content) Creates a NoOperation itemvoid
createPageGroupTagLogicalElement
(TagLogicalElement.State[] attributes) Creates a TagLogicalElement on the current page group.void
createPageTagLogicalElement
(TagLogicalElement.State[] attributes) Creates a TagLogicalElement on the current page.void
createShading
(int x, int y, int w, int h, Color col) This method will create shading on the page using the specified coordinates (the shading contrast is controlled via the red, green, blue parameters, by converting this to grey scale).void
createTagLogicalElement
(String name, String value, int encoding) Creates a TagLogicalElement on the current page or page groupvoid
createText
(AFPTextDataInfo textDataInfo, int letterSpacing, int wordSpacing, Font font, CharacterSet charSet) Helper method to create text on the current page, this method delegates to the current presentation text object in order to construct the text.void
Helper method to mark the end of the current document.void
Helper method to mark the end of the current overlay.void
endPage()
Helper method to mark the end of the current page.void
Helper method to mark the end of the page group.Returns the current pageReturns the current page groupReturns the MO:DCA interchange set in useReturns the outputstreamgetResourceGroup
(AFPResourceLevel level) Returns the resource group for a given resource infovoid
restorePage
(PageObject pageObject) Helper method to restore the current page.savePage()
Helper method to save the current page.void
setDocumentName
(String name) The document is started by invoking this method which creates an instance of the AFP Document object.void
setInterchangeSet
(InterchangeSet interchangeSet) Sets the MO:DCA interchange set to usevoid
Start a new document.void
startOverlay
(int x, int y, int width, int height, int widthRes, int heightRes, int overlayRotation) Start a new overlay.void
startPage
(int pageWidth, int pageHeight, int pageRotation, int pageWidthRes, int pageHeightRes) Start a new page.void
Start a new page group.
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOGStatic logging instance
-
-
Constructor Details
-
DataStream
Default constructor for the AFPDocumentStream.- Parameters:
factory
- the resource factorypaintingState
- the AFP painting stateoutputStream
- the outputstream to write to
-
-
Method Details
-
getOutputStream
Returns the outputstream- Returns:
- the outputstream
-
getCurrentPage
Returns the current page- Returns:
- the current page
-
setDocumentName
The document is started by invoking this method which creates an instance of the AFP Document object.- Parameters:
name
- the name of this document.
-
endDocument
Helper method to mark the end of the current document.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
startPage
public void startPage(int pageWidth, int pageHeight, int pageRotation, int pageWidthRes, int pageHeightRes) Start a new page. When processing has finished on the current page, theendPage()
method must be invoked to mark the page ending.- Parameters:
pageWidth
- the width of the pagepageHeight
- the height of the pagepageRotation
- the rotation of the pagepageWidthRes
- the width resolution of the pagepageHeightRes
- the height resolution of the page
-
startOverlay
public void startOverlay(int x, int y, int width, int height, int widthRes, int heightRes, int overlayRotation) Start a new overlay. When processing has finished on the current overlay, theendOverlay()
method must be invoked to mark the overlay ending.- Parameters:
x
- the x position of the overlay on the pagey
- the y position of the overlay on the pagewidth
- the width of the overlayheight
- the height of the overlaywidthRes
- the width resolution of the overlayheightRes
- the height resolution of the overlayoverlayRotation
- the rotation of the overlay
-
endOverlay
Helper method to mark the end of the current overlay.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
savePage
Helper method to save the current page.- Returns:
- current page object that was saved
-
restorePage
Helper method to restore the current page.- Parameters:
pageObject
- page object
-
endPage
Helper method to mark the end of the current page.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
addFontsToCurrentPage
Creates the given page fonts in the current page- Parameters:
pageFonts
- a collection of AFP font attributes
-
createFont
Helper method to create a map coded font object on the current page, this method delegates the construction of the map coded font object to the active environment group on the current page.- Parameters:
fontReference
- the font number used as the resource identifierfont
- the fontsize
- the point size of the font
-
createText
public void createText(AFPTextDataInfo textDataInfo, int letterSpacing, int wordSpacing, Font font, CharacterSet charSet) throws UnsupportedEncodingException Helper method to create text on the current page, this method delegates to the current presentation text object in order to construct the text.- Parameters:
textDataInfo
- the afp text dataletterSpacing
- letter spacing to draw text withwordSpacing
- word Spacing to draw text withfont
- is the font to draw text withcharSet
- is the AFP Character Set to use with the text- Throws:
UnsupportedEncodingException
- thrown if character encoding is not supported
-
createLine
Method to create a line on the current page.- Parameters:
lineDataInfo
- the line data information.
-
createShading
This method will create shading on the page using the specified coordinates (the shading contrast is controlled via the red, green, blue parameters, by converting this to grey scale).- Parameters:
x
- the x coordinate of the shadingy
- the y coordinate of the shadingw
- the width of the shaded areah
- the height of the shaded areacol
- the shading color
-
createIncludePageOverlay
Helper method which allows creation of the MPO object, via the AEG. And the IPO via the Page. (See actual object for descriptions.)- Parameters:
name
- the name of the static overlayx
- x-coordinatey
- y-coordinate
-
createInvokeMediumMap
Helper method which allows creation of the IMM object.- Parameters:
name
- the name of the medium map
-
createIncludePageSegment
Creates an IncludePageSegment on the current page.- Parameters:
name
- the name of the include page segmentx
- the x coordinate for the overlayy
- the y coordinate for the overlaywidth
- the width of the imageheight
- the height of the image
-
createPageTagLogicalElement
Creates a TagLogicalElement on the current page.- Parameters:
attributes
- the array of key value pairs.
-
createPageGroupTagLogicalElement
Creates a TagLogicalElement on the current page group.- Parameters:
attributes
- the array of key value pairs.
-
createTagLogicalElement
Creates a TagLogicalElement on the current page or page group- Parameters:
name
- The tag namevalue
- The tag valueencoding
- The CCSID character set encoding
-
createNoOperation
Creates a NoOperation item- Parameters:
content
- byte data
-
getCurrentPageGroup
Returns the current page group- Returns:
- the current page group
-
startDocument
Start a new document.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
startPageGroup
Start a new page group. When processing has finished on the current page group theendPageGroup()
method must be invoked to mark the page group ending.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
endPageGroup
Helper method to mark the end of the page group.- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
setInterchangeSet
Sets the MO:DCA interchange set to use- Parameters:
interchangeSet
- the MO:DCA interchange set
-
getInterchangeSet
Returns the MO:DCA interchange set in use- Returns:
- the MO:DCA interchange set in use
-
getResourceGroup
Returns the resource group for a given resource info- Parameters:
level
- a resource level- Returns:
- a resource group for the given resource info
-