org.apache.fop.area

Class PageViewport

Implemented Interfaces:
Cloneable, Resolvable

public class PageViewport
extends AreaTreeObject
implements Resolvable, Cloneable

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

protected static Log
log
logging instance

Fields inherited from class org.apache.fop.area.AreaTreeObject

foreignAttributes

Constructor Summary

PageViewport(Rectangle2D viewArea, int pageNumber, String pageStr, String simplePageMasterName, boolean blank)
Constructor used by the area tree parser.
PageViewport(PageViewport original)
Copy constructor.
PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank)
Create a page viewport.

Method Summary

void
addExtensionAttachment(ExtensionAttachment attachment)
Adds a new ExtensionAttachment instance to this page.
void
addMarkers(Map marks, boolean starting, boolean isfirst, boolean islast)
Add the markers for this page.
void
addUnresolvedIDRef(String idref, Resolvable res)
Add an idref to this page.
void
clear()
Clear the page contents to save memory.
Object
clone()
Clone this page.
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 PageViewport
NormalFlow
getCurrentFlow()
Convenience method to get the normal-flow-reference-area currently being processed
Span
getCurrentSpan()
Convenience method to get the span-reference-area currently being processed
List
getExtensionAttachments()
String[]
getIDRefs()
Get the unresolved idrefs for this page.
String
getKey()
Get the key for this page viewport.
Object
getMarker(String name, int pos)
Get a marker from this page.
Page
getPage()
Get the page reference area with the contents.
int
getPageIndex()
int
getPageNumber()
Get the page number of this page.
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.
String
getSimplePageMasterName()
Rectangle2D
getViewArea()
Get the view area rectangle of this viewport.
boolean
hasExtensionAttachments()
boolean
isBlank()
boolean
isFirstWithID(String id)
Check whether a certain id first appears on this page
boolean
isResolved()
Check if this page has been fully resolved.
void
loadPage(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
resolveIDRef(String id, List pages)
void
savePage(ObjectOutputStream out)
Save the page contents to an object stream.
void
setFirstWithID(String id)
Add an "ID-first" to this page.
void
setKey(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 to
String
toString()

Methods inherited from class org.apache.fop.area.AreaTreeObject

getForeignAttributeValue, getForeignAttributes, setForeignAttribute, setForeignAttributes

Field Details

log

protected static Log log
logging instance

Constructor Details

PageViewport

public PageViewport(Rectangle2D viewArea,
                    int pageNumber,
                    String pageStr,
                    String simplePageMasterName,
                    boolean blank)
Constructor used by the area tree parser.
Parameters:
viewArea - the view area
pageNumber - the page number
pageStr - String representation of the page number
simplePageMasterName - name of the original simple-page-master that generated this page
blank - true if this is a blank page

PageViewport

public PageViewport(PageViewport original)
Copy constructor.
Parameters:
original - the original PageViewport to copy from

PageViewport

public PageViewport(SimplePageMaster spm,
                    int pageNumber,
                    String pageStr,
                    boolean blank)
Create a page viewport.
Parameters:
spm - SimplePageMaster indicating the page and region dimensions
pageNumber - the page number
pageStr - String representation of the page number
blank - true if this is a blank page

Method Details

addExtensionAttachment

public void addExtensionAttachment(ExtensionAttachment attachment)
Adds a new ExtensionAttachment instance to this page.
Parameters:
attachment - the ExtensionAttachment

addMarkers

public void addMarkers(Map marks,
                       boolean starting,
                       boolean isfirst,
                       boolean islast)
Add the markers for this page. Only the required markers are kept. For "first-starting-within-page" it adds the markers that are starting only if the marker class name is not already added. For "first-including-carryover" it adds any starting marker if the marker class name is not already added. For "last-starting-within-page" it adds all marks that are starting, replacing earlier markers. For "last-ending-within-page" it adds all markers that are ending, replacing earlier markers. Should this logic be placed in the Page layout manager.
Parameters:
marks - the map of markers to add
starting - if the area being added is starting or ending
isfirst - if the area being added has is-first trait
islast - if the area being added has is-last trait

addUnresolvedIDRef

public void addUnresolvedIDRef(String idref,
                               Resolvable res)
Add an idref to this page. All idrefs found for child areas of this PageViewport are added to unresolvedIDRefs, for subsequent resolution by AreaTreeHandler calls to this object's resolveIDRef().
Parameters:
idref - the idref
res - the child element of this page that needs this idref resolved

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.

clone

public Object clone()
Clone this page. Used by the page master to create a copy of an original page.
Returns:
a copy of this page and associated viewports

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

dumpMarkers

public void dumpMarkers()
Dumps the current marker data to the logger.

getBodyRegion

public BodyRegion getBodyRegion()
Convenience method to get BodyRegion of this PageViewport
Returns:
BodyRegion object

getCurrentFlow

public NormalFlow getCurrentFlow()
Convenience method to get the normal-flow-reference-area currently being processed
Returns:
span currently being processed.

getCurrentSpan

public Span getCurrentSpan()
Convenience method to get the span-reference-area currently being processed
Returns:
span currently being processed.

getExtensionAttachments

public List getExtensionAttachments()
Returns:
the list of extension attachments for this page

getIDRefs

public String[] getIDRefs()
Get the unresolved idrefs for this page.
Specified by:
getIDRefs in interface Resolvable
Returns:
String array of idref's that still have not been resolved

getKey

public 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

getMarker

public Object getMarker(String name,
                        int pos)
Get a marker from this page. This will retrieve a marker with the class name and position.
Parameters:
name - The class name of the marker to retrieve
pos - the position to retrieve
Returns:
Object the marker found or null

getPage

public Page getPage()
Get the page reference area with the contents.
Returns:
the page reference area

getPageIndex

public int getPageIndex()
Returns:
the overall page index of the page in this rendering run (zero-based, -1 if it is undetermined).

getPageNumber

public int getPageNumber()
Get the page number of this page.
Returns:
the integer value that represents this page

getPageNumberString

public String getPageNumberString()
Get the page number of this page.
Returns:
the string that represents this page

getPageSequence

public PageSequence getPageSequence()
Returns:
the page sequence this page belongs to

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.

getSimplePageMasterName

public String getSimplePageMasterName()
Returns:
the name of the simple-page-master that created this page

getViewArea

public Rectangle2D getViewArea()
Get the view area rectangle of this viewport.
Returns:
the rectangle for this viewport

hasExtensionAttachments

public boolean hasExtensionAttachments()
Returns:
whether this page viewport has any extension attachments

isBlank

public boolean isBlank()
Returns:
True if this is a blank page.

isFirstWithID

public boolean isFirstWithID(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

isResolved

public boolean isResolved()
Check if this page has been fully resolved.
Specified by:
isResolved in interface Resolvable
Returns:
true if the page is resolved and can be rendered

loadPage

public void loadPage(ObjectInputStream in)
            throws Exception
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

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.

resolveIDRef

public void resolveIDRef(String id,
                         List pages)
Specified by:
resolveIDRef in interface Resolvable

savePage

public void savePage(ObjectOutputStream out)
            throws Exception
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

setFirstWithID

public void setFirstWithID(String id)
Add an "ID-first" to this page. This is typically called by the AreaTreeHandler when associating an ID with a PageViewport.
Parameters:
id - the id to be registered as first appearing on this page

setKey

public void setKey(String key)
Sets the unique key for this PageViewport that will be used to reference this page.
Parameters:
key - the unique key.

setPage

public void setPage(Page page)
Sets the page object for this PageViewport.
Parameters:
page - the 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

setPageSequence

public void setPageSequence(PageSequence seq)
Sets the page sequence this page belongs to
Parameters:
seq - the page sequence

toString

public String toString()

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.