本文整理匯總了Golang中github.com/axel-freesp/sge/interface/behaviour.PortIf.Direction方法的典型用法代碼示例。如果您正苦於以下問題:Golang PortIf.Direction方法的具體用法?Golang PortIf.Direction怎麽用?Golang PortIf.Direction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/axel-freesp/sge/interface/behaviour.PortIf
的用法示例。
在下文中一共展示了PortIf.Direction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getMatchingPorts
// For connection only: lookup matching ports to connect.
func getMatchingPorts(fts *models.FilesTreeStore, object tr.TreeElementIf) (ret []bh.PortIf) {
var thisPort bh.PortIf
switch object.(type) {
case bh.PortIf:
thisPort = object.(bh.PortIf)
case bh.ConnectionIf:
log.Fatal("getMatchingPorts error: expecting Port, not Connection")
default:
log.Fatal("getMatchingPorts error: expecting Port")
}
thisNode := thisPort.Node()
graph := thisNode.Context()
for _, n := range graph.Nodes() {
var ports []bh.PortIf
if thisPort.Direction() == gr.InPort {
ports = n.OutPorts()
} else {
ports = n.InPorts()
}
for _, p := range ports {
if p.SignalType().TypeName() == thisPort.SignalType().TypeName() {
ret = append(ret, p)
}
}
}
return
}
示例2: SelectPort
func (n *Node) SelectPort(port bh.PortIf) {
var index int
if port.Direction() == gr.InPort {
index = n.InPortIndex(port.Name())
} else {
index = n.OutPortIndex(port.Name())
if index >= 0 {
index += n.NumInPorts()
}
}
for i, p := range n.ports {
if i == index {
p.Select()
} else {
p.Deselect()
}
}
n.selectedPort = index
}
示例3: PortNew
func PortNew(box image.Rectangle, userObj bh.PortIf) *Port {
var config DrawConfig
if userObj.Direction() == gr.InPort {
config = DrawConfig{ColorInit(ColorOption(InputPort)),
ColorInit(ColorOption(HighlightInPort)),
ColorInit(ColorOption(SelectInPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
} else {
config = DrawConfig{ColorInit(ColorOption(OutputPort)),
ColorInit(ColorOption(HighlightOutPort)),
ColorInit(ColorOption(SelectOutPort)),
ColorInit(ColorOption(BoxFrame)),
Color{},
image.Point{}}
}
return &Port{SelectableBoxInit(box, config), userObj}
}
示例4: portConnect
func portConnect(port1 bh.PortIf, c *connection) error {
p1 := port1.(*port)
var port2 bh.PortIf
var p2 *port
if c.from.(*port) == p1 {
port2 = c.to
} else if c.to.(*port) == p1 {
port2 = c.from
}
p2 = port2.(*port)
if port1.SignalType().TypeName() != port2.SignalType().TypeName() {
return fmt.Errorf("type mismatch")
}
if port1.Direction() == port2.Direction() {
return fmt.Errorf("direction mismatch")
}
p1.connected.Append(port2.(*port))
p1.conn = append(p1.conn, c)
p2.connected.Append(port1.(*port))
p2.conn = append(p2.conn, c)
return nil
}