本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.NodeIf.InPorts方法的典型用法代码示例。如果您正苦于以下问题:Golang NodeIf.InPorts方法的具体用法?Golang NodeIf.InPorts怎么用?Golang NodeIf.InPorts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.NodeIf
的用法示例。
在下文中一共展示了NodeIf.InPorts方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateXmlIONodePosHint
func CreateXmlIONodePosHint(n bh.NodeIf, path string) (xmln *backend.XmlNodePosHint) {
if len(path) == 0 {
xmln = backend.XmlNodePosHintNew(n.Name())
} else {
xmln = backend.XmlNodePosHintNew(fmt.Sprintf("%s/%s", path, n.Name()))
}
empty := image.Point{}
for _, p := range n.PathList() {
for _, m := range gr.ValidModes {
xmlp := string(gr.CreatePathMode(p, m))
pos := n.PathModePosition(p, m)
if pos != empty {
xmln.Entry = append(xmln.Entry, *backend.XmlModeHintEntryNew(xmlp, pos.X, pos.Y))
}
}
}
for _, p := range n.InPorts() {
xmlp := backend.XmlPortPosHintNew(p.Name())
xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
xmln.InPorts = append(xmln.InPorts, *xmlp)
}
for _, p := range n.OutPorts() {
xmlp := backend.XmlPortPosHintNew(p.Name())
xmlp.Entry = freesp.CreateXmlModePosition(p).Entry
xmln.OutPorts = append(xmln.OutPorts, *xmlp)
}
return
}
示例2: IsProcessingNode
func IsProcessingNode(n bh.NodeIf) bool {
if len(n.InPorts()) == 0 {
return false
}
if len(n.OutPorts()) == 0 {
return false
}
return true
}
示例3: 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
}
示例4: mapelemNew
func mapelemNew(n bh.NodeIf, nId bh.NodeIdIf, p pf.ProcessIf, mapping mp.MappingIf) (m *mapelem) {
m = &mapelem{*gr.ModePositionerObjectNew(), n, nId, p, mapping, false,
make([]gr.ModePositionerObject, len(n.InPorts())),
make([]gr.ModePositionerObject, len(n.OutPorts()))}
for i := 0; i < len(m.inports); i++ {
m.inports[i] = *gr.ModePositionerObjectNew()
}
for i := 0; i < len(m.outports); i++ {
m.outports[i] = *gr.ModePositionerObjectNew()
}
return
}
示例5: 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
}
示例6: addNode
func (t *signalGraphType) addNode(n bh.NodeIf) error {
if len(n.InPorts()) > 0 {
if len(n.OutPorts()) > 0 {
t.processingNodes = append(t.processingNodes, n.(*node))
} else {
t.outputNodes = append(t.outputNodes, n.(*node))
}
} else {
if len(n.OutPorts()) > 0 {
t.inputNodes = append(t.inputNodes, n.(*node))
} else {
return fmt.Errorf("signalGraphType.AddNode error: node has no ports")
}
}
t.nodes.Append(n.(*node))
return nil
}
示例7: NodeNew
func NodeNew(getPositioner GetPositioner, n bh.NodeIf, nId bh.NodeIdIf) (ret *Node) {
positioner := getPositioner(nId)
pos := positioner.Position()
dy := NumericOption(PortDY)
box := image.Rect(pos.X, pos.Y, pos.X+global.nodeWidth, pos.Y+global.nodeHeight+numPorts(n)*dy)
config := DrawConfig{ColorInit(ColorOption(NodeNormal)),
ColorInit(ColorOption(NodeHighlight)),
ColorInit(ColorOption(NodeSelected)),
ColorInit(ColorOption(BoxFrame)),
ColorInit(ColorOption(Text)),
image.Point{global.padX, global.padY}}
ret = &Node{NamedBoxObjectInit(box, config, n), n, positioner, nil, -1}
ret.RegisterOnHighlight(func(hit bool, pos image.Point) bool {
return ret.onHighlight(hit, pos)
})
ret.RegisterOnSelect(func() bool {
return ret.onSelect()
}, func() bool {
return ret.onDeselect()
})
portBox := image.Rect(0, 0, global.portW, global.portH)
portBox = portBox.Add(box.Min)
shiftIn := image.Point{global.padX + global.portX0, global.padY + global.portY0}
shiftOut := image.Point{box.Size().X - global.padX - global.portW - global.portX0, global.padY + global.portY0}
b := portBox.Add(shiftIn)
for _, p := range n.InPorts() {
p := PortNew(b, p)
ret.ports = append(ret.ports, p)
b = b.Add(image.Point{0, global.portDY})
}
b = portBox.Add(shiftOut)
for _, p := range n.OutPorts() {
p := PortNew(b, p)
ret.ports = append(ret.ports, p)
b = b.Add(image.Point{0, global.portDY})
}
return
}
示例8: treeRemoveObject
func (t *nodeType) treeRemoveObject(tree tr.TreeIf, cursor tr.Cursor) (removed []tr.IdWithObject) {
parentId := tree.Parent(cursor)
if t != tree.Object(parentId) {
log.Fatal("nodeType.RemoveObject error: not removing child of mine.")
}
obj := tree.Object(cursor)
switch obj.(type) {
case bh.ImplementationIf:
impl := obj.(bh.ImplementationIf)
if impl.ImplementationType() == bh.NodeTypeGraph {
// TODO: This is redundant with implementation.go
// Simply remove all nodes? Do not traverse a modifying list...
// Removed Input- and Output nodes are NOT stored (they are
// created automatically when adding the implementation graph).
// Return all removed edges ...
for _, n := range impl.Graph().Nodes() {
nCursor := tree.Cursor(n)
for _, p := range n.OutPorts() {
pCursor := tree.CursorAt(nCursor, p)
for index, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, index, conn})
}
}
}
// ... and processing nodes
for _, n := range impl.Graph().ProcessingNodes() {
nCursor := tree.Cursor(n)
gCursor := tree.Parent(nCursor)
nIndex := gCursor.Position
removed = append(removed, tr.IdWithObject{nCursor.Path, nIndex, n})
}
}
case bh.PortTypeIf:
nt := obj.(bh.PortTypeIf)
for _, impl := range t.Implementation() {
if impl.ImplementationType() == bh.NodeTypeGraph {
// Remove and store all edges connected to the nodes linked to the outer ports
g := impl.Graph().(*signalGraphType)
var n bh.NodeIf
if nt.Direction() == gr.InPort {
n = g.findInputNodeFromPortType(nt)
} else {
n = g.findOutputNodeFromPortType(nt)
}
if n == nil {
log.Fatalf("nodeType.RemoveObject error: invalid implementation...\n")
}
nCursor := tree.CursorAt(parentId, n)
for _, p := range n.InPorts() {
pCursor := tree.CursorAt(nCursor, p)
for _, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, -1, conn})
}
}
for _, p := range n.OutPorts() {
pCursor := tree.CursorAt(nCursor, p)
for _, c := range p.Connections() {
conn := p.Connection(c)
removed = append(removed, tr.IdWithObject{pCursor.Path, -1, conn})
}
}
// Remove (but dont store) the nodes linked to the outer ports:
tree.Remove(nCursor)
}
}
default:
log.Fatalf("nodeType.RemoveObject error: invalid type %T\n", obj)
}
return
}
示例9: 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())
//.........这里部分代码省略.........