org.foray.graphic.batik
Class PDFGraphics2D

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D
          extended by org.apache.batik.ext.awt.g2d.AbstractGraphics2D
              extended by org.foray.graphic.batik.PDFGraphics2D
All Implemented Interfaces:
Cloneable

public class PDFGraphics2D
extends org.apache.batik.ext.awt.g2d.AbstractGraphics2D

A Graphics2D implementation used by Batik to render two-dimensional objects (the SVG image) into a PDF document.


Field Summary
static byte QTY_ELEMENTS_CUBIC
          Constant indicating the number of elements in a cubic element, that is, 6.
static byte QTY_ELEMENTS_LINEAR
          Constant indicating the number of elements in a linear element, that is, 2.
static byte QTY_ELEMENTS_QUAD
          Constant indicating the number of elements in a quad element, that is, 4.
 
Fields inherited from class org.apache.batik.ext.awt.g2d.AbstractGraphics2D
gc, textAsShapes
 
Constructor Summary
PDFGraphics2D(boolean textAsShapes, org.w3c.dom.svg.SVGDocument svgDocument, org.axsl.font.FontConsumer fontConsumer, org.apache.commons.logging.Log logger, org.axsl.graphic.output.GraphicOutputContext pdfContext, OutputStream outputStream)
          Create a new PDFGraphics2D with the given pdf document info.
PDFGraphics2D(PDFGraphics2D g)
          This constructor supports the create method.
 
Method Summary
 void addLink(org.axsl.pdf.PdfPage pdfPage, Shape bounds, AffineTransform trans, String dest, boolean externalLink)
          This is a pdf specific method used to add a link to the pdf document.
protected  void applyColor(Color color, boolean fill)
          Apply a color to the document.
protected  void applyPaint(Paint paint, boolean fill)
          Apply a paint to the document.
protected  void applyStroke(Stroke stroke)
          Apply a stroke to the document.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
           
 Graphics create()
           
 void dispose()
           
protected  void doDrawing(boolean fill, boolean stroke, boolean nonzero)
          Add the commands to do the actual drawing.
 void draw(Shape s)
           
 boolean drawImage(Image img, int x, int y, ImageObserver observer)
           
 boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
           
 void drawRenderableImage(RenderableImage img, AffineTransform xform)
           
 void drawRenderedImage(RenderedImage img, AffineTransform xform)
           
 void drawString(AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(String s, float x, float y)
           
 void fill(Shape s)
           
 GraphicsConfiguration getDeviceConfiguration()
           
 FontMetrics getFontMetrics(Font f)
           
 boolean ioErrorFound()
          Indicates whether any I/O errors were found while writing to the output stream.
static String matrixToString(double[] theMatrix, int numElements)
          Converts a matrix of decimal values to its PDF representation.
static String octalMatrixToString(double[] theMatrix)
          Converts a matrix of octal values to its PDF representation.
 void setGraphicContext(org.apache.batik.ext.awt.g2d.GraphicContext c)
          Sets the graphic context.
 void setOverrideFontState(org.axsl.font.output.FontPdf infont, float size)
          Sets the override font and size.
 void setXORMode(Color c1)
           
protected  void writeClip(Shape s)
          Clip the document to a specific shape.
 
Methods inherited from class org.apache.batik.ext.awt.g2d.AbstractGraphics2D
addRenderingHints, clearRect, clip, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getClip, getClipBounds, getColor, getComposite, getFont, getFontRenderContext, getGraphicContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setClip, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QTY_ELEMENTS_CUBIC

public static final byte QTY_ELEMENTS_CUBIC
Constant indicating the number of elements in a cubic element, that is, 6.

See Also:
Constant Field Values

QTY_ELEMENTS_QUAD

public static final byte QTY_ELEMENTS_QUAD
Constant indicating the number of elements in a quad element, that is, 4.

See Also:
Constant Field Values

QTY_ELEMENTS_LINEAR

public static final byte QTY_ELEMENTS_LINEAR
Constant indicating the number of elements in a linear element, that is, 2.

See Also:
Constant Field Values
Constructor Detail

PDFGraphics2D

public PDFGraphics2D(boolean textAsShapes,
                     org.w3c.dom.svg.SVGDocument svgDocument,
                     org.axsl.font.FontConsumer fontConsumer,
                     org.apache.commons.logging.Log logger,
                     org.axsl.graphic.output.GraphicOutputContext pdfContext,
                     OutputStream outputStream)
              throws org.axsl.graphic.GraphicException
Create a new PDFGraphics2D with the given pdf document info. This is used to create a Graphics object for use inside an already existing document.

Parameters:
textAsShapes - Set this to true so that text will be rendered using curves and not the font.
svgDocument - The SVG document to be drawn.
fontConsumer - The font consumer for this document.
logger - The logger.
pdfContext - The PDF context in which this content is being written.
outputStream - The output stream to which this processor writes its PDF output.
Throws:
org.axsl.graphic.GraphicException - If there is no graphical environment available.

PDFGraphics2D

public PDFGraphics2D(PDFGraphics2D g)
This constructor supports the create method.

Parameters:
g - The encapsulated image.
Method Detail

octalMatrixToString

public static String octalMatrixToString(double[] theMatrix)
Converts a matrix of octal values to its PDF representation.

Parameters:
theMatrix - The matrix to be converted.
Returns:
The PDF representation of the matrix.

matrixToString

public static String matrixToString(double[] theMatrix,
                                    int numElements)
Converts a matrix of decimal values to its PDF representation.

Parameters:
theMatrix - The matrix to be converted.
numElements - The number of elements in the matrix to be included in the output.
Returns:
The PDF representation of the matrix.

setGraphicContext

public void setGraphicContext(org.apache.batik.ext.awt.g2d.GraphicContext c)
Sets the graphic context.

Parameters:
c - The new graphic context.

setOverrideFontState

public void setOverrideFontState(org.axsl.font.output.FontPdf infont,
                                 float size)
Sets the override font and size.

Parameters:
infont - The new override font.
size - The new override font size.

create

public Graphics create()
Specified by:
create in class Graphics

addLink

public void addLink(org.axsl.pdf.PdfPage pdfPage,
                    Shape bounds,
                    AffineTransform trans,
                    String dest,
                    boolean externalLink)
This is a pdf specific method used to add a link to the pdf document.

Parameters:
pdfPage - The page on which the link should be placed.
bounds - The location of the link.
trans - The affine transform.
dest - The name of the destination.
externalLink - Set to true if the link is to an external document.

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         ImageObserver observer)
Specified by:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         ImageObserver observer)
Specified by:
drawImage in class Graphics

dispose

public void dispose()
Specified by:
dispose in class Graphics

draw

public void draw(Shape s)
Specified by:
draw in class Graphics2D

writeClip

protected void writeClip(Shape s)
Clip the document to a specific shape.

Parameters:
s - The shape to which the document should be clipped.

applyColor

protected void applyColor(Color color,
                          boolean fill)
Apply a color to the document.

Parameters:
color - The color to be applied.
fill - Set to true if the color is for fill, false if for stroke.

applyPaint

protected void applyPaint(Paint paint,
                          boolean fill)
Apply a paint to the document.

Parameters:
paint - The paint to be applied.
fill - Set to true if the paint is for fill, false if for stroke.

applyStroke

protected void applyStroke(Stroke stroke)
Apply a stroke to the document.

Parameters:
stroke - The stroke to be applied.

drawRenderedImage

public void drawRenderedImage(RenderedImage img,
                              AffineTransform xform)
Specified by:
drawRenderedImage in class Graphics2D

drawRenderableImage

public void drawRenderableImage(RenderableImage img,
                                AffineTransform xform)
Specified by:
drawRenderableImage in class Graphics2D

drawString

public void drawString(String s,
                       float x,
                       float y)
Specified by:
drawString in class Graphics2D

drawString

public void drawString(AttributedCharacterIterator iterator,
                       float x,
                       float y)
Specified by:
drawString in class Graphics2D

fill

public void fill(Shape s)
Specified by:
fill in class Graphics2D

doDrawing

protected void doDrawing(boolean fill,
                         boolean stroke,
                         boolean nonzero)
Add the commands to do the actual drawing.

Parameters:
fill - Set to true if the item should be filled.
stroke - Set to true if the item should be stroked.
nonzero - Set to true to use the nonzero winding number rule.

getDeviceConfiguration

public GraphicsConfiguration getDeviceConfiguration()
Specified by:
getDeviceConfiguration in class Graphics2D

getFontMetrics

public FontMetrics getFontMetrics(Font f)
Specified by:
getFontMetrics in class Graphics

setXORMode

public void setXORMode(Color c1)
Specified by:
setXORMode in class Graphics

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Specified by:
copyArea in class Graphics

ioErrorFound

public boolean ioErrorFound()
Indicates whether any I/O errors were found while writing to the output stream.

Returns:
True iff there were I/O errors while writing to the output stream.


Copyright © 2017. All rights reserved.