Documentation
¶
Overview ¶
Package flow implements a flow chart
Index ¶
- Variables
- func AllocEdgeID(t string) string
- func AllocNodeID(t string) string
- func AllocPadID(t string) string
- type DrawCommand
- type DrawEdgeCmd
- type DrawNodeCmd
- type DrawObject
- type DrawPadCmd
- type Edge
- type Layout
- func (fl *Layout) DeleteNode(n Node)
- func (fl *Layout) DisplayList() (min, max [2]float64, dl []DrawCommand, err error)
- func (fl *Layout) Dump() []NodePosition
- func (fl *Layout) MoveNode(n Node, x, y float64)
- func (fl *Layout) Node(n Node) *NodeLayout
- func (fl *Layout) Pad(p Pad) *PadLayout
- func (fl *Layout) RecomputePadPositions(n Node)
- type Node
- type NodeLayout
- type NodePosition
- type NodeSide
- type Pad
- type PadLayout
- type SEdge
- type SNode
- func (sn *SNode) AppendPad(pad Pad)
- func (sn *SNode) AppendSPad(t string, side NodeSide, sideAmt float64)
- func (sn *SNode) LinkPads(toNode Node, fromPad, toPad Pad) (Edge, error)
- func (sn *SNode) NodeHeadline() string
- func (sn *SNode) NodeID() string
- func (sn *SNode) Pads() []Pad
- func (sn *SNode) Size() (float64, float64)
- type SPad
- func (sp *SPad) ConnectFrom(e Edge) error
- func (sp *SPad) ConnectTo(e Edge) error
- func (sp *SPad) Disconnect(del Edge)
- func (sp *SPad) DisconnectAll()
- func (sp *SPad) EndEdges() []Edge
- func (sp *SPad) PadColor() (float64, float64, float64)
- func (sp *SPad) PadID() string
- func (sp *SPad) Parent() Node
- func (sp *SPad) Positioning() (NodeSide, float64)
- func (sp *SPad) SetPadColor(r, g, b float64)
- func (sp *SPad) Size() (float64, float64)
- func (sp *SPad) StartEdges() []Edge
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyLinked = errors.New("pads already linked")
var ErrIsRoot = errors.New("cannot delete the root node")
ErrIsRoot is returned if deletion of the root node is attempted.
var ErrSelfLink = errors.New("cannot link to self")
Functions ¶
func AllocEdgeID ¶
func AllocNodeID ¶
func AllocPadID ¶
Types ¶
type DrawCommand ¶
type DrawCommand interface {
DrawObject() DrawObject
}
type DrawEdgeCmd ¶
func (DrawEdgeCmd) DrawObject ¶
func (c DrawEdgeCmd) DrawObject() DrawObject
type DrawNodeCmd ¶
type DrawNodeCmd struct { Node Node Layout *NodeLayout }
func (DrawNodeCmd) DrawObject ¶
func (c DrawNodeCmd) DrawObject() DrawObject
type DrawObject ¶
type DrawObject uint8
const ( DrawNode DrawObject = iota DrawPad DrawEdge )
Valid DrawObject types.
type DrawPadCmd ¶
func (DrawPadCmd) DrawObject ¶
func (c DrawPadCmd) DrawObject() DrawObject
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout keeps track of state describing how elements of a flowchart should be positioned.
func NewLayout ¶
func NewLayout() *Layout
NewLayout constructs a new layout controller, to keep track of the position and compute the draw order of flowchart nodes.
func (*Layout) DeleteNode ¶ added in v0.3.0
DeleteNode removes a node from the layout, destroying all edges to other nodes in the layout.
func (*Layout) DisplayList ¶
func (fl *Layout) DisplayList() (min, max [2]float64, dl []DrawCommand, err error)
DisplayList returns a list of drawing commands for rendering the layout. The bounds of all objects in the layout are also returned.
func (*Layout) Dump ¶ added in v0.4.1
func (fl *Layout) Dump() []NodePosition
Dump returns a list of all nodes and their positions.
func (*Layout) Node ¶
func (fl *Layout) Node(n Node) *NodeLayout
Node returns the object storing the position of a node.
func (*Layout) RecomputePadPositions ¶ added in v0.6.2
RecomputePadPositions should be called by the user after the position of any pad on the node changes.
type NodeLayout ¶
type NodeLayout struct {
X, Y float64
}
NodeLayout describes the layout state of a flowchart node.
func (*NodeLayout) Pos ¶
func (fns *NodeLayout) Pos() (float64, float64)
type NodePosition ¶ added in v0.4.1
type NodePosition struct { Pos NodeLayout Node Node }
type Pad ¶
type Pad interface { PadID() string Size() (float64, float64) Parent() Node // Positioning returns the side the pad should be positioned on its node, // as well as how far down the axis from the leftmost part of the side. Positioning() (NodeSide, float64) StartEdges() []Edge EndEdges() []Edge Disconnect(del Edge) DisconnectAll() ConnectTo(Edge) error ConnectFrom(Edge) error }
Pad describes a connection point on a node.
type PadLayout ¶
type PadLayout struct {
X, Y float64
}
PadLayout describes the layout state of a flowchart pad.
type SEdge ¶
type SEdge struct {
// contains filtered or unexported fields
}
func NewSEdgeWithID ¶ added in v0.4.2
func (*SEdge) Disconnect ¶ added in v0.3.0
func (se *SEdge) Disconnect()
type SNode ¶
type SNode struct { Headline string // contains filtered or unexported fields }
func (*SNode) NodeHeadline ¶
type SPad ¶
type SPad struct {
// contains filtered or unexported fields
}
func (*SPad) ConnectFrom ¶
func (*SPad) Disconnect ¶ added in v0.3.0
func (*SPad) DisconnectAll ¶ added in v0.3.0
func (sp *SPad) DisconnectAll()