package stress
import (
"github.com/d2lang/elk-go/internal/common/nodespacing"
"github.com/d2lang/elk-go/internal/core"
"github.com/d2lang/elk-go/internal/force"
"github.com/d2lang/elk-go/internal/graph"
)
type Provider struct {}
func Register (registry *core .AlgorithmRegistry ) error {
return registry .Register (core .AlgorithmData {
ID : "org.eclipse.elk.stress" ,
Create : func () core .LayoutProvider { return &Provider {} },
})
}
func (*Provider ) Layout (model *graph .Model , parent graph .NodeID , monitor core .ProgressMonitor ) error {
if !graph .Get (&model .Node (parent ).Properties , force .Interactive ) {
if err := force .InitialLayout (model , parent , monitor .Subtask (1 )); err != nil {
return err
}
} else if !graph .Get (&model .Node (parent ).Properties , force .OmitNodeMicroLayout ) {
nodespacing .CalculateLabelAndNodeSizes (model , parent , nil )
}
importer := force .NewImporter (model , parent )
fgraph , err := importer .ImportGraph ()
if err != nil {
return err
}
components := force .Split (fgraph )
for _ , component := range components {
if len (component .Nodes ) <= 1 {
continue
}
majorization := &Majorization {}
majorization .Initialize (model , component )
majorization .Execute ()
for _ , label := range component .Labels {
label .RefreshPosition ()
}
}
importer .ApplyLayout (force .Recombine (components ))
return nil
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .