JGraph
v5.13.0.0


com.jgraph.io.svg
Class SVGGraphWriter

java.lang.Object
  extended by com.jgraph.io.svg.SVGGraphWriter

public class SVGGraphWriter
extends Object


Field Summary
protected  SVGEdgeWriter edgeFactory
          Holds the object that creates the SVG code for edges.
static double FONT_PROPORTION_FACTOR
          The assumes proportion between the font height and the average character width.
protected  Map gradients
          Holds the gradients created dynamically during the rendering process and added later to the defs part of the SVG output.
static Font TITLE_FONT
          Specifies the font used for the title of the diagram.
static String TITLE_HEXCOLOR
          Specifies the color the diagram title.
static int TITLE_VSPACING
          Specifies the spacing between the title and the diagram.
protected  SVGVertexWriter vertexFactory
          Holds object that creates the SVG code for vertices.
protected  Rectangle viewBox
          Holds the bounds of the graph.
 
Constructor Summary
SVGGraphWriter()
           
 
Method Summary
protected  Node createDropShadowFilter(Document document, int fuzziness, int dx, int dy)
          This implements the official recommended way of a drop shadow.
protected  Node createGradient(Document document, String id, String startColor, String endColor)
          Creates a new gradient element to be used my multiple cells.
protected  Node createNode(Document document, String title, GraphLayoutCache cache, int inset)
           
protected  Node createRoot(Document document, double w, double h, int inset)
          Creates the root SVG node with the basic information.
 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.
 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.
 Node getGradient(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.
 void write(OutputStream out, String title, GraphLayoutCache cache, int inset)
          Writes the SVG.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TITLE_FONT

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


TITLE_VSPACING

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


FONT_PROPORTION_FACTOR

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


TITLE_HEXCOLOR

public static String TITLE_HEXCOLOR
Specifies the color the diagram title.


vertexFactory

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


edgeFactory

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


gradients

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


viewBox

protected Rectangle viewBox
Holds the bounds of the graph.

Constructor Detail

SVGGraphWriter

public SVGGraphWriter()
Method Detail

write

public void write(OutputStream out,
                  String title,
                  GraphLayoutCache cache,
                  int inset)
Writes the SVG.


createNode

protected Node createNode(Document document,
                          String title,
                          GraphLayoutCache cache,
                          int inset)
                   throws ParserConfigurationException
Throws:
ParserConfigurationException

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

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

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

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

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.


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

JGraph
v5.13.0.0


Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.