org.springframework.beandoc.output
Class GraphVizDecorator

java.lang.Object
  extended by org.springframework.beandoc.output.SimpleDecorator
      extended by org.springframework.beandoc.output.GraphVizDecorator
All Implemented Interfaces:
Decorator

public class GraphVizDecorator
extends SimpleDecorator

GraphVizDecorator is a configurable Decorator implementation that adds attributes to the DOM used by DotFileTransformer in generating input files for GraphViz.

Since:
1.0
Author:
Darren Davison, Marat Radchenko, Jan Tietjens

Field Summary
protected static String ATTRIBUTE_COLOUR
           
protected static String ATTRIBUTE_GRAPH_BEANSHAPE
           
protected static String ATTRIBUTE_GRAPH_CONSOLIDATED
           
protected static String ATTRIBUTE_GRAPH_FONTNAME
           
protected static String ATTRIBUTE_GRAPH_FONTSIZE
           
protected static String ATTRIBUTE_GRAPH_IGNORE
           
protected static String ATTRIBUTE_GRAPH_LABELLOCATION
           
protected static String ATTRIBUTE_GRAPH_RANK
           
protected static String ATTRIBUTE_GRAPH_RATIO
           
protected static String ATTRIBUTE_GRAPH_SIZE
           
protected static String ATTRIBUTE_GRAPH_TYPE
           
 
Fields inherited from class org.springframework.beandoc.output.SimpleDecorator
logger
 
Constructor Summary
GraphVizDecorator()
           
 
Method Summary
 void addColourBeans(String pattern, String colour)
          Add a fill colour to the beans on a graph whose name, id's or classname match the supplied string.
 void addIgnoreBeans(String pattern)
          Add a naming pattern of bean id's or bean names or classnames that should not be displayed on output.
 void addRankBeans(String pattern)
          Add a naming pattern of bean id's or bean names or classnames that should be constrained to the same rank of a graph.
protected  void decorateElement(org.jdom.Element element)
          Decorates root element with graph type attributes and each bean element as required with colour information.
 String getBeanShape()
          Default shape used to describe bean nodes on the graph.
 Map getColourBeans()
          Returns a Map keyed by bean name or class name that is used to determine the fill colour for bean descriptions in the HTML output andf on the graphing output.
 String getDefaultFillColour()
          Fill colour used for beans on graphs and keyed in the HTML documentation if no other colour is specified through pattern matching.
 String getFontName()
          The font name used on the graph nodes.
 int getFontSize()
          Font size (pt) used for node labels on graph output
 float getGraphXSize()
          The maximum length of the x-axis of the graph in inches.
 float getGraphYSize()
          The maximum length of the y-axis of the graph in inches.
 List getIgnoreBeans()
          A List of patterns representing bean names/ids or classnames that should be excluded from the output.
 char getLabelLocation()
          Label position denoting whether graph labels appear at the top or bottom of the graph.
 String getOutputType()
          The type of output that the GraphViz 'dot' program should create from the intermediate .dot files.
 List getRankBeans()
          A list of patterns of bean names or package names that determine how groups of similar beans are graphed.
 String getRatio()
          A value denoting ratio of x and y axes on the graoh output.
 void setBeanShape(String shape)
          The shape to draw bean nodes in.
 void setColourBeans(Map colours)
          A Map keyed by bean names/ids or classnames that hold colour attributes used to fill graph nodes or key the HTML output.
 void setDefaultFillColour(String colour)
          Sets the fill colour used for beans on graphs and keyed in the HTML documentation if no other colour is specified through pattern matching.
 void setFontName(String font)
          Set the font used in bean labels in graphing output.
 void setFontSize(int fontSize)
          Set the font size used in bean labels in graphing output.
 void setGraphXSize(float x)
          The maximum length of the x-axis of the graph in inches.
 void setGraphYSize(float y)
          The maximum length of the y-axis of the graph in inches.
 void setIgnoreBeans(List ignoreBeans)
          A List of patterns representing bean names/ids or classnames that should be excluded from the output documents.
 void setLabelLocation(String labelLocation)
          Determines whether graph titles will appear at the top or bottom of the graph.
 void setOutputType(String graphType)
          Determines the format of the graphing output.
 void setRankBeans(List rankBeans)
          A list of patterns of bean names or package names that determine how groups of similar beans are graphed.
 void setRatio(String ratio)
          Sets the graph ratio.
 
Methods inherited from class org.springframework.beandoc.output.SimpleDecorator
decorate, setFilter, setFilterNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_GRAPH_TYPE

protected static final String ATTRIBUTE_GRAPH_TYPE
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_FONTNAME

protected static final String ATTRIBUTE_GRAPH_FONTNAME
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_FONTSIZE

protected static final String ATTRIBUTE_GRAPH_FONTSIZE
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_SIZE

protected static final String ATTRIBUTE_GRAPH_SIZE
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_RATIO

protected static final String ATTRIBUTE_GRAPH_RATIO
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_BEANSHAPE

protected static final String ATTRIBUTE_GRAPH_BEANSHAPE
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_LABELLOCATION

protected static final String ATTRIBUTE_GRAPH_LABELLOCATION
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_CONSOLIDATED

protected static final String ATTRIBUTE_GRAPH_CONSOLIDATED
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_IGNORE

protected static final String ATTRIBUTE_GRAPH_IGNORE
See Also:
Constant Field Values

ATTRIBUTE_GRAPH_RANK

protected static final String ATTRIBUTE_GRAPH_RANK
See Also:
Constant Field Values

ATTRIBUTE_COLOUR

protected static final String ATTRIBUTE_COLOUR
See Also:
Constant Field Values
Constructor Detail

GraphVizDecorator

public GraphVizDecorator()
Method Detail

decorateElement

protected void decorateElement(org.jdom.Element element)
Decorates root element with graph type attributes and each bean element as required with colour information.

Specified by:
decorateElement in class SimpleDecorator
See Also:
SimpleDecorator.decorateElement(org.jdom.Element)

setDefaultFillColour

public void setDefaultFillColour(String colour)
Sets the fill colour used for beans on graphs and keyed in the HTML documentation if no other colour is specified through pattern matching.

Parameters:
colour - a String in the format "#AABBCC" - a standard hex triplet for the RGB values

setColourBeans

public void setColourBeans(Map colours)
A Map keyed by bean names/ids or classnames that hold colour attributes used to fill graph nodes or key the HTML output. The preferred way to modify colours is through the addColourBeans(java.lang.String, java.lang.String) convenience method.

Parameters:
colours - a Map of node fill colours for graph output. Also used to key the HTML documentation.
See Also:
addColourBeans(java.lang.String, java.lang.String)

addColourBeans

public void addColourBeans(String pattern,
                           String colour)
Add a fill colour to the beans on a graph whose name, id's or classname match the supplied string. Can be used to nicely highlight application layers or other concepts within your bean factories and application contexts if you follow a disciplined bean naming convention.

Parameters:
pattern - a String representing a pattern to match based on RegEx matching. A null value will be ignored
colour - the colour as an RGB HEX triplet to fill the bean with. May not be null

setBeanShape

public void setBeanShape(String shape)
The shape to draw bean nodes in. Ignored if setDoGraphOutput is false Common options are; See the Graphviz documentation for a full list of available shapes. The default is "ellipse"

Parameters:
shape - the shape for bean nodes in generated graphs.

setFontName

public void setFontName(String font)
Set the font used in bean labels in graphing output.

Parameters:
font - the font to use, default is "helvetica" which should work on most platforms

setFontSize

public void setFontSize(int fontSize)
Set the font size used in bean labels in graphing output.

Parameters:
fontSize - the font point size, default is 10

setLabelLocation

public void setLabelLocation(String labelLocation)
Determines whether graph titles will appear at the top or bottom of the graph. Use 't' or 'b' as required

Parameters:
labelLocation - a String representing Top ('t') or Bottom ('b'). Default is 't'.

setRatio

public void setRatio(String ratio)
Sets the graph ratio. May require some experimentation to get the most suitable output depending on the content of your bean definition files.

Adapted from the GraphViz documentation:

ratio affects layout size. There are a number of cases, depending on the settings of size and ratio;
  1. ratio was not set (null). If the drawing already fits within the given size, then nothing happens. Otherwise, the drawing is reduced uniformly enough to make the critical dimension fit.
  2. If ratio was set, there are four subcases;
    • If ratio=x where x is a floating point number, then the drawing is scaled up in one dimension to achieve the requested ratio expressed as drawing height/width. For example, ratio=2.0 makes the drawing twice as high as it is wide. Then the layout is scaled using size as in 1.
    • If ratio="auto" and the page attribute is set and the graph cannot be drawn on a single page, then size is ignored and dot computes an ideal size. In particular, the size in a given dimension will be the smallest integral multiple of the page size in that dimension which is at least half the current size. The two dimensions are then scaled independently to the new size

Parameters:
ratio - the ratio for graph output, default is "auto"
See Also:
setGraphXSize(float), setGraphYSize(float)

setGraphXSize

public void setGraphXSize(float x)
The maximum length of the x-axis of the graph in inches. Useful to set this value if the graph has to be printed to ensure it will fit on the target paper size. Used by GraphViz in conjunction with the ratio setting to determine final layout and positioning of nodes on the graph. If the corresponding value for the y-axis of the graph is not set, this value is ignored.

Parameters:
x - a float value specifying the length of the x-axis of the graph

setGraphYSize

public void setGraphYSize(float y)
The maximum length of the y-axis of the graph in inches. Useful to set this value if the graph has to be printed to ensure it will fit on the target paper size. Used by GraphViz in conjunction with the ratio setting to determine final layout and positioning of nodes on the graph. If the corresponding value for the x-axis of the graph is not set, this value is ignored.

Parameters:
y - a float value specifying the length of the y-axis of the graph

setOutputType

public void setOutputType(String graphType)
Determines the format of the graphing output. Some options are;

Parameters:
graphType - the output format for graphs. Default is png which is a very efficient format in terms of file size and highly recommended over gif and jpg if your viewer supports it. Most modern browsers can display PNG files.

getIgnoreBeans

public List getIgnoreBeans()
A List of patterns representing bean names/ids or classnames that should be excluded from the output.

The returned underlying List is modifiable and will, if modified, affect subsequent calls to the ContextProcessor's process() method if you are using the tool programmatically. The preferred way to modify this list is through the addIgnoreBeans(java.lang.String) convenience method.

Returns:
a List of patterns of bean names to be excluded from graphs
See Also:
addIgnoreBeans(String)

setIgnoreBeans

public void setIgnoreBeans(List ignoreBeans)
A List of patterns representing bean names/ids or classnames that should be excluded from the output documents. The preferred way to modify this list is through the addIgnoreBeans(java.lang.String) convenience method.

Parameters:
ignoreBeans - a List of patterns of bean names to be excluded from graphs
See Also:
addIgnoreBeans(java.lang.String)

addIgnoreBeans

public void addIgnoreBeans(String pattern)
Add a naming pattern of bean id's or bean names or classnames that should not be displayed on output. Some beans (such as PropertyConfigurers and MessageSources) are auxilliary and you may wish to exclude them from documents to keep the output focused.

This method may be called any number of times to add different patterns to the list of ignored beans. Pattern may not be null (such a value will be ignored).

Parameters:
pattern - a String representing a pattern to match. The pattern uses RegEx matching. May not be null

setRankBeans

public void setRankBeans(List rankBeans)
A list of patterns of bean names or package names that determine how groups of similar beans are graphed. Specifically, a ranked set of beans will all appear on the same rank (row) of a graph.

Parameters:
rankBeans - the List of patterns of grouped beans

addRankBeans

public void addRankBeans(String pattern)
Add a naming pattern of bean id's or bean names or classnames that should be constrained to the same rank of a graph.

This method may be called any number of times to add different patterns to the list of ignored beans. Pattern may not be null (such a value will be ignored).

Parameters:
pattern - a String representing a pattern to match. The pattern uses RegEx matching. May not be null

getColourBeans

public Map getColourBeans()
Returns a Map keyed by bean name or class name that is used to determine the fill colour for bean descriptions in the HTML output andf on the graphing output.

Returns:
the Map used to describe fill colours of beans, keyed by bean name or classname
See Also:
getDefaultFillColour()

getOutputType

public String getOutputType()
The type of output that the GraphViz 'dot' program should create from the intermediate .dot files. Default is PNG. See setOutputType(java.lang.String) for some of the optional formats supported

Returns:
the type of graph output that will be generated from the .dot files
See Also:
setOutputType(java.lang.String)

getDefaultFillColour

public String getDefaultFillColour()
Fill colour used for beans on graphs and keyed in the HTML documentation if no other colour is specified through pattern matching.

Returns:
the default fill colour for beans that don't match any pattern used for determining fill colours
See Also:
addColourBeans(String, String), getColourBeans()

getBeanShape

public String getBeanShape()
Default shape used to describe bean nodes on the graph. See setBeanShape(java.lang.String) for some of the options

Returns:
the shape GraphViz should use to display beans
See Also:
setBeanShape(java.lang.String)

getFontName

public String getFontName()
The font name used on the graph nodes. Must be a known font on the fontpath for the local machine. Basically this will pretty much work for any font you have installed on Win32 platforms, but may give unexpected results on Unix/Linux type platforms depending on your font server setup.

If you want to use a font that GraphViz can't find on your system, set a FONTPATH environment variable pointing to the location of your font directories.

Returns:
the font name used for bean labels on the graph

getFontSize

public int getFontSize()
Font size (pt) used for node labels on graph output

Returns:
the font size used for bean labels on the graph

getLabelLocation

public char getLabelLocation()
Label position denoting whether graph labels appear at the top or bottom of the graph.

Returns:
't' or 'b' to denote top or bottom respectively

getRatio

public String getRatio()
A value denoting ratio of x and y axes on the graoh output. Used in conjunction with setGraphXSize(float) and setGraphYSize(float) to determine final size and layout.

Returns:
the ratio to use for the graph
See Also:
getGraphXSize(), getGraphYSize()

getGraphXSize

public float getGraphXSize()
The maximum length of the x-axis of the graph in inches. Useful to set this value if the graph has to be printed to ensure it will fit on the target paper size. Used by GraphViz in conjunction with the ratio setting to determine final layout and positioning of nodes on the graph. If the corresponding value for the y-axis of the graph is not set, this value is ignored.

Returns:
a float value for the length of the x-axis of a graph, or -1 if the value is not set.
See Also:
setGraphXSize(float), getGraphYSize(), setGraphYSize(float)

getGraphYSize

public float getGraphYSize()
The maximum length of the y-axis of the graph in inches. Useful to set this value if the graph has to be printed to ensure it will fit on the target paper size. Used by GraphViz in conjunction with the ratio setting to determine final layout and positioning of nodes on the graph. If the corresponding value for the x-axis of the graph is not set, this value is ignored.

Returns:
a float value for the length of the y-axis of a graph, or -1 if the value is not set.
See Also:
setGraphYSize(float), getGraphXSize(), setGraphXSize(float)

getRankBeans

public List getRankBeans()
A list of patterns of bean names or package names that determine how groups of similar beans are graphed. Specifically, a ranked set of beans will all appear on the same rank (row) of a graph.

Returns:
the List of patterns of grouped beans


Copyright © 2004-2010 Spring BeanDoc. All Rights Reserved.