Package org.apache.fop.area
Class PageViewport
- java.lang.Object
-
- org.apache.fop.area.AreaTreeObject
-
- org.apache.fop.area.PageViewport
-
- All Implemented Interfaces:
java.lang.Cloneable
,Resolvable
public class PageViewport extends AreaTreeObject implements Resolvable
Page viewport that specifies the viewport area and holds the page contents. This is the top level object for a page and remains valid for the life of the document and the area tree. This object may be used as a key to reference a page. This is the level that creates the page. The page (reference area) is then rendered inside the page object
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
blank
private java.util.Set<java.lang.String>
idFirsts
protected static org.apache.commons.logging.Log
log
logging instanceprivate Page
page
private int
pageIndex
private java.lang.String
pageKey
Unique key to identify the page.private Markers
pageMarkers
private int
pageNumber
private java.lang.String
pageNumberString
private PageSequence
pageSequence
private java.util.Map<java.lang.String,java.util.List<PageViewport>>
pendingResolved
private java.lang.String
simplePageMasterName
private java.util.Map<java.lang.String,java.util.List<Resolvable>>
unresolvedIDRefs
private java.awt.Rectangle
viewArea
-
Fields inherited from class org.apache.fop.area.AreaTreeObject
extensionAttachments, foreignAttributes
-
-
Constructor Summary
Constructors Constructor Description PageViewport(java.awt.Rectangle viewArea, int pageNumber, java.lang.String pageStr, java.lang.String simplePageMasterName, boolean blank)
Constructor used by the area tree parser.PageViewport(PageViewport original)
Copy constructor.PageViewport(SimplePageMaster spm, int pageNumber, java.lang.String pageStr, boolean blank)
Create a page viewport.PageViewport(SimplePageMaster spm, int pageNumber, java.lang.String pageStr, boolean blank, boolean spanAll)
Create a page viewport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUnresolvedIDRef(java.lang.String idref, Resolvable res)
Add an idref to this page.void
clear()
Clear the page contents to save memory.java.lang.Object
clone()
Span
createSpan(boolean spanAll)
Convenience method to create a new Span for this this PageViewport.void
dumpMarkers()
Dumps the current marker data to the logger.BodyRegion
getBodyRegion()
Convenience method to get BodyRegion of this PageViewportNormalFlow
getCurrentFlow()
Convenience method to get the normal-flow-reference-area currently being processedSpan
getCurrentSpan()
Convenience method to get the span-reference-area currently being processedjava.lang.String[]
getIDRefs()
Get the unresolved idrefs for this page.java.lang.String
getKey()
Get the key for this page viewport.Page
getPage()
Get the page reference area with the contents.int
getPageIndex()
int
getPageNumber()
Get the page number of this page.java.lang.String
getPageNumberString()
Get the page number of this page.PageSequence
getPageSequence()
RegionReference
getRegionReference(int id)
Convenience method to return a given region-reference-area, keyed by the Constants class identifier for the corresponding formatting object (ie.java.lang.String
getSimplePageMasterName()
java.awt.Rectangle
getViewArea()
Get the view area rectangle of this viewport.boolean
isBlank()
boolean
isFirstWithID(java.lang.String id)
Check whether a certain id first appears on this pageboolean
isResolved()
Check if this page has been fully resolved.void
loadPage(java.io.ObjectInputStream in)
Load the page contents from an object stream.NormalFlow
moveToNextFlow()
Convenience method to increment the Span to the next NormalFlow to be processed, and to return that flow.void
registerMarkers(java.util.Map<java.lang.String,Marker> marks, boolean starting, boolean isfirst, boolean islast)
Register the markers for this page.void
replace(PageViewport oldViewPort)
Replace the old view port.void
resolveIDRef(java.lang.String id, java.util.List<PageViewport> pages)
This method allows the Resolvable object to resolve one of its unresolved idrefs with the actual set of PageViewports containing the target ID.Marker
resolveMarker(AbstractRetrieveMarker rm)
Resolve a marker from this page.void
savePage(java.io.ObjectOutputStream out)
Save the page contents to an object stream.void
setFirstWithID(java.lang.String id)
Add an "ID-first" to this page.void
setKey(java.lang.String key)
Sets the unique key for this PageViewport that will be used to reference this page.void
setPage(Page page)
Sets the page object for this PageViewport.void
setPageIndex(int index)
Sets the page index of the page in this rendering run.void
setPageSequence(PageSequence seq)
Sets the page sequence this page belongs tovoid
setWritingModeTraits(WritingModeTraitsGetter wmtg)
Sets the writing mode traits for the page associated with this viewport.java.lang.String
toString()
-
Methods inherited from class org.apache.fop.area.AreaTreeObject
addExtensionAttachment, getExtensionAttachments, getForeignAttributes, getForeignAttributeValue, hasExtensionAttachments, setExtensionAttachments, setForeignAttribute, setForeignAttributes
-
-
-
-
Field Detail
-
page
private Page page
-
viewArea
private java.awt.Rectangle viewArea
-
simplePageMasterName
private java.lang.String simplePageMasterName
-
pageKey
private java.lang.String pageKey
Unique key to identify the page. pageNumberString and pageIndex are both no option for this.
-
pageNumber
private int pageNumber
-
pageNumberString
private java.lang.String pageNumberString
-
pageIndex
private int pageIndex
-
blank
private boolean blank
-
pageSequence
private transient PageSequence pageSequence
-
idFirsts
private java.util.Set<java.lang.String> idFirsts
-
unresolvedIDRefs
private java.util.Map<java.lang.String,java.util.List<Resolvable>> unresolvedIDRefs
-
pendingResolved
private java.util.Map<java.lang.String,java.util.List<PageViewport>> pendingResolved
-
pageMarkers
private Markers pageMarkers
-
log
protected static final org.apache.commons.logging.Log log
logging instance
-
-
Constructor Detail
-
PageViewport
public PageViewport(SimplePageMaster spm, int pageNumber, java.lang.String pageStr, boolean blank, boolean spanAll)
Create a page viewport.- Parameters:
spm
- SimplePageMaster indicating the page and region dimensionspageNumber
- the page numberpageStr
- String representation of the page numberblank
- true if this is a blank pagespanAll
- true if the first span area spans all columns
-
PageViewport
public PageViewport(SimplePageMaster spm, int pageNumber, java.lang.String pageStr, boolean blank)
Create a page viewport.- Parameters:
spm
- SimplePageMaster indicating the page and region dimensionspageNumber
- the page numberpageStr
- String representation of the page numberblank
- true if this is a blank page
-
PageViewport
public PageViewport(PageViewport original) throws FOPException
Copy constructor.- Parameters:
original
- the original PageViewport to copy from- Throws:
FOPException
- when cloning of the page is not supported
-
PageViewport
public PageViewport(java.awt.Rectangle viewArea, int pageNumber, java.lang.String pageStr, java.lang.String simplePageMasterName, boolean blank)
Constructor used by the area tree parser.- Parameters:
viewArea
- the view areapageNumber
- the page numberpageStr
- String representation of the page numbersimplePageMasterName
- name of the original simple-page-master that generated this pageblank
- true if this is a blank page
-
-
Method Detail
-
setPageSequence
public void setPageSequence(PageSequence seq)
Sets the page sequence this page belongs to- Parameters:
seq
- the page sequence
-
getPageSequence
public PageSequence getPageSequence()
- Returns:
- the page sequence this page belongs to
-
getViewArea
public java.awt.Rectangle getViewArea()
Get the view area rectangle of this viewport.- Returns:
- the rectangle for this viewport
-
getPage
public Page getPage()
Get the page reference area with the contents.- Returns:
- the page reference area
-
setPage
public void setPage(Page page)
Sets the page object for this PageViewport.- Parameters:
page
- the page
-
getPageNumber
public int getPageNumber()
Get the page number of this page.- Returns:
- the integer value that represents this page
-
getPageNumberString
public java.lang.String getPageNumberString()
Get the page number of this page.- Returns:
- the string that represents this page
-
setPageIndex
public void setPageIndex(int index)
Sets the page index of the page in this rendering run. (This is not the same as the page number!)- Parameters:
index
- the page index (zero-based), -1 if it is undetermined
-
getPageIndex
public int getPageIndex()
- Returns:
- the overall page index of the page in this rendering run (zero-based, -1 if it is undetermined).
-
setKey
public void setKey(java.lang.String key)
Sets the unique key for this PageViewport that will be used to reference this page.- Parameters:
key
- the unique key.
-
getKey
public java.lang.String getKey()
Get the key for this page viewport. This is used so that a serializable key can be used to lookup the page or some other reference.- Returns:
- a unique page viewport key for this area tree
-
setFirstWithID
public void setFirstWithID(java.lang.String id)
Add an "ID-first" to this page. This is typically called by theAreaTreeHandler
when associating an ID with aPageViewport
.- Parameters:
id
- the id to be registered as first appearing on this page
-
isFirstWithID
public boolean isFirstWithID(java.lang.String id)
Check whether a certain id first appears on this page- Parameters:
id
- the id to be checked- Returns:
- true if this page is the first where the id appears
-
replace
public void replace(PageViewport oldViewPort)
Replace the old view port. This copies all ID related fields from the old view port to the current one.- Parameters:
oldViewPort
- old view port
-
addUnresolvedIDRef
public void addUnresolvedIDRef(java.lang.String idref, Resolvable res)
Add an idref to this page. All idrefs found for child areas of thisPageViewport
are added to unresolvedIDRefs, for subsequent resolution byAreaTreeHandler
calls to this object'sresolveIDRef()
.- Parameters:
idref
- the idrefres
- the child element of this page that needs this idref resolved
-
isResolved
public boolean isResolved()
Check if this page has been fully resolved.- Specified by:
isResolved
in interfaceResolvable
- Returns:
- true if the page is resolved and can be rendered
-
getIDRefs
public java.lang.String[] getIDRefs()
Get the unresolved idrefs for this page.- Specified by:
getIDRefs
in interfaceResolvable
- Returns:
- String array of idref's that still have not been resolved
-
resolveIDRef
public void resolveIDRef(java.lang.String id, java.util.List<PageViewport> pages)
This method allows the Resolvable object to resolve one of its unresolved idrefs with the actual set of PageViewports containing the target ID. The Resolvable object initially identifies to the AreaTreeHandler which idrefs it needs resolved. After the idrefs are resolved, the ATH calls this method to allow the Resolvable object to update itself with the PageViewport information.- Specified by:
resolveIDRef
in interfaceResolvable
- Parameters:
id
- an ID matching one of the Resolvable object's unresolved idref's.pages
- the list of PageViewports with the given ID
-
registerMarkers
public void registerMarkers(java.util.Map<java.lang.String,Marker> marks, boolean starting, boolean isfirst, boolean islast)
Register the markers for this page.- Parameters:
marks
- the map of markers to addstarting
- if the area being added is starting or endingisfirst
- if the area being added has is-first traitislast
- if the area being added has is-last trait
-
resolveMarker
public Marker resolveMarker(AbstractRetrieveMarker rm)
Resolve a marker from this page. This will retrieve a marker with the class name and position.- Parameters:
rm
- the retrieve-marker instance- Returns:
- Object the marker found or null
-
dumpMarkers
public void dumpMarkers()
Dumps the current marker data to the logger.
-
savePage
public void savePage(java.io.ObjectOutputStream out) throws java.io.IOException
Save the page contents to an object stream. The map of unresolved references are set on the page so that the resolvers can be properly serialized and reloaded.- Parameters:
out
- the object output stream to write the contents- Throws:
java.io.IOException
- in case of an I/O error while serializing the page
-
loadPage
public void loadPage(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
Load the page contents from an object stream. This loads the page contents from the stream and if there are any unresolved references that were resolved while saved they will be resolved on the page contents.- Parameters:
in
- the object input stream to read the page from- Throws:
java.lang.ClassNotFoundException
- if a class was not found while loading the pagejava.io.IOException
- if an I/O error occurred while loading the page
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classAreaTreeObject
- Throws:
java.lang.CloneNotSupportedException
-
clear
public void clear()
Clear the page contents to save memory. This object is kept for the life of the area tree since it holds id and marker information and is used as a key.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getSimplePageMasterName
public java.lang.String getSimplePageMasterName()
- Returns:
- the name of the simple-page-master that created this page
-
isBlank
public boolean isBlank()
- Returns:
- True if this is a blank page.
-
getBodyRegion
public BodyRegion getBodyRegion()
Convenience method to get BodyRegion of this PageViewport- Returns:
- BodyRegion object
-
createSpan
public Span createSpan(boolean spanAll)
Convenience method to create a new Span for this this PageViewport.- Parameters:
spanAll
- whether this is a single-column span- Returns:
- Span object created
-
getCurrentSpan
public Span getCurrentSpan()
Convenience method to get the span-reference-area currently being processed- Returns:
- span currently being processed.
-
getCurrentFlow
public NormalFlow getCurrentFlow()
Convenience method to get the normal-flow-reference-area currently being processed- Returns:
- span currently being processed.
-
moveToNextFlow
public NormalFlow moveToNextFlow()
Convenience method to increment the Span to the next NormalFlow to be processed, and to return that flow.- Returns:
- the next NormalFlow in the Span.
-
getRegionReference
public RegionReference getRegionReference(int id)
Convenience method to return a given region-reference-area, keyed by the Constants class identifier for the corresponding formatting object (ie. Constants.FO_REGION_BODY, FO_REGION_START, etc.)- Parameters:
id
- the Constants class identifier for the region.- Returns:
- the corresponding region-reference-area for this page.
-
setWritingModeTraits
public void setWritingModeTraits(WritingModeTraitsGetter wmtg)
Sets the writing mode traits for the page associated with this viewport.- Parameters:
wmtg
- a WM traits getter
-
-