本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.NodeIf.AddToTree方法的典型用法代码示例。如果您正苦于以下问题:Golang NodeIf.AddToTree方法的具体用法?Golang NodeIf.AddToTree怎么用?Golang NodeIf.AddToTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.NodeIf
的用法示例。
在下文中一共展示了NodeIf.AddToTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: treeNewObject
func (t *nodeType) treeNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor) {
switch obj.(type) {
case bh.ImplementationIf:
cursor.Position = len(t.Implementation()) - 1
newCursor = tree.Insert(cursor)
obj.(bh.ImplementationIf).AddToTree(tree, newCursor)
case bh.PortTypeIf:
pt := obj.(bh.PortTypeIf)
newCursor = tree.Insert(cursor)
pt.AddToTree(tree, newCursor)
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
// bh.NodeIf linked to outer port
g := impl.Graph().(*signalGraphType)
var n bh.NodeIf
index := -len(t.Implementation())
if pt.Direction() == gr.InPort {
n = g.findInputNodeFromPortType(pt)
if cursor.Position == tr.AppendCursor {
index += len(g.InputNodes())
}
} else {
n = g.findOutputNodeFromPortType(pt)
if cursor.Position == tr.AppendCursor {
index += len(g.InputNodes()) + len(g.OutputNodes())
}
}
if n == nil {
log.Fatalf("nodeType.AddNewObject error: invalid implementation...\n")
}
if cursor.Position != tr.AppendCursor {
index += cursor.Position
}
gCursor := tree.CursorAt(cursor, impl)
gCursor.Position = index
n.AddToTree(tree, tree.Insert(gCursor))
}
}
default:
log.Fatalf("nodeType.AddNewObject error: invalid type %T\n", obj)
}
return
}
示例2: treeAddNewObject
func (t *signalGraphType) treeAddNewObject(tree tr.TreeIf, cursor tr.Cursor, n bh.NodeIf) (newCursor tr.Cursor) {
newCursor = tree.Insert(cursor)
n.AddToTree(tree, newCursor)
return
}