graph

package
v0.0.0-...-583b476 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphEdge

type GraphEdge struct {
	widget.BaseWidget

	Graph *GraphWidget

	EdgeColor color.Color

	Width float32

	Origin *GraphNode
	Target *GraphNode

	Directed bool
}

func NewGraphEdge

func NewGraphEdge(g *GraphWidget, v, u *GraphNode) *GraphEdge

func (*GraphEdge) CreateRenderer

func (e *GraphEdge) CreateRenderer() fyne.WidgetRenderer

func (*GraphEdge) R2Line

func (e *GraphEdge) R2Line() r2.Line

type GraphNode

type GraphNode struct {
	widget.BaseWidget

	Graph *GraphWidget

	// InnerSize stores size that the inner object should have, may not
	// be respected if not large enough for the object.
	InnerSize fyne.Size

	// InnerObject is the canvas object that should be drawn inside of
	// the graph node.
	InnerObject fyne.CanvasObject

	// Padding is the distance between the inner object's drawing area
	// and the box.
	Padding int

	// BoxStrokeWidth is the stroke width of the box which delineates the
	// node. Defaults to 1.
	BoxStrokeWidth float32

	// BoxFill is the fill color of the node, the inner object will be
	// drawn on top of this. Defaults to the theme.BackgroundColor().
	BoxFillColor color.Color

	// BoxStrokeColor is the stroke color of the node rectangle. Defaults
	// to theme.TextColor().
	BoxStrokeColor color.Color

	// HandleColor is the color of node handle.
	HandleColor color.Color

	// HandleStrokeWidth is the stroke width of the node handle, defaults
	// to 3.
	HandleStroke float32
}

GraphNode represents a node in the graph widget. It contains an inner widget, and also draws a border, and a "handle" that can be used to drag it around.

func NewGraphNode

func NewGraphNode(g *GraphWidget, obj fyne.CanvasObject) *GraphNode

func (*GraphNode) Center

func (n *GraphNode) Center() fyne.Position

func (*GraphNode) CreateRenderer

func (n *GraphNode) CreateRenderer() fyne.WidgetRenderer

func (*GraphNode) Cursor

func (n *GraphNode) Cursor() desktop.Cursor

func (*GraphNode) Displace

func (n *GraphNode) Displace(delta fyne.Position)

func (*GraphNode) DragEnd

func (n *GraphNode) DragEnd()

func (*GraphNode) Dragged

func (n *GraphNode) Dragged(event *fyne.DragEvent)

func (*GraphNode) MouseIn

func (n *GraphNode) MouseIn(event *desktop.MouseEvent)

func (*GraphNode) MouseMoved

func (n *GraphNode) MouseMoved(event *desktop.MouseEvent)

func (*GraphNode) MouseOut

func (n *GraphNode) MouseOut()

func (*GraphNode) R2Box

func (n *GraphNode) R2Box() r2.Box

func (*GraphNode) R2Center

func (n *GraphNode) R2Center() r2.Vec2

func (*GraphNode) R2Position

func (n *GraphNode) R2Position() r2.Vec2

type GraphWidget

type GraphWidget struct {
	widget.BaseWidget

	Offset fyne.Position

	// DesiredSize specifies the size which the graph widget should take
	// up, defaults to 800 x 600
	DesiredSize fyne.Size

	Nodes map[string]*GraphNode
	Edges map[string]*GraphEdge
}

func NewGraph

func NewGraph() *GraphWidget

func (*GraphWidget) CreateRenderer

func (g *GraphWidget) CreateRenderer() fyne.WidgetRenderer

func (*GraphWidget) Cursor

func (g *GraphWidget) Cursor() desktop.Cursor

func (*GraphWidget) DragEnd

func (g *GraphWidget) DragEnd()

func (*GraphWidget) Dragged

func (g *GraphWidget) Dragged(event *fyne.DragEvent)

func (*GraphWidget) GetEdges

func (g *GraphWidget) GetEdges(n *GraphNode) []*GraphEdge

func (*GraphWidget) MouseIn

func (g *GraphWidget) MouseIn(event *desktop.MouseEvent)

func (*GraphWidget) MouseMoved

func (g *GraphWidget) MouseMoved(event *desktop.MouseEvent)

func (*GraphWidget) MouseOut

func (g *GraphWidget) MouseOut()

func (*GraphWidget) StepForceLayout

func (g *GraphWidget) StepForceLayout(targetLength float64)

StepForceLayout calculates one step of force directed graph layout, with the target distance between adjacent nodes being targetLength.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL