Package org.apache.fop.afp
Class DataStream
- java.lang.Object
-
- org.apache.fop.afp.DataStream
-
public class DataStream extends java.lang.Object
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
Fields Modifier and Type Field Description private boolean
complete
Boolean completion indicatorprivate Overlay
currentOverlay
The current overlay objectprivate AbstractPageObject
currentPage
The current pageprivate PageGroup
currentPageGroup
The current page group objectprivate PageObject
currentPageObject
The current page objectprivate Document
document
The AFP document objectprivate Factory
factory
private InterchangeSet
interchangeSet
The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set)protected static org.apache.commons.logging.Log
LOG
Static logging instanceprivate java.io.OutputStream
outputStream
private AFPPaintingState
paintingState
the afp painting state
-
Constructor Summary
Constructors Constructor Description DataStream(Factory factory, AFPPaintingState paintingState, java.io.OutputStream outputStream)
Default constructor for the AFPDocumentStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFontsToCurrentPage(java.util.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(java.lang.String name, int x, int y)
Helper method which allows creation of the MPO object, via the AEG.void
createIncludePageSegment(java.lang.String name, int x, int y, int width, int height)
Creates an IncludePageSegment on the current page.void
createInvokeMediumMap(java.lang.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(java.lang.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, java.awt.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(java.lang.String name, java.lang.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
endDocument()
Helper method to mark the end of the current document.void
endOverlay()
Helper method to mark the end of the current overlay.void
endPage()
Helper method to mark the end of the current page.void
endPageGroup()
Helper method to mark the end of the page group.AbstractPageObject
getCurrentPage()
Returns the current pagePageGroup
getCurrentPageGroup()
Returns the current page groupprivate Document
getDocument()
Returns the document objectInterchangeSet
getInterchangeSet()
Returns the MO:DCA interchange set in usejava.io.OutputStream
getOutputStream()
Returns the outputstreamprivate java.awt.Point
getPoint(int x, int y)
Returns a point on the current pageResourceGroup
getResourceGroup(AFPResourceLevel level)
Returns the resource group for a given resource infovoid
restorePage(PageObject pageObject)
Helper method to restore the current page.PageObject
savePage()
Helper method to save the current page.void
setDocumentName(java.lang.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
startDocument()
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
startPageGroup()
Start a new page group.
-
-
-
Field Detail
-
LOG
protected static final org.apache.commons.logging.Log LOG
Static logging instance
-
complete
private boolean complete
Boolean completion indicator
-
document
private Document document
The AFP document object
-
currentPageGroup
private PageGroup currentPageGroup
The current page group object
-
currentPageObject
private PageObject currentPageObject
The current page object
-
currentOverlay
private Overlay currentOverlay
The current overlay object
-
currentPage
private AbstractPageObject currentPage
The current page
-
interchangeSet
private InterchangeSet interchangeSet
The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set)
-
factory
private final Factory factory
-
outputStream
private java.io.OutputStream outputStream
-
paintingState
private final AFPPaintingState paintingState
the afp painting state
-
-
Constructor Detail
-
DataStream
public DataStream(Factory factory, AFPPaintingState paintingState, java.io.OutputStream outputStream)
Default constructor for the AFPDocumentStream.- Parameters:
factory
- the resource factorypaintingState
- the AFP painting stateoutputStream
- the outputstream to write to
-
-
Method Detail
-
getOutputStream
public java.io.OutputStream getOutputStream()
Returns the outputstream- Returns:
- the outputstream
-
getDocument
private Document getDocument()
Returns the document object- Returns:
- the document object
-
getCurrentPage
public AbstractPageObject getCurrentPage()
Returns the current page- Returns:
- the current page
-
setDocumentName
public void setDocumentName(java.lang.String name)
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
public void endDocument() throws java.io.IOException
Helper method to mark the end of the current document.- Throws:
java.io.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
public void endOverlay() throws java.io.IOException
Helper method to mark the end of the current overlay.- Throws:
java.io.IOException
- thrown if an I/O exception of some sort has occurred
-
savePage
public PageObject savePage()
Helper method to save the current page.- Returns:
- current page object that was saved
-
restorePage
public void restorePage(PageObject pageObject)
Helper method to restore the current page.- Parameters:
pageObject
- page object
-
endPage
public void endPage() throws java.io.IOException
Helper method to mark the end of the current page.- Throws:
java.io.IOException
- thrown if an I/O exception of some sort has occurred
-
addFontsToCurrentPage
public void addFontsToCurrentPage(java.util.Map pageFonts)
Creates the given page fonts in the current page- Parameters:
pageFonts
- a collection of AFP font attributes
-
createFont
public void 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.- Parameters:
fontReference
- the font number used as the resource identifierfont
- the fontsize
- the point size of the font
-
getPoint
private java.awt.Point getPoint(int x, int y)
Returns a point on the current page- Parameters:
x
- the X-coordinatey
- the Y-coordinate- Returns:
- a point on the current page
-
createText
public void createText(AFPTextDataInfo textDataInfo, int letterSpacing, int wordSpacing, Font font, CharacterSet charSet) throws java.io.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:
java.io.UnsupportedEncodingException
- thrown if character encoding is not supported
-
createLine
public void createLine(AFPLineDataInfo lineDataInfo)
Method to create a line on the current page.- Parameters:
lineDataInfo
- the line data information.
-
createShading
public void createShading(int x, int y, int w, int h, java.awt.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).- 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
public void createIncludePageOverlay(java.lang.String name, int x, int y)
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
public void createInvokeMediumMap(java.lang.String name)
Helper method which allows creation of the IMM object.- Parameters:
name
- the name of the medium map
-
createIncludePageSegment
public void createIncludePageSegment(java.lang.String name, int x, int y, int width, int height)
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
public void createPageTagLogicalElement(TagLogicalElement.State[] attributes)
Creates a TagLogicalElement on the current page.- Parameters:
attributes
- the array of key value pairs.
-
createPageGroupTagLogicalElement
public void createPageGroupTagLogicalElement(TagLogicalElement.State[] attributes)
Creates a TagLogicalElement on the current page group.- Parameters:
attributes
- the array of key value pairs.
-
createTagLogicalElement
public void createTagLogicalElement(java.lang.String name, java.lang.String value, int encoding)
Creates a TagLogicalElement on the current page or page group- Parameters:
name
- The tag namevalue
- The tag valueencoding
- The CCSID character set encoding
-
createNoOperation
public void createNoOperation(java.lang.String content)
Creates a NoOperation item- Parameters:
content
- byte data
-
getCurrentPageGroup
public PageGroup getCurrentPageGroup()
Returns the current page group- Returns:
- the current page group
-
startDocument
public void startDocument() throws java.io.IOException
Start a new document.- Throws:
java.io.IOException
- thrown if an I/O exception of some sort has occurred
-
startPageGroup
public void startPageGroup() throws java.io.IOException
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:
java.io.IOException
- thrown if an I/O exception of some sort has occurred
-
endPageGroup
public void endPageGroup() throws java.io.IOException
Helper method to mark the end of the page group.- Throws:
java.io.IOException
- thrown if an I/O exception of some sort has occurred
-
setInterchangeSet
public void setInterchangeSet(InterchangeSet interchangeSet)
Sets the MO:DCA interchange set to use- Parameters:
interchangeSet
- the MO:DCA interchange set
-
getInterchangeSet
public InterchangeSet getInterchangeSet()
Returns the MO:DCA interchange set in use- Returns:
- the MO:DCA interchange set in use
-
getResourceGroup
public ResourceGroup getResourceGroup(AFPResourceLevel level)
Returns the resource group for a given resource info- Parameters:
level
- a resource level- Returns:
- a resource group for the given resource info
-
-