fop 0.90alpha1

org.apache.fop.area
Class PageViewport

java.lang.Object
  extended byorg.apache.fop.area.PageViewport
All Implemented Interfaces:
java.lang.Cloneable, Resolvable

public class PageViewport
extends java.lang.Object
implements Resolvable, java.lang.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 org.apache.commons.logging.Log log
          logging instance
 
Constructor Summary
PageViewport(SimplePageMaster spm, java.lang.String pageStr, boolean blank)
          Create a page viewport.
PageViewport(SimplePageMaster spm, java.lang.String pageStr, Page p, java.awt.geom.Rectangle2D bounds)
          Create a page viewport
 
Method Summary
 void addMarkers(java.util.Map marks, boolean starting, boolean isfirst, boolean islast)
          Add the markers for this page.
 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()
          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
 java.lang.String[] getIDRefs()
          Get the unresolved idrefs for this page.
 java.lang.String getKey()
          Get the key for this page viewport.
 java.lang.Object getMarker(java.lang.String name, int pos)
          Get a marker from this page.
 Page getPage()
          Get the page reference area with the contents.
 int getPageIndex()
           
 java.lang.String getPageNumberString()
          Get the page number of this page.
 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.
 SimplePageMaster getSPM()
           
 java.awt.geom.Rectangle2D getViewArea()
          Get the view area rectangle of this viewport.
 boolean isBlank()
           
 boolean 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 resolveIDRef(java.lang.String id, java.util.List pages)
          This method allows the Resolvable object to resolve one of its unresolved idrefs with the actual set of PageViewports containing the target ID.
 void savePage(java.io.ObjectOutputStream out)
          Save the page contents to an object stream.
 void setClip(boolean c)
          Set if this viewport should clip.
 void setPageIndex(int index)
          Sets the page index of the page in this rendering run.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
logging instance

Constructor Detail

PageViewport

public PageViewport(SimplePageMaster spm,
                    java.lang.String pageStr,
                    boolean blank)
Create a page viewport.

Parameters:
spm - SimplePageMaster indicating the page and region dimensions
pageStr - String representation of the page number
blank - true if this is a blank page

PageViewport

public PageViewport(SimplePageMaster spm,
                    java.lang.String pageStr,
                    Page p,
                    java.awt.geom.Rectangle2D bounds)
Create a page viewport

Parameters:
spm - SimplePageMaster indicating the page and region dimensions
pageStr - the page number as string.
p - Page Reference Area
bounds - Page Viewport dimensions
Method Detail

setClip

public void setClip(boolean c)
Set if this viewport should clip.

Parameters:
c - true if this viewport should clip

getViewArea

public java.awt.geom.Rectangle2D 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

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.

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).

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

addUnresolvedIDRef

public void addUnresolvedIDRef(java.lang.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

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

getIDRefs

public java.lang.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

resolveIDRef

public void resolveIDRef(java.lang.String id,
                         java.util.List pages)
Description copied from interface: Resolvable
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 interface Resolvable
Parameters:
id - an ID matching one of the Resolvable object's unresolved idref's.
pages - the list of PageViewports with the given ID
See Also:
Resolvable.resolveIDRef(String, List)

addMarkers

public void addMarkers(java.util.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

getMarker

public java.lang.Object getMarker(java.lang.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

dumpMarkers

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


savePage

public void savePage(java.io.ObjectOutputStream out)
              throws java.lang.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
Throws:
java.lang.Exception - if there is a problem saving the page

loadPage

public void loadPage(java.io.ObjectInputStream in)
              throws java.lang.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
Throws:
java.lang.Exception - if there is an error loading the page

clone

public java.lang.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

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()
See Also:
Object.toString()

getSPM

public SimplePageMaster getSPM()
Returns:
Returns the spm.

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.

fop 0.90alpha1

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