org.apache.pdfbox.pdfviewer
Class PageDrawer

java.lang.Object
  extended by org.apache.pdfbox.util.PDFStreamEngine
      extended by org.apache.pdfbox.pdfviewer.PageDrawer

public class PageDrawer
extends PDFStreamEngine

This will paint a page in a PDF document to a graphics context.

Version:
$Revision: 1.22 $
Author:
Ben Litchfield

Field Summary
protected  PDPage page
          Current page to be rendered.
protected  Dimension pageSize
          Size of the page.
 
Constructor Summary
PageDrawer()
          Default constructor, loads properties from file.
 
Method Summary
 void colorChanged(boolean bStroking)
          Deprecated. 
 void drawImage(Image awtImage, AffineTransform at)
          Draw the AWT image.
 void drawPage(Graphics g, PDPage p, Dimension pageDimension)
          This will draw the page to the requested context.
 void fillPath(int windingRule)
          Fill the path.
 double fixY(double y)
          Fix the y coordinate.
 Graphics2D getGraphics()
          Get the graphics that we are currently drawing on.
 GeneralPath getLinePath()
          Get the current line path to be drawn.
 PDPage getPage()
          Get the page that is currently being drawn.
 Dimension getPageSize()
          Get the size of the page that is currently being drawn.
 BasicStroke getStroke()
          This will return the current stroke.
protected  void processTextPosition(TextPosition text)
          You should override this method if you want to perform an action when a text is being processed.
 void setClippingPath(int windingRule)
          Set the clipping Path.
 void setLinePath(GeneralPath newLinePath)
          Set the line path to draw.
 void setStroke(BasicStroke newStroke)
          This will set the current stroke.
protected  void SHFill_Axial(PDShading Shading)
          Fill with an Axial Shading.
protected  void SHFill_CoonsPatch(PDShading Shading)
          Fill with a Coons patch mesh If extending the class, override this and its siblings, not the public SHFill method.
protected  void SHFill_FreeGourad(PDShading Shading)
          Fill with a Free-form Gourad-shaded triangle mesh.
protected  void SHFill_Function(PDShading Shading)
          Fill with a Function-based gradient / shading.
protected  void SHFill_LatticeGourad(PDShading Shading)
          Fill with a Lattice-form Gourad-shaded triangle mesh.
protected  void SHFill_Radial(PDShading Shading)
          Fill with a Radial gradient / shading.
protected  void SHFill_TensorPatch(PDShading Shading)
          Fill with a Tensor-product patch mesh.
 void shFill(COSName shadingName)
          Fill with Shading.
 void SHFill(COSName ShadingName)
          Deprecated. use {@link #shFill(COSName)) instead.
 void strokePath()
          Stroke the path.
 Point2D.Double transformedPoint(double x, double y)
          use the current transformation matrix to transform a single point.
 
Methods inherited from class org.apache.pdfbox.util.PDFStreamEngine
getColorSpaces, getCurrentPage, getFonts, getGraphicsStack, getGraphicsState, getGraphicsStates, getResources, getTextLineMatrix, getTextMatrix, getTotalCharCnt, getValidCharCnt, getXObjects, inspectFontEncoding, isForceParsing, processEncodedText, processOperator, processOperator, processStream, processSubStream, registerOperatorProcessor, resetEngine, setColorSpaces, setFonts, setForceParsing, setGraphicsStack, setGraphicsState, setGraphicsStates, setTextLineMatrix, setTextMatrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageSize

protected Dimension pageSize
Size of the page.


page

protected PDPage page
Current page to be rendered.

Constructor Detail

PageDrawer

public PageDrawer()
           throws IOException
Default constructor, loads properties from file.

Throws:
IOException - If there is an error loading properties from the file.
Method Detail

drawPage

public void drawPage(Graphics g,
                     PDPage p,
                     Dimension pageDimension)
              throws IOException
This will draw the page to the requested context.

Parameters:
g - The graphics context to draw onto.
p - The page to draw.
pageDimension - The size of the page to draw.
Throws:
IOException - If there is an IO error while drawing the page.

processTextPosition

protected void processTextPosition(TextPosition text)
You should override this method if you want to perform an action when a text is being processed.

Overrides:
processTextPosition in class PDFStreamEngine
Parameters:
text - The text to process

getGraphics

public Graphics2D getGraphics()
Get the graphics that we are currently drawing on.

Returns:
The graphics we are drawing on.

getPage

public PDPage getPage()
Get the page that is currently being drawn.

Returns:
The page that is being drawn.

getPageSize

public Dimension getPageSize()
Get the size of the page that is currently being drawn.

Returns:
The size of the page that is being drawn.

fixY

public double fixY(double y)
Fix the y coordinate.

Parameters:
y - The y coordinate.
Returns:
The updated y coordinate.

getLinePath

public GeneralPath getLinePath()
Get the current line path to be drawn.

Returns:
The current line path to be drawn.

setLinePath

public void setLinePath(GeneralPath newLinePath)
Set the line path to draw.

Parameters:
newLinePath - Set the line path to draw.

fillPath

public void fillPath(int windingRule)
              throws IOException
Fill the path.

Parameters:
windingRule - The winding rule this path will use.
Throws:
IOException - If there is an IO error while filling the path.

setStroke

public void setStroke(BasicStroke newStroke)
This will set the current stroke.

Parameters:
newStroke - The current stroke.

getStroke

public BasicStroke getStroke()
This will return the current stroke.

Returns:
The current stroke.

strokePath

public void strokePath()
                throws IOException
Stroke the path.

Throws:
IOException - If there is an IO error while stroking the path.

colorChanged

@Deprecated
public void colorChanged(boolean bStroking)
                  throws IOException
Deprecated. 

Called when the color changed.

Parameters:
bStroking - true for the stroking color, false for the non-stroking color
Throws:
IOException - if an I/O error occurs

transformedPoint

public Point2D.Double transformedPoint(double x,
                                       double y)
use the current transformation matrix to transform a single point.

Parameters:
x - x-coordinate of the point to be transform
y - y-coordinate of the point to be transform
Returns:
the transformed coordinates as Point2D.Double

setClippingPath

public void setClippingPath(int windingRule)
Set the clipping Path.

Parameters:
windingRule - The winding rule this path will use.

drawImage

public void drawImage(Image awtImage,
                      AffineTransform at)
Draw the AWT image. Called by Invoke. Moved into PageDrawer so that Invoke doesn't have to reach in here for Graphics as that breaks extensibility.

Parameters:
awtImage - The image to draw.
at - The transformation to use when drawing.

SHFill

public void SHFill(COSName ShadingName)
            throws IOException
Deprecated. use {@link #shFill(COSName)) instead.

Fill with Shading. Called by SHFill operator.

Parameters:
ShadingName - The name of the Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

shFill

public void shFill(COSName shadingName)
            throws IOException
Fill with Shading. Called by SHFill operator.

Parameters:
shadingName - The name of the Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the clipping area.

SHFill_Function

protected void SHFill_Function(PDShading Shading)
                        throws IOException
Fill with a Function-based gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_Axial

protected void SHFill_Axial(PDShading Shading)
                     throws IOException
Fill with an Axial Shading. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_Radial

protected void SHFill_Radial(PDShading Shading)
                      throws IOException
Fill with a Radial gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_FreeGourad

protected void SHFill_FreeGourad(PDShading Shading)
                          throws IOException
Fill with a Free-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_LatticeGourad

protected void SHFill_LatticeGourad(PDShading Shading)
                             throws IOException
Fill with a Lattice-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_CoonsPatch

protected void SHFill_CoonsPatch(PDShading Shading)
                          throws IOException
Fill with a Coons patch mesh If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.

SHFill_TensorPatch

protected void SHFill_TensorPatch(PDShading Shading)
                           throws IOException
Fill with a Tensor-product patch mesh. If extending the class, override this and its siblings, not the public SHFill method.

Parameters:
Shading - The Shading Dictionary to use for this fill instruction.
Throws:
IOException - If there is an IO error while shade-filling the path/clipping area.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.