Satsuma
a delicious .NET graph library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Pages
Public Member Functions | Properties | List of all members
Satsuma.Drawing.GraphDrawer Class Reference

Draws a graph on a Graphics. More...

Public Member Functions

void Draw (Graphics graphics, Matrix matrix=null)
 Draws the graph. More...
 
void Draw (Graphics graphics, RectangleF box)
 Draws the graph to fit the given bounding box. More...
 
Bitmap Draw (int width, int height, Color backColor, bool antialias=true, PixelFormat pixelFormat=PixelFormat.Format32bppArgb)
 Draws the graph to a new bitmap and returns the bitmap. More...
 
 GraphDrawer ()
 

Properties

Func< Arc, Pen > ArcPen [get, set]
 Assigns a pen to each arc. More...
 
Pen DirectedPen [get, set]
 The pen used for directed arcs. More...
 
IGraph Graph [get, set]
 The graph to draw. More...
 
Func< Node, string > NodeCaption [get, set]
 Assigns its caption to a node. More...
 
Func< Node, PointF > NodePosition [get, set]
 Assigns its position to a node. More...
 
Func< Node, NodeStyleNodeStyle [get, set]
 Assigns its style to a node. More...
 
Pen UndirectedPen [get, set]
 The pen used for undirected arcs. More...
 

Detailed Description

Draws a graph on a Graphics.

Example:

var graph = new CompleteGraph(7);
// compute a nice layout of the graph
var layout = new ForceDirectedLayout(graph);
layout.Run();
// draw the graph using the computed layout
var nodeShape = new NodeShape(NodeShapeKind.Diamond, new PointF(40, 40));
var nodeStyle = new NodeStyle { Brush = Brushes.Yellow, Shape = nodeShape };
var drawer = new GraphDrawer()
{
Graph = graph,
NodePositions = (node => (PointF)layout.NodePositions[node]),
NodeCaptions = (node => graph.GetNodeIndex(node).ToString()),
NodeStyles = (node => nodeStyle)
};
drawer.Draw(300, 300, Color.White).Save(@"c:\graph.png", ImageFormat.Png);

Definition at line 195 of file Drawing.cs.

Constructor & Destructor Documentation

Satsuma.Drawing.GraphDrawer.GraphDrawer ( )

Definition at line 222 of file Drawing.cs.

Member Function Documentation

void Satsuma.Drawing.GraphDrawer.Draw ( Graphics  graphics,
Matrix  matrix = null 
)

Draws the graph.

Parameters
matrixThe transformation matrix to be applied to the node positions (but not to the node and arc shapes). If null, the identity matrix is used.

Definition at line 236 of file Drawing.cs.

void Satsuma.Drawing.GraphDrawer.Draw ( Graphics  graphics,
RectangleF  box 
)

Draws the graph to fit the given bounding box.

Parameters
boxThe desired bounding box for the drawn graph.

Definition at line 270 of file Drawing.cs.

Bitmap Satsuma.Drawing.GraphDrawer.Draw ( int  width,
int  height,
Color  backColor,
bool  antialias = true,
PixelFormat  pixelFormat = PixelFormat.Format32bppArgb 
)

Draws the graph to a new bitmap and returns the bitmap.

Parameters
widthThe width of the bitmap.
heightThe height of the bitmap.
backColorThe background color for the bitmap.
antialiasSpecifies whether anti-aliasing should take place when drawing.
pixelFormatThe pixel format of the bitmap. Default value: 32-bit ARGB.

Definition at line 308 of file Drawing.cs.

Property Documentation

Func<Arc, Pen> Satsuma.Drawing.GraphDrawer.ArcPen
getset

Assigns a pen to each arc.

Default value: assign DirectedPen to directed arcs, and UndirectedPen to edges.

Definition at line 212 of file Drawing.cs.

Pen Satsuma.Drawing.GraphDrawer.DirectedPen
getset

The pen used for directed arcs.

Default value: a black pen with an arrow end. Unused if ArcPens is set to a custom value.

Definition at line 216 of file Drawing.cs.

IGraph Satsuma.Drawing.GraphDrawer.Graph
getset

The graph to draw.

Definition at line 198 of file Drawing.cs.

Func<Node, string> Satsuma.Drawing.GraphDrawer.NodeCaption
getset

Assigns its caption to a node.

Default value: assign the empty string (i.e. no caption) to each node.

Definition at line 203 of file Drawing.cs.

Func<Node, PointF> Satsuma.Drawing.GraphDrawer.NodePosition
getset

Assigns its position to a node.

Definition at line 200 of file Drawing.cs.

Func<Node, NodeStyle> Satsuma.Drawing.GraphDrawer.NodeStyle
getset

Assigns its style to a node.

Default value: assign a default NodeStyle to each node.

Warning
This function is called lots of times (at least twice for each arc). Avoid creating a NodeStyle object on each call. Return pre-made objects from some collection instead.

Definition at line 209 of file Drawing.cs.

Pen Satsuma.Drawing.GraphDrawer.UndirectedPen
getset

The pen used for undirected arcs.

Default value: Pens.Black. Unused if ArcPen is set to a custom value.

Definition at line 220 of file Drawing.cs.


The documentation for this class was generated from the following file: