org.apache.fop.render.pdf
Class SVGRenderer

java.lang.Object
  |
  +--org.apache.fop.render.pdf.SVGRenderer

public class SVGRenderer
extends java.lang.Object

Renderer that renders SVG to PDF


Field Summary
protected  java.lang.String currentFontName
          the current (internal) font name
protected  int currentFontSize
          the current font size in millipoints
protected  int currentXPosition
          the current horizontal position in millipoints from left
protected  int currentYPosition
          the current vertical position in millipoints from bottom
protected  FontState fontState
           
protected  PDFDocument pdfDoc
          the PDF Document being created
 
Constructor Summary
SVGRenderer(FontState fs, PDFDocument doc, java.lang.String font, int size, int xpos, int ypos)
          create the SVG renderer
 
Method Summary
protected  void addCircle(float cx, float cy, float r, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          Add an SVG circle Uses bezier curves to approximate the shape of a circle.
protected  void addEllipse(float cx, float cy, float rx, float ry, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          Add an SVG ellips Uses bezier curves to approximate the shape of an ellipse.
protected  void addLine(float x1, float y1, float x2, float y2, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          add a line to the current stream
protected  void addPath(java.util.Vector points, int posx, int posy, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          Adds an SVG path to the current streem.
protected  void addPolyline(java.util.Vector points, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di, boolean close)
          Adds an SVG polyline or polygon.
protected  void addRect(float x, float y, float w, float h, float rx, float ry, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          add an SVG rectangle to the current stream.
protected  float addSVGStr(FontState fs, float currentX, java.lang.String str, boolean spacing)
          Adds an svg string to the output.
protected  org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction applyStyle(org.w3c.dom.svg.SVGElement area, org.w3c.dom.svg.SVGStylable style)
           
protected  void applyTransform(org.w3c.dom.svg.SVGAnimatedTransformList trans)
           
protected  float[] calculateLastControl(float x1, float y1, float x2, float y2, float relx, float rely)
          Calculate the last control point for a bezier curve.
protected  void doDrawing(org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          Writes the drawing instruction out to the current stream depending on what type of drawing is required.
 java.lang.String getString()
           
protected  void handleGradient(java.lang.String sp, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di, boolean fill, org.w3c.dom.svg.SVGElement area)
          Handles the construction of an SVG gradient.
protected  void handleLinearGradient(org.w3c.dom.svg.SVGLinearGradientElement linear, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di, boolean fill, org.w3c.dom.svg.SVGElement area)
           
protected  void handlePattern(org.w3c.dom.svg.SVGPatternElement pattern, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di, boolean fill, org.w3c.dom.svg.SVGElement area)
           
protected  void handleRadialGradient(org.w3c.dom.svg.SVGRadialGradientElement radial, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di, boolean fill, org.w3c.dom.svg.SVGElement area)
           
protected  void handleSwitchElement(int posx, int posy, org.w3c.dom.svg.SVGSwitchElement ael)
          Handles the SVG switch element.
protected  org.w3c.dom.svg.SVGElement locateDef(java.lang.String ref, org.w3c.dom.svg.SVGElement currentElement)
          Locates a defined element in an svg document.
 void renderElement(org.w3c.dom.svg.SVGElement area, int posx, int posy)
          Main rendering selection.
 void renderGArea(org.w3c.dom.svg.SVGGElement area, int posx, int posy)
           
 void renderImage(java.lang.String href, float x, float y, float width, float height)
          Renders an svg image to the current stream.
protected  void renderSVG(org.w3c.dom.svg.SVGSVGElement svg, int x, int y)
          Renders an SVG element in an SVG document.
protected  void renderSymbol(org.w3c.dom.svg.SVGSymbolElement symbol, int x, int y)
          A symbol has a viewbox and preserve aspect ratio.
 void renderText(SVGTextElementImpl tg, float x, float y, org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
          Todo: underline, linethrough, textpath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pdfDoc

protected PDFDocument pdfDoc
the PDF Document being created

fontState

protected FontState fontState

currentFontName

protected java.lang.String currentFontName
the current (internal) font name

currentFontSize

protected int currentFontSize
the current font size in millipoints

currentYPosition

protected int currentYPosition
the current vertical position in millipoints from bottom

currentXPosition

protected int currentXPosition
the current horizontal position in millipoints from left
Constructor Detail

SVGRenderer

public SVGRenderer(FontState fs,
                   PDFDocument doc,
                   java.lang.String font,
                   int size,
                   int xpos,
                   int ypos)
create the SVG renderer
Method Detail

getString

public java.lang.String getString()

renderSVG

protected void renderSVG(org.w3c.dom.svg.SVGSVGElement svg,
                         int x,
                         int y)
Renders an SVG element in an SVG document. This renders each of the child elements.

renderGArea

public void renderGArea(org.w3c.dom.svg.SVGGElement area,
                        int posx,
                        int posy)

handleSwitchElement

protected void handleSwitchElement(int posx,
                                   int posy,
                                   org.w3c.dom.svg.SVGSwitchElement ael)
Handles the SVG switch element. The switch determines which of its child elements should be rendered according to the required extensions, required features and system language.

addLine

protected void addLine(float x1,
                       float y1,
                       float x2,
                       float y2,
                       org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
add a line to the current stream
Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
r - the red component
g - the green component
b - the blue component

addCircle

protected void addCircle(float cx,
                         float cy,
                         float r,
                         org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
Add an SVG circle Uses bezier curves to approximate the shape of a circle.

addEllipse

protected void addEllipse(float cx,
                          float cy,
                          float rx,
                          float ry,
                          org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
Add an SVG ellips Uses bezier curves to approximate the shape of an ellipse.

addRect

protected void addRect(float x,
                       float y,
                       float w,
                       float h,
                       float rx,
                       float ry,
                       org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
add an SVG rectangle to the current stream. If there are curved edges then these are rendered using bezier curves.
Parameters:
x - the x position of left edge
y - the y position of top edge
w - the width
h - the height
rx - the x radius curved edge
ry - the y radius curved edge

addPath

protected void addPath(java.util.Vector points,
                       int posx,
                       int posy,
                       org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
Adds an SVG path to the current streem. An SVG path is made up of a list of drawing instructions that are rendered out in order. Arcs don't work.

calculateLastControl

protected float[] calculateLastControl(float x1,
                                       float y1,
                                       float x2,
                                       float y2,
                                       float relx,
                                       float rely)
Calculate the last control point for a bezier curve. This is used to find the last control point for a curve where only the first control point is specified. The control point is a reflection of the first control point which results in an even smooth curve. The curve is symmetrical.

addPolyline

protected void addPolyline(java.util.Vector points,
                           org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di,
                           boolean close)
Adds an SVG polyline or polygon. A polygon is merely a closed polyline. This is made up from a set of points that straight lines are drawn between.

doDrawing

protected void doDrawing(org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
Writes the drawing instruction out to the current stream depending on what type of drawing is required.

renderImage

public void renderImage(java.lang.String href,
                        float x,
                        float y,
                        float width,
                        float height)
Renders an svg image to the current stream. This uses the FopImageFactory to load the image and then renders it.

renderSymbol

protected void renderSymbol(org.w3c.dom.svg.SVGSymbolElement symbol,
                            int x,
                            int y)
A symbol has a viewbox and preserve aspect ratio.

handleGradient

protected void handleGradient(java.lang.String sp,
                              org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di,
                              boolean fill,
                              org.w3c.dom.svg.SVGElement area)
Handles the construction of an SVG gradient. This gets the gradient element and creates the pdf info in the pdf document. The type of gradient is determined by what class the gradient element is.

handlePattern

protected void handlePattern(org.w3c.dom.svg.SVGPatternElement pattern,
                             org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di,
                             boolean fill,
                             org.w3c.dom.svg.SVGElement area)

handleLinearGradient

protected void handleLinearGradient(org.w3c.dom.svg.SVGLinearGradientElement linear,
                                    org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di,
                                    boolean fill,
                                    org.w3c.dom.svg.SVGElement area)

handleRadialGradient

protected void handleRadialGradient(org.w3c.dom.svg.SVGRadialGradientElement radial,
                                    org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di,
                                    boolean fill,
                                    org.w3c.dom.svg.SVGElement area)

applyStyle

protected org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction applyStyle(org.w3c.dom.svg.SVGElement area,
                                                                              org.w3c.dom.svg.SVGStylable style)

applyTransform

protected void applyTransform(org.w3c.dom.svg.SVGAnimatedTransformList trans)

renderElement

public void renderElement(org.w3c.dom.svg.SVGElement area,
                          int posx,
                          int posy)
Main rendering selection. This applies any transform and style and then calls the appropriate rendering method depending on the type of element.

renderText

public void renderText(SVGTextElementImpl tg,
                       float x,
                       float y,
                       org.apache.fop.render.pdf.SVGRenderer.DrawingInstruction di)
Todo: underline, linethrough, textpath

addSVGStr

protected float addSVGStr(FontState fs,
                          float currentX,
                          java.lang.String str,
                          boolean spacing)
Adds an svg string to the output. This handles the escaping of special pdf chars and deals with whitespace.

locateDef

protected org.w3c.dom.svg.SVGElement locateDef(java.lang.String ref,
                                               org.w3c.dom.svg.SVGElement currentElement)
Locates a defined element in an svg document. Either gets the element defined by its "id" in the current SVGDocument, or if the uri reference is to an external document it loads the document and returns the element.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.