graphjson

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: EPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package graphjson defines ELK's JSON graph interchange model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float64

func Float64(value float64) *float64

Float64 returns a pointer suitable for optional numeric graph fields.

func Number

func Number(value *float64) float64

Number returns value, or zero when value is nil.

func String

func String(value string) *string

String returns a pointer suitable for optional text fields.

Types

type Edge

type Edge struct {
	ID               ID                         `json:"id,omitempty"`
	Labels           []*Label                   `json:"labels,omitempty"`
	LayoutOptions    LayoutOptions              `json:"layoutOptions,omitempty"`
	Sources          []ID                       `json:"sources,omitempty"`
	Targets          []ID                       `json:"targets,omitempty"`
	Sections         []*EdgeSection             `json:"sections,omitempty"`
	JunctionPoints   []Point                    `json:"junctionPoints,omitempty"`
	Source           *ID                        `json:"source,omitempty"`
	SourcePort       *ID                        `json:"sourcePort,omitempty"`
	Target           *ID                        `json:"target,omitempty"`
	TargetPort       *ID                        `json:"targetPort,omitempty"`
	SourcePoint      *Point                     `json:"sourcePoint,omitempty"`
	TargetPoint      *Point                     `json:"targetPoint,omitempty"`
	BendPoints       []Point                    `json:"bendPoints,omitempty"`
	Container        *ID                        `json:"container,omitempty"`
	AdditionalFields map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

Edge accepts both ELK's extended sources/targets form and its deprecated primitive source/target form.

func (*Edge) LayoutOptionKeys

func (edge *Edge) LayoutOptionKeys() []string

LayoutOptionKeys returns the layout-option member order captured while decoding JSON. Programmatically constructed edges return nil.

func (Edge) MarshalJSON

func (edge Edge) MarshalJSON() ([]byte, error)

func (*Edge) UnmarshalJSON

func (edge *Edge) UnmarshalJSON(data []byte) error

type EdgeSection

type EdgeSection struct {
	ID               ID                         `json:"id,omitempty"`
	LayoutOptions    LayoutOptions              `json:"layoutOptions,omitempty"`
	StartPoint       *Point                     `json:"startPoint,omitempty"`
	EndPoint         *Point                     `json:"endPoint,omitempty"`
	BendPoints       []Point                    `json:"bendPoints,omitempty"`
	IncomingShape    *ID                        `json:"incomingShape,omitempty"`
	OutgoingShape    *ID                        `json:"outgoingShape,omitempty"`
	IncomingSections []ID                       `json:"incomingSections,omitempty"`
	OutgoingSections []ID                       `json:"outgoingSections,omitempty"`
	AdditionalFields map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

EdgeSection is one connected piece of an edge route.

func (*EdgeSection) LayoutOptionKeys

func (section *EdgeSection) LayoutOptionKeys() []string

LayoutOptionKeys returns the layout-option member order captured while decoding JSON. Programmatically constructed sections return nil.

func (EdgeSection) MarshalJSON

func (section EdgeSection) MarshalJSON() ([]byte, error)

func (*EdgeSection) UnmarshalJSON

func (section *EdgeSection) UnmarshalJSON(data []byte) error

type Graph

type Graph = Node

Graph is the root-node spelling used by Layout.

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID is an ELK graph identifier. ELK's documented API uses string IDs, while its JSON importer also accepts integral JSON numbers. ID preserves which representation was supplied.

func IDPtr

func IDPtr(id ID) *ID

IDPtr returns a pointer to a copy of id.

func IntID

func IntID(value int64) ID

IntID constructs an integer-valued graph identifier.

func StringID

func StringID(value string) ID

StringID constructs a string-valued graph identifier.

func (ID) Int64

func (id ID) Int64() (int64, bool)

Int64 returns the numeric identifier and whether this ID is numeric.

func (ID) IsNumber

func (id ID) IsNumber() bool

IsNumber reports whether the ID uses the JSON number representation.

func (ID) IsValid

func (id ID) IsValid() bool

IsValid reports whether the ID was explicitly initialized.

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (ID) String

func (id ID) String() string

String returns the identifier's canonical text representation.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

type Label

type Label struct {
	ID               *ID                        `json:"id,omitempty"`
	Text             *string                    `json:"text,omitempty"`
	Labels           []*Label                   `json:"labels,omitempty"`
	LayoutOptions    LayoutOptions              `json:"layoutOptions,omitempty"`
	X                *float64                   `json:"x,omitempty"`
	Y                *float64                   `json:"y,omitempty"`
	Width            *float64                   `json:"width,omitempty"`
	Height           *float64                   `json:"height,omitempty"`
	AdditionalFields map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

Label is a shape attached to a node, port, or edge.

func (*Label) LayoutOptionKeys

func (label *Label) LayoutOptionKeys() []string

LayoutOptionKeys returns the layout-option member order captured while decoding JSON. Programmatically constructed labels return nil.

func (Label) MarshalJSON

func (label Label) MarshalJSON() ([]byte, error)

func (*Label) UnmarshalJSON

func (label *Label) UnmarshalJSON(data []byte) error

type LayoutOptions

type LayoutOptions map[string]any

LayoutOptions contains layout option values. ELK's JavaScript facade accepts strings as documented as well as JSON booleans and numbers.

type Node

type Node struct {
	ID                 ID                         `json:"id,omitempty"`
	Labels             []*Label                   `json:"labels,omitempty"`
	LayoutOptions      LayoutOptions              `json:"layoutOptions,omitempty"`
	IndividualSpacings LayoutOptions              `json:"individualSpacings,omitempty"`
	X                  *float64                   `json:"x,omitempty"`
	Y                  *float64                   `json:"y,omitempty"`
	Width              *float64                   `json:"width,omitempty"`
	Height             *float64                   `json:"height,omitempty"`
	Children           []*Node                    `json:"children,omitempty"`
	Ports              []*Port                    `json:"ports,omitempty"`
	Edges              []*Edge                    `json:"edges,omitempty"`
	AdditionalFields   map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

Node is both ELK's root graph type and its recursive node type. Nil slices are absent JSON members; non-nil empty slices are emitted as empty arrays.

func (*Node) IndividualSpacingKeys

func (node *Node) IndividualSpacingKeys() []string

IndividualSpacingKeys returns the individual-spacing member order captured while decoding JSON. Programmatically constructed nodes return nil.

func (*Node) LayoutOptionKeys

func (node *Node) LayoutOptionKeys() []string

LayoutOptionKeys returns the layout-option member order captured while decoding JSON. Programmatically constructed nodes return nil.

func (Node) MarshalJSON

func (node Node) MarshalJSON() ([]byte, error)

func (*Node) UnmarshalJSON

func (node *Node) UnmarshalJSON(data []byte) error

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Point is a two-dimensional point in parent-relative ELK coordinates.

func (Point) MarshalJSON

func (point Point) MarshalJSON() ([]byte, error)

type Port

type Port struct {
	ID               ID                         `json:"id,omitempty"`
	Labels           []*Label                   `json:"labels,omitempty"`
	LayoutOptions    LayoutOptions              `json:"layoutOptions,omitempty"`
	X                *float64                   `json:"x,omitempty"`
	Y                *float64                   `json:"y,omitempty"`
	Width            *float64                   `json:"width,omitempty"`
	Height           *float64                   `json:"height,omitempty"`
	AdditionalFields map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

Port is a connectable shape owned by a node.

func (*Port) LayoutOptionKeys

func (port *Port) LayoutOptionKeys() []string

LayoutOptionKeys returns the layout-option member order captured while decoding JSON. Programmatically constructed ports return nil.

func (Port) MarshalJSON

func (port Port) MarshalJSON() ([]byte, error)

func (*Port) UnmarshalJSON

func (port *Port) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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