本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.NodeIf.ItsType方法的典型用法代码示例。如果您正苦于以下问题:Golang NodeIf.ItsType方法的具体用法?Golang NodeIf.ItsType怎么用?Golang NodeIf.ItsType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.NodeIf
的用法示例。
在下文中一共展示了NodeIf.ItsType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MenuViewCurrent
func MenuViewCurrent(menu *GoAppMenu, g *Global) {
fts := g.FTS().(tr.TreeIf)
cursor := fts.Current()
menu.viewExpand.SetSensitive(false)
menu.viewCollapse.SetSensitive(false)
if len(cursor.Path) == 0 {
return
}
obj := fts.Object(cursor)
var n bh.NodeIf
switch obj.(type) {
case bh.NodeIf:
n = obj.(bh.NodeIf)
//case mp.MappedElementIf:
// n = obj.(mp.MappedElementIf).Node()
default:
return
}
impl := n.ItsType().Implementation()
for _, i := range impl {
if i.ImplementationType() == bh.NodeTypeGraph {
menu.viewExpand.SetSensitive(true)
menu.viewCollapse.SetSensitive(true)
break
}
}
}
示例2: CreateXmlProcessingNode
func CreateXmlProcessingNode(n bh.NodeIf) *backend.XmlProcessingNode {
ret := backend.XmlProcessingNodeNew(n.Name(), n.ItsType().TypeName())
for _, p := range n.InPorts() {
ret.InPort = append(ret.InPort, *CreateXmlInPort(p))
}
for _, p := range n.OutPorts() {
ret.OutPort = append(ret.OutPort, *CreateXmlOutPort(p))
}
return ret
}
示例3: RemoveNode
func (t *signalGraphType) RemoveNode(n bh.NodeIf) {
for _, p := range n.(*node).inPort.Ports() {
for _, c := range p.Connections() {
c.RemoveConnection(p)
}
}
t.nodes.Remove(n)
RemNode(&t.inputNodes, n.(*node))
RemNode(&t.outputNodes, n.(*node))
RemNode(&t.processingNodes, n.(*node))
n.ItsType().(*nodeType).removeInstance(n.(*node))
}
示例4: CreateXmlOutputNode
func CreateXmlOutputNode(n bh.NodeIf) *backend.XmlOutputNode {
tName := n.ItsType().TypeName()
if strings.HasPrefix(tName, "autoOutputNodeType-") {
tName = ""
}
ret := backend.XmlOutputNodeNew(n.Name(), tName)
if n.(*node).portlink != nil {
ret.NPort = n.(*node).portlink.Name()
}
for _, p := range n.InPorts() {
ret.InPort = append(ret.InPort, *CreateXmlInPort(p))
}
return ret
}
示例5: AddNode
func (t *signalGraphType) AddNode(n bh.NodeIf) error {
nType := n.ItsType()
if !isAutoType(nType) {
libname := nType.DefinedAt()
if len(libname) == 0 {
return fmt.Errorf("signalGraphType.AddNode error: node type %s has no DefinedAt...", nType.TypeName())
}
if !t.containsLibRef(libname) {
lib, ok := freesp.GetLibraryByName(libname)
if !ok {
return fmt.Errorf("signalGraphType.AddNode error: library %s not registered", libname)
}
t.libraries = append(t.libraries, lib)
}
}
return t.addNode(n)
}
示例6: addExpandedMappings
func addExpandedMappings(m mp.MappingIf, n bh.NodeIf, parentId bh.NodeIdIf) {
idlist := m.MappedIds()
nId := behaviour.NodeIdNew(parentId, n.Name())
for _, id := range idlist {
if nId.String() == id.String() {
return
}
}
melem := m.AddMapping(n, nId, nil)
melem.SetExpanded(true)
for _, impl := range n.ItsType().Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
addExpandedMappings(m, nn, nId)
}
}
}
}
示例7: CreateXmlNodeMapList
func CreateXmlNodeMapList(m mp.MappingIf, n bh.NodeIf, path string) (xmln []backend.XmlNodeMap) {
p, ok := m.Mapped(n.Name())
if ok { // entire node is mapped to p:
pname := fmt.Sprintf("%s/%s", p.Arch().Name(), p.Name())
xmln = append(xmln, *CreateXmlNodeMap(path, pname))
}
nt := n.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
xmlnn := CreateXmlNodeMapList(m, nn, fmt.Sprintf("%s/%s", path, nn.Name()))
for _, x := range xmlnn {
xmln = append(xmln, x)
}
}
}
}
return
}
示例8: findNodeInIdList
func findNodeInIdList(n bh.NodeIf, parent bh.NodeIdIf, idlist []bh.NodeIdIf) bool {
nId := behaviour.NodeIdNew(parent, n.Name())
log.Printf("findNodeInIdList: n=%s, parent=%v\n", n.Name(), parent)
for _, id := range idlist {
if nId.String() == id.String() {
return true
}
}
for _, impl := range n.ItsType().Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
if !findNodeInIdList(nn, nId, idlist) {
return false
}
}
return true
}
}
return false
}
示例9: nodePath
func (g *Global) nodePath(n bh.NodeIf, nCursor tr.Cursor, selectId bh.NodeIdIf) (cursor tr.Cursor) {
ids := strings.Split(selectId.String(), "/")
if len(ids) == 1 {
cursor = nCursor
return
}
nt := n.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, nn := range impl.Graph().ProcessingNodes() {
if nn.Name() == ids[1] {
nnId := behaviour.NodeIdFromString(strings.Join(ids[1:], "/"), selectId.Filename())
cursor = g.nodePath(nn, g.fts.CursorAt(nCursor, nn), nnId)
break
}
}
break
}
}
return
}
示例10: CreateXmlNodePosHint
func CreateXmlNodePosHint(nd bh.NodeIf, path string) (xmln []backend.XmlNodePosHint) {
xmlnd := CreateXmlIONodePosHint(nd, path)
xmlnd.Expanded = nd.Expanded()
xmln = append(xmln, *xmlnd)
nt := nd.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
for _, n := range impl.Graph().ProcessingNodes() {
var p string
if len(path) == 0 {
p = nd.Name()
} else {
p = fmt.Sprintf("%s/%s", path, nd.Name())
}
hintlist := CreateXmlNodePosHint(n, p)
for _, h := range hintlist {
xmln = append(xmln, h)
}
}
break
}
}
return
}
示例11: ExpandedNodeNew
func ExpandedNodeNew(getPositioner GetPositioner, userObj bh.NodeIf, nId bh.NodeIdIf) (ret *ExpandedNode) {
positioner := getPositioner(nId)
pos := positioner.Position()
path := nId.String()
config := DrawConfig{ColorInit(ColorOption(NormalExpandedNode)),
ColorInit(ColorOption(HighlightExpandedNode)),
ColorInit(ColorOption(SelectExpandedNode)),
ColorInit(ColorOption(BoxFrame)),
ColorInit(ColorOption(Text)),
image.Point{global.padX, global.padY}}
cconfig := ContainerConfig{expandedPortWidth, expandedPortHeight, 120, 80}
// Add children
var g bh.SignalGraphTypeIf
nt := userObj.ItsType()
for _, impl := range nt.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
g = impl.Graph()
break
}
}
var children []ContainerChild
if g != nil {
empty := image.Point{}
first := image.Point{16, 32}
shift := image.Point{16, 16}
for i, n := range g.ProcessingNodes() {
var ch ContainerChild
var mode gr.PositionMode
if n.Expanded() {
mode = gr.PositionModeExpanded
} else {
mode = gr.PositionModeNormal
}
proxy := gr.PathModePositionerProxyNew(n)
proxy.SetActivePath(path)
proxy.SetActiveMode(mode)
log.Printf("ExpandedNodeNew TODO: position of child nodes. path=%s, mode=%v\n", path, mode)
chpos := proxy.Position()
if chpos == empty {
chpos = pos.Add(first.Add(shift.Mul(i)))
proxy.SetPosition(chpos)
}
id := freesp.NodeIdNew(nId, n.Name())
if n.Expanded() {
ch = ExpandedNodeNew(getPositioner, n, id)
} else {
ch = NodeNew(getPositioner, n, id)
}
children = append(children, ch)
}
}
ret = &ExpandedNode{ContainerInit(children, config, userObj, cconfig),
userObj, positioner, nil, nil}
ret.ContainerInit()
empty := image.Point{}
config = DrawConfig{ColorInit(ColorOption(InputPort)),
ColorInit(ColorOption(HighlightInPort)),
ColorInit(ColorOption(SelectInPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
for i, p := range userObj.InPorts() {
pos := p.ModePosition(gr.PositionModeExpanded)
if pos == empty {
pos = ret.CalcInPortPos(i)
}
positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
ret.AddPort(config, p, positioner)
}
config = DrawConfig{ColorInit(ColorOption(OutputPort)),
ColorInit(ColorOption(HighlightOutPort)),
ColorInit(ColorOption(SelectOutPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
for i, p := range userObj.OutPorts() {
pos := p.ModePosition(gr.PositionModeExpanded)
if pos == empty {
pos = ret.CalcOutPortPos(i)
}
positioner := gr.ModePositionerProxyNew(p, gr.PositionModeExpanded)
ret.AddPort(config, p, positioner)
}
for _, n := range g.ProcessingNodes() {
from, ok := ret.ChildByName(n.Name())
if !ok {
log.Printf("ExpandedNodeNew error: node %s not found\n", n.Name())
continue
}
for _, p := range n.OutPorts() {
fromId := from.OutPortIndex(p.Name())
for _, c := range p.Connections() {
to, ok := ret.ChildByName(c.Node().Name())
if ok {
toId := to.InPortIndex(c.Name())
ret.connections = append(ret.connections, ConnectionNew(from, to, fromId, toId))
} else {
portname, ok := c.Node().PortLink()
if !ok {
log.Printf("ExpandedNodeNew error: output node %s not linked\n", c.Node().Name())
//.........这里部分代码省略.........