com.ibm.as400.util.reportwriter.pclwriter
Class PCLContext

com.ibm.as400.util.reportwriter.pclwriter.PCLContext

public class PCLContext

The PCLContext class defines the methods necessary to render an area tree to a PCL data stream according to the rendering model of the XSL FO specification. An application is only required to create an instance of the PCLContext. The public methods defined in PCLContext are called internally.


Constructor Summary
PCLContext(java.io.OutputStream out, java.awt.print.PageFormat pF)
          Constructs a PCLContext object.
 
Method Summary
 void drawBorder(com.ibm.xsl.composer.prim.Border top, com.ibm.xsl.composer.prim.Border left, com.ibm.xsl.composer.prim.Border bottom, com.ibm.xsl.composer.prim.Border right, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size)
          Draw the border using the border traits given.
 void drawGlyph(char code, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location)
          Draw a single glyph at the given location.
 void drawGraphic(java.lang.String Uri, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size)
          Draw an image resource at the given location.
 void drawOrientatedGlyph(char code, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, short referenceOrientation)
          Draw a single glyph at the given location with the specified orientation.
 void drawRule(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint start, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint end, com.ibm.xsl.composer.prim.Border border)
          Draw a rule from the start point to the end point with given border properties.
 void drawString(java.lang.String series, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location)
          Draw a series of glyphs at the given location.
 void endDocument()
          Called at the end of processing a document, after all other output methods.
 void fillBackground(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size, com.ibm.as400.util.reportwriter.pclwriter.CSSColor color)
          Fill a rectangle with color.
 void fillBackground(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size, java.lang.String imageName, com.ibm.as400.util.reportwriter.pclwriter.CSSPoint offset, int howToRepeat)
          Fill a rectangle with an image.
 com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont getExtendedFont(com.ibm.xsl.composer.properties.FontProperty fontProperty)
          Get the class which reports metrics for a font that most nearly satisfies the given properties.
 com.ibm.as400.util.reportwriter.pclwriter.CSSExtent getGraphicDimension(java.lang.String image)
          Retrieve the dimensions of an image resource.
 com.ibm.as400.util.reportwriter.pclwriter.CSSExtent getPageSize()
          Get the size of the output media in fo space (long units).
 long getUnitsPerPixel()
          Get number of units in fo space equal to one pixel in device space.
 long getUnitsPerPoint()
          Get number of units in fo space equal to one point in device space.
 void notifyGraphic(java.net.URL image)
          Indicate to the context that an image resource may be used in a later call to fillBackground or drawGraphic.
 void setFont(com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont extendedFont)
          Set the font for rendering text to a font that most nearly satisfies the given properties.
 void setTextColor(com.ibm.as400.util.reportwriter.pclwriter.CSSColor color)
          Set the color for rendering text.
 void startDocument()
          Called at the start of processing a document, before any other output methods.
 void startViewport(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location, com.ibm.as400.util.reportwriter.pclwriter.CSSExtent extent, boolean isPage)
          Start a viewport with the given location and extent.
 

Constructor Detail

PCLContext

public PCLContext(java.io.OutputStream out,
                  java.awt.print.PageFormat pF)
           throws java.lang.NullPointerException
Constructs a PCLContext object.
Parameters:
out - The OutputStream used to hold the PCL data.
pF - The PageFormat describes the size and orientation of a page to be printed.
Throws:
java.lang.NullPointerException - If the OutputStream or PageFormat is null.
Method Detail

getPageSize

public com.ibm.as400.util.reportwriter.pclwriter.CSSExtent getPageSize()
Get the size of the output media in fo space (long units).
Returns:
extent of the device, by copy.

getUnitsPerPoint

public long getUnitsPerPoint()
Get number of units in fo space equal to one point in device space.
Returns:
number of units per point

getUnitsPerPixel

public long getUnitsPerPixel()
Get number of units in fo space equal to one pixel in device space.
Returns:
number of units per pixel

startDocument

public void startDocument()
Called at the start of processing a document, before any other output methods. Allows the implementation to do initialialization.

endDocument

public void endDocument()
Called at the end of processing a document, after all other output methods. Allows the implementation to do end processing, such as ejecting the final page.

startViewport

public void startViewport(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                          com.ibm.as400.util.reportwriter.pclwriter.CSSExtent extent,
                          boolean isPage)
Start a viewport with the given location and extent.
Parameters:
location - the location of the start of the viewport.
extent - the extent of the vieport.
isPage - if true, on a page device, open the viewport on a new page; on a screen device, open a new window.

getExtendedFont

public com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont getExtendedFont(com.ibm.xsl.composer.properties.FontProperty fontProperty)
Get the class which reports metrics for a font that most nearly satisfies the given properties.
Parameters:
fontProperty - an XSL font property object
Returns:
ExtendedFont A font metrics class, which is immutable.

setFont

public void setFont(com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont extendedFont)
Set the font for rendering text to a font that most nearly satisfies the given properties.
Parameters:
extendedFont - the font information from the framework
See Also:
#getExtendedFont()

setTextColor

public void setTextColor(com.ibm.as400.util.reportwriter.pclwriter.CSSColor color)
Set the color for rendering text.
Parameters:
color - text color

drawGlyph

public void drawGlyph(char code,
                      com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location)
Draw a single glyph at the given location. Draws with the font last set, in the color last set.
Parameters:
code - the codepoint
location - the location of the start of the glyph at it's baseline.
See Also:
setFont(com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pclwriter.CSSColor)

drawOrientatedGlyph

public void drawOrientatedGlyph(char code,
                                com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                                short referenceOrientation)
Draw a single glyph at the given location with the specified orientation. Draws with the font last set, in the color last set.
Parameters:
code - the codepoint
location - the location of the start of the glyph at it's baseline.
referenceOrientation - the orientation of the glyph
See Also:
setFont(com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pclwriter.CSSColor)

drawString

public void drawString(java.lang.String series,
                       com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location)
Draw a series of glyphs at the given location. Draws with the font last set, in the color last set.
Parameters:
series - the sequence of codepoints
location - the location of the start of the first glyph at it's baseline.
See Also:
setFont(com.ibm.as400.util.reportwriter.pclwriter.ExtendedFont), setTextColor(com.ibm.as400.util.reportwriter.pclwriter.CSSColor)

drawRule

public void drawRule(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint start,
                     com.ibm.as400.util.reportwriter.pclwriter.CSSPoint end,
                     com.ibm.xsl.composer.prim.Border border)
Draw a rule from the start point to the end point with given border properties.
Parameters:
start - the first endpoint.
end - the second endpoint.
border - the properties of the border

drawBorder

public void drawBorder(com.ibm.xsl.composer.prim.Border top,
                       com.ibm.xsl.composer.prim.Border left,
                       com.ibm.xsl.composer.prim.Border bottom,
                       com.ibm.xsl.composer.prim.Border right,
                       com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                       com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size)
Draw the border using the border traits given.
Parameters:
top - properties of the top border
left - properties of the left border
bottom - properties of the bottom border
right - properties of the right border
location - of the rectangle internal to the border
size - of the rectangle internal to the border

fillBackground

public void fillBackground(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                           com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size,
                           com.ibm.as400.util.reportwriter.pclwriter.CSSColor color)
Fill a rectangle with color.
Parameters:
location - of the rectangle.
size - of the rectangle
color - to fill

fillBackground

public void fillBackground(com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                           com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size,
                           java.lang.String imageName,
                           com.ibm.as400.util.reportwriter.pclwriter.CSSPoint offset,
                           int howToRepeat)
Fill a rectangle with an image.
Parameters:
location - of the rectangle.
size - of the rectangle
imageName - uri for the image
offset - the offset of the origin of the image
howToRepeat - whether and how to tile the image

notifyGraphic

public void notifyGraphic(java.net.URL image)
Indicate to the context that an image resource may be used in a later call to fillBackground or drawGraphic.
Parameters:
image - the uri for the image

drawGraphic

public void drawGraphic(java.lang.String Uri,
                        com.ibm.as400.util.reportwriter.pclwriter.CSSPoint location,
                        com.ibm.as400.util.reportwriter.pclwriter.CSSExtent size)
Draw an image resource at the given location.
Parameters:
Uri - the uri for the image
location - the location of the start of the glyph at it's baseline.
size - of the image (context must scale to this size)

getGraphicDimension

public com.ibm.as400.util.reportwriter.pclwriter.CSSExtent getGraphicDimension(java.lang.String image)
Retrieve the dimensions of an image resource.
Parameters:
image - the uri for the image
Returns:
size of the image