Exemplo n.º 1
0
func detectType(
	handlers map[string]CXAspectHandler,
	tag string, value interface{},
	cyjsNetwork *cyjs.CyJS,
	nodeAttrs *map[string]interface{},
	edgeAttrs *map[string]interface{},
	layout *map[string]interface{},
	vps *map[string]interface{}) {

	switch tag {

	case cx.NetworkAttributesTag:
		netHandler := handlers[cx.NetworkAttributesTag]
		cyjsNetwork.Data = netHandler.HandleAspect(value.([]interface{}))
	case cx.NodesTag:
		createNodes(value.([]interface{}), cyjsNetwork)
	case cx.EdgesTag:
		decodeEdges(value.([]interface{}), cyjsNetwork)
	case cx.NodeAttributesTag:
		nodeAttributeHandler := handlers[cx.NodeAttributesTag]
		na := nodeAttributeHandler.HandleAspect(value.([]interface{}))
		*nodeAttrs = mergeAttr(na, *nodeAttrs)
	case cx.EdgeAttributesTag:
		edgeAttributeHandler := handlers[cx.EdgeAttributesTag]
		ea := edgeAttributeHandler.HandleAspect(value.([]interface{}))
		*edgeAttrs = mergeAttr(ea, *edgeAttrs)
	case cx.CartesianLayoutTag:
		layoutHandler := handlers[cx.CartesianLayoutTag]
		*layout = layoutHandler.HandleAspect(value.([]interface{}))
	case cx.VisualPropertiesTag:
		vpHandler := handlers[cx.VisualPropertiesTag]
		*vps = vpHandler.HandleAspect(value.([]interface{}))
	default:
		// All others
		cyjsNetwork.CxData[tag] = value
	}
}