com.jgraph.io.svg

Class SVGGraphWriter

public class SVGGraphWriter extends Object

Field Summary
protected SVGEdgeWriteredgeFactory
Holds the object that creates the SVG code for edges.
static doubleFONT_PROPORTION_FACTOR
The assumes proportion between the font height and the average character width.
protected Mapgradients
Holds the gradients created dynamically during the rendering process and added later to the defs part of the SVG output.
static FontTITLE_FONT
Specifies the font used for the title of the diagram.
static StringTITLE_HEXCOLOR
Specifies the color the diagram title.
static intTITLE_VSPACING
Specifies the spacing between the title and the diagram.
protected SVGVertexWritervertexFactory
Holds object that creates the SVG code for vertices.
protected RectangleviewBox
Holds the bounds of the graph.
Method Summary
protected NodecreateDropShadowFilter(Document document, int fuzziness, int dx, int dy)
This implements the official recommended way of a drop shadow.
protected NodecreateGradient(Document document, String id, String startColor, String endColor)
Creates a new gradient element to be used my multiple cells.
protected NodecreateNode(Document document, String title, GraphLayoutCache cache, int inset)
protected NodecreateRoot(Document document, double w, double h, int inset)
Creates the root SVG node with the basic information.
NodecreateShapeNode(Document document, int shapeType, Rectangle2D bounds, double dx, double dy, String hexBackground, String hexGradient, String hexLineColor, float lineWidth, double opacity, boolean dropShadow)
Creates a rect or ellipse element based on the specified values.
NodecreateTextNode(Document document, String label, String align, Font font, String hexFontColor, int middleX, int y)
Creates a new text element for the specified details.
NodegetGradient(Document document, String startColor, String endColor)
Returns or creates a gradient object for the specified colors.
Object[]getLabels(CellView view)
Returns the labels for a graph cell as an object array.
voidwrite(OutputStream out, String title, GraphLayoutCache cache, int inset)
Writes the SVG.

Field Detail

edgeFactory

protected SVGEdgeWriter edgeFactory
Holds the object that creates the SVG code for edges.

FONT_PROPORTION_FACTOR

public static double FONT_PROPORTION_FACTOR
The assumes proportion between the font height and the average character width.

gradients

protected Map gradients
Holds the gradients created dynamically during the rendering process and added later to the defs part of the SVG output.

TITLE_FONT

public static Font TITLE_FONT
Specifies the font used for the title of the diagram.

TITLE_HEXCOLOR

public static String TITLE_HEXCOLOR
Specifies the color the diagram title.

TITLE_VSPACING

public static int TITLE_VSPACING
Specifies the spacing between the title and the diagram.

vertexFactory

protected SVGVertexWriter vertexFactory
Holds object that creates the SVG code for vertices.

viewBox

protected Rectangle viewBox
Holds the bounds of the graph.

Method Detail

createDropShadowFilter

protected Node createDropShadowFilter(Document document, int fuzziness, int dx, int dy)
This implements the official recommended way of a drop shadow. However, it does not work with the SVG Plugin. We use a second shape behind the main shape as a workaround. This element is currently not added to the SVG output. See createNodeShape.

createGradient

protected Node createGradient(Document document, String id, String startColor, String endColor)
Creates a new gradient element to be used my multiple cells.

Parameters: document id startColor endColor

Returns: a node detailing the gradient on a cell element

createNode

protected Node createNode(Document document, String title, GraphLayoutCache cache, int inset)

createRoot

protected Node createRoot(Document document, double w, double h, int inset)
Creates the root SVG node with the basic information.

Parameters: document w h inset

Returns: a SVG node describing the SVG diagram

createShapeNode

public Node createShapeNode(Document document, int shapeType, Rectangle2D bounds, double dx, double dy, String hexBackground, String hexGradient, String hexLineColor, float lineWidth, double opacity, boolean dropShadow)
Creates a rect or ellipse element based on the specified values.

Parameters: document shapeType bounds dx dy hexBackground hexGradient hexLineColor lineWidth opacity dropShadow

Returns: a node detailing the shape on a vertex element

createTextNode

public Node createTextNode(Document document, String label, String align, Font font, String hexFontColor, int middleX, int y)
Creates a new text element for the specified details.

Parameters: document label align font hexFontColor middleX y

Returns: a node detailing the label on a cell element

getGradient

public Node getGradient(Document document, String startColor, String endColor)
Returns or creates a gradient object for the specified colors.

Parameters: document startColor endColor

Returns: a node detailing the gradient on a cell element

getLabels

public Object[] getLabels(CellView view)
Returns the labels for a graph cell as an object array.

Parameters: view

Returns: the labels displayed for the specified cell view

write

public void write(OutputStream out, String title, GraphLayoutCache cache, int inset)
Writes the SVG.
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.