DotWriter

class DotWriter(    name: String,     isDirected: Boolean,     charactersPerLine: Int,     accumulator: Appendable,     darkMode: Boolean = true,     val copyrightOwner: String = System.getProperty("user.name"))

DotWriter produces source text for dot, the widely supported graph description language. Such source text can be passed to numerous renderers, most notably Graphviz, to produce graph visualizations.

DotWriter is not able to generate every sentence recognized by dot, but it is able to access every semantic feature afforded by dot. All APIs automatically escape identifiers as necessary, always choosing to provide a minimal text when several semantically equivalent texts are available. Support is deliberately omitted for the _compass point, since omitting the compass point of a node in an edge specification is equivalent to specifying _ as the compass point.

DotWriter exposes the ability to generate dot source files through a hierarchy of contextual emitters rooted at AttributeWriter. These emitters are provided to a lambda through dependency injection, and care should be taken in the implementation of a lambda only to use the injected emitter (and not some other lexically available emitter created in an outer dynamic scope).

Author

Todd L Smith

See also

Parameters

name

The name of the graph.

isDirected

If true, then a directed graph will be generated; otherwise, an undirected graph will be generated.

charactersPerLine

The number of characters to emit per line. Only applies to formatting of block comments.

accumulator

The accumulator for the generated source code.

darkMode

If true, draw with light colors on a dark background.

copyrightOwner

This name is embedded in a copyright claim within the document.

Constructors

Link copied to clipboard
fun DotWriter(    name: String,     isDirected: Boolean,     charactersPerLine: Int,     accumulator: Appendable,     darkMode: Boolean = true,     copyrightOwner: String = System.getProperty("user.name"))

Construct a new DotWriter.

Types

Link copied to clipboard
open inner class AttributeWriter

An AttributeWriter provides the ability to write generally available dot elements, e.g., indentation, comments, identifiers, attributes, etc.

Link copied to clipboard
object Companion
Link copied to clipboard
enum CompassPoint : Enum<DotWriter.CompassPoint>

CompassPoint represents one of the compass points allowed for edge attachments to node ports. The names of the enumeration values are chosen to match dot keywords and must not be changed.

Link copied to clipboard
class DecoratedNode

DecoratedNode represents a decorated node that includes an optional port and an optional CompassPoint. It exists only for edge specification, as dot does not permit decorated nodes to appear on their own.

Link copied to clipboard

DefaultAttributeBlockType represents the scope of a default attributes block. The three supported scopes are GRAPH, NODE, and EDGE. The names of the enumeration values are chosen to match dot keywords and must not be changed.

Link copied to clipboard
inner class GraphWriter : DotWriter.AttributeWriter

A GraphWriter provides the capability of writing entire graphs, and as such is able to emit default attribute blocks, nodes, and edges.

Functions

Link copied to clipboard
fun blockComment(comment: String)

Emit a block comment, such as a copyright banner or statement of purpose.

Link copied to clipboard
fun graph(block: (DotWriter.GraphWriter) -> Unit)

Emit an entire graph.

Properties

Link copied to clipboard
val copyrightOwner: String