Enterprise Information Portal APIs

com.ibm.mm.viewer
Class CMBPage

java.lang.Object
  |
  +--com.ibm.mm.viewer.CMBPage
All Implemented Interfaces:
CMBViewerConstants, java.io.Serializable

public class CMBPage
extends java.lang.Object
implements CMBViewerConstants, java.io.Serializable

CMBPage contains data for a particular page of a document. Methods on CMBPage provide renderable images of the document page at specified zoom, rotation. Methods are also provided to access the annotations on the page.

There is no public constructor on CMBPage. Use CMBDocument.getPage() to get an instance of CMBPage for a particular page of a document.

Since:
7.1
See Also:
Serialized Form

Fields inherited from interface com.ibm.mm.viewer.CMBViewerConstants
DEFAULT_PAGE_NUMBER, ROTATE_0, ROTATE_180, ROTATE_270, ROTATE_90
 
Method Summary
 void dispose()
          Releases document engine resources for the page.
 boolean getCanGetImage()
          Returns true if a java image of the page can be obtained using getImage().
 boolean getCanWrite()
          Returns true if the page can be written.
 CMBDocument getDocument()
          Returns the document that this page belongs to.
 double getHeight()
          Returns the height of the page, in inches.
 java.awt.Image getImage()
          Returns a Java image of the page.
 java.awt.Image getImage(double scale)
          Returns a scaled Java image of the page.
 double getMaxScale()
          Returns the maximum scale that pages of the document can be displayed.
 double getMinScale()
          Returns the minimum scale that this page can be displayed.
 int getPageNumber()
          Returns the number of this page in the document.
 java.lang.String getResourceMimeType(java.lang.String resourceId)
          Returns the MIME content type for a resource.
 int getRotation()
          Returns the rotation for this page.
 double getScale()
          Returns the actual scale that this page will be displayed.
 double getWidth()
          Returns the width of the page, in inches.
 java.lang.String getWriteMimeType()
          Returns the mime type for the format that the page will be written when using CMBPage.write.
 void setRotation(int rotation)
          Sets the rotation for this page.
 void write(java.io.OutputStream outStream)
          Writes the page to the output stream.
 void write(java.io.OutputStream outStream, java.lang.String resourcePrefix)
          Writes the page to the output stream.
 void writeResource(java.io.OutputStream outStream, java.lang.String resourceId)
          Writes the page resource to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocument

public CMBDocument getDocument()
Returns the document that this page belongs to.

getRotation

public int getRotation()
Returns the rotation for this page. This rotation is in addition to the rotation of the document.

setRotation

public void setRotation(int rotation)
Sets the rotation for this page. This rotation is in addition to the rotation of the document.
Parameters:
rotation - The rotation

getPageNumber

public int getPageNumber()
Returns the number of this page in the document. (The first page of a document is number 1.)

getWidth

public double getWidth()
Returns the width of the page, in inches. If the width cannot be determined, 0.0 is returned.

getHeight

public double getHeight()
Returns the height of the page, in inches. If the height cannot be determined, 0.0 is returned.

getMinScale

public double getMinScale()
Returns the minimum scale that this page can be displayed. If the minimum scale cannot be determined, 1.0 is returned.

getMaxScale

public double getMaxScale()
Returns the maximum scale that pages of the document can be displayed. If the maximum scale cannot be determined, 1.0 is returned.

getScale

public double getScale()
Returns the actual scale that this page will be displayed. This is the preferred scale as specified on the document, limited by the min and max scale of this page.

getCanGetImage

public boolean getCanGetImage()
Returns true if a java image of the page can be obtained using getImage().

getImage

public java.awt.Image getImage()
                        throws CMBDocumentEngineException,
                               java.io.IOException
Returns a Java image of the page.

getImage

public java.awt.Image getImage(double scale)
                        throws CMBDocumentEngineException,
                               java.io.IOException
Returns a scaled Java image of the page.
Parameters:
scale - scale to which the page image is scaled

getCanWrite

public boolean getCanWrite()
Returns true if the page can be written.

getWriteMimeType

public java.lang.String getWriteMimeType()
Returns the mime type for the format that the page will be written when using CMBPage.write. This format is determined by the underlying document conversion engine and the preferred format specified using CMBDocumentServices.setPreferredPageFormats. First checks if the engine can write this particular page in one of the preferred page formats. If the engine returns true for one of the formats, then the page is written in the selected format. This way the document conversion engine can write each page to a different format(mime type) for pages of the same document. If the engine returns false for all the preferred formats, then it checks if the engine can convert from the document mime type to one of the preferred page formats.

write

public void write(java.io.OutputStream outStream)
           throws CMBDocumentEngineException,
                  java.io.IOException
Writes the page to the output stream. The format of the page is chosen using the getMimeType method.
Parameters:
outStream - the output stream where the page is written.

write

public void write(java.io.OutputStream outStream,
                  java.lang.String resourcePrefix)
           throws CMBDocumentEngineException,
                  java.io.IOException
Writes the page to the output stream. The format of the page is chosen using the getMimeType method.

This version of write has a parameter for identifying external resources in the generated page. External resources are other files needed to compose the page. The common case is HTML documents, where the resources are usually images referenced with relative links in the document.

Parameters:
outStream - the output stream where the page is written.
resourcePrefix - for HTML generated pages, this is a prefix to be added to hrefs for embedded images. The application should choose the prefix in order to gain control for resource requests.

getResourceMimeType

public java.lang.String getResourceMimeType(java.lang.String resourceId)
                                     throws java.io.IOException
Returns the MIME content type for a resource. For HTML, a resource is usually an embedded image referred to by the generated page.
Parameters:
resourceId - an identifier for the resource. For HTML, this is the suffix following the resource prefix specified on CMBPage.write.

writeResource

public void writeResource(java.io.OutputStream outStream,
                          java.lang.String resourceId)
                   throws CMBDocumentEngineException,
                          java.io.IOException
Writes the page resource to the output stream.
Parameters:
outStream - the output stream where the page resource is written.
resourceId - an identifier for the resource. For HTML, this is the suffix following the resource prefix specified on CMBPage.write.

dispose

public void dispose()
Releases document engine resources for the page. Calling dispose for a page may make additional resources available in the engine for loading other pages, but the next time an action is taken on a disposed page, the performance may be slower because the engine may need to extract the page from the document again.

EIP JavaBeans

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.