jcckit.renderer
Class SVGRenderer

java.lang.Object
  extended byjcckit.renderer.SVGRenderer
All Implemented Interfaces:
GraphicalCompositeRenderer, OvalRenderer, PolygonRenderer, RectangleRenderer, Renderer, TextRenderer

public class SVGRenderer
extends java.lang.Object
implements GraphicalCompositeRenderer, PolygonRenderer, OvalRenderer, TextRenderer, RectangleRenderer

Renderer creating Scalable Vector Graphics (SVG) from GraphicalElements. SVG is an XML-based standard for vector graphics as recommended by W3C.

There is no coordinate transformation of GraphPoints except that the sign of the y-coordinate is flipped because in SVG the y-axis points downwards.

The renderer writes the XML elements into a StringBuffer. An appropriated header and root element has to be written elsewhere (e.g. by the class SVGPlotter).

Shapes will be outlined in black if neither a fill color nor a line color is defined. A zero line thickness is translated into a stroke width of 10-6.

The Java standard font names Serif, SansSerif, and Monospaced are mapped onto the SVG font families serif, sans-serif, and monospace, respectively. The default font family is sans-serif. The default font color is black and the default font size is 1% of the paper size (as specified in the constructor).

Author:
Franz-Josef Elmer

Constructor Summary
SVGRenderer()
           
 
Method Summary
 void finishRendering(GraphicalComposite composite)
          Ends renderering of the specified composite.
 SVGRenderer init(java.lang.StringBuffer buffer, int initialIndentLevel, double paperSize)
          Initializes this instance.
 void render(Oval oval)
          Renders an oval.
 void render(Polygon polygon)
          Renders a polygon.
 void render(Rectangle rectangle)
          Renders a rectangle.
 void render(Text text)
          Renders text.
 void startRendering(GraphicalComposite composite)
          Starts renderering of the specified composite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGRenderer

public SVGRenderer()
Method Detail

init

public SVGRenderer init(java.lang.StringBuffer buffer,
                        int initialIndentLevel,
                        double paperSize)
Initializes this instance.

Parameters:
buffer - The buffer into which the XML elements are written.
initialIndentLevel - Initial level of indentation. Nested XML elements are indented.
paperSize - The size of the paper. It is needed to determine the default font size.
Returns:
this instance.

startRendering

public void startRendering(GraphicalComposite composite)
Starts renderering of the specified composite. The g element of SVG is used for this purpose.

If composite has a ClippingShape a clip-path attribute is added with an URL which points onto a clipPath element. The id of this element is of the form pathnumber where number is an index counting all clip paths starting at zero. The clip path is defined by a rect element determined by the bounding box of the clipping shape.

Specified by:
startRendering in interface GraphicalCompositeRenderer

finishRendering

public void finishRendering(GraphicalComposite composite)
Ends renderering of the specified composite. Closes the g element.

Specified by:
finishRendering in interface GraphicalCompositeRenderer

render

public void render(Polygon polygon)
Renders a polygon. Depending on whether polygon is closed or not an SVG polygon or polyline element will be created.

Specified by:
render in interface PolygonRenderer

render

public void render(Rectangle rectangle)
Renders a rectangle. An SVG rect element is created.

Specified by:
render in interface RectangleRenderer

render

public void render(Oval oval)
Renders an oval. An SVG ellipse element is created.

Specified by:
render in interface OvalRenderer

render

public void render(Text text)
Renders text. An SVG text element is created.

Specified by:
render in interface TextRenderer