python_psynth
This is the official python package for generating graphs in Psymphonic Psynth
psynth.psynth.Node Class Reference

Nodes are the basic unit in Psynth. More...

Public Member Functions

def __init__
 Constructs a Node object. More...
 
def add_detail
 Attaches a Detail to this Node. More...
 
def details (self)
 Returns a uid-keyed dictionary of Detail objects which are attached to this Node. More...
 
def detail_list (self)
 Returns a list of Detail objects which are attached to this Node. More...
 
def out_links (self)
 Returns a list of Link objects which originate at this Node. More...
 
def in_links (self)
 Returns a list of Link objects which terminate at this Node. More...
 
def all_links (self)
 Returns a list of Link objects which connect to this Node. More...
 
def out_neighbors (self)
 Returns a list of Node objects which neighbor this Node by outgoing Link. More...
 
def in_neighbors (self)
 Returns a list of Node objects which neighbor this Node by incoming Link. More...
 
def all_neighbors (self)
 Returns a list of Node objects which neighbor this Node. More...
 
def dictionary (self)
 Returns a dictionary with this Node's properties, as required by the API. More...
 
def update
 Updates the register of this Node on the server. More...
 

Public Attributes

 name
 str :: The display name of the Node. More...
 
 uid
 str :: The global unique id of the Node. More...
 
 x
 float :: The x-coordinate of the Node. More...
 
 y
 float :: The y-coordinate of the Node. More...
 
 shape
 int :: The number of sides of the Node shape. More...
 
 image
 str :: The URL for an image to display on this Node. More...
 
 radius
 float :: The radius of the Node
 
 color
 str :: The color of the Node. More...
 
 created
 bool :: Whether or not this Node has been created on the Server. More...
 

Static Public Attributes

 graph = None
 Graph :: The Graph to which this Node belongs. More...
 

Detailed Description

Nodes are the basic unit in Psynth.

They can be connected by Link objects, and Detail objects can be attached to them.

Constructor & Destructor Documentation

def psynth.psynth.Node.__init__ (   self,
  uid = None,
  name = "New Node",
  x = 1.0,
  y = 1.0,
  shape = 6,
  image = "na",
  radius = 24.0,
  color = "dynamic" 
)

Constructs a Node object.

Parameters
uidstr :: A global unique identifier for the Node.
namestr :: The displayed name of the Node.
xfloat :: The x-coordinate of the Node. Assumes a web-standard grid with (0,0) at (top,left)
yfloat :: The y-coordinate of the Node. Assumes a web-standard grid with (0,0) at (top,left)
shapeint :: The number of sides the Node should have. 0 for circle, 1 for image.
imagestr :: The url of an image to display on this node. Requires a shape of 1.
radiusfloat :: The radius of the Node shape.
colorstr :: A color string, e.g. '#FF0000'. 'dynamic' will make the Node responsive to user-selected palette. 'static' will leave a node image's color unaffected. Labeled as a Photo mode in the gui.
1 n = Node(name='My Node', shape=8, radius=33.5)
2 g.add_node(n)

Member Function Documentation

def psynth.psynth.Node.add_detail (   self,
  detail,
  update = True,
  callback = None 
)

Attaches a Detail to this Node.

Allows for fewer explicit property declarations on Detail creation.

Parameters
detailDetail :: The Detail to attach to this Node.
updatebool :: Whether or not to immediately enqueue the query.
callbackfunction :: An optional function to handle the server's response to the query.
1 d = Detail(content="http://psymphonic.com", type="link")
2 n.add_detail(d)
def psynth.psynth.Node.all_links (   self)

Returns a list of Link objects which connect to this Node.

Returns
links: list :: A list of Link objects which connect to this Node.
1 for link in n.all_links():
2  print link.value
def psynth.psynth.Node.all_neighbors (   self)

Returns a list of Node objects which neighbor this Node.

Returns
nodes: list :: A list of Node objects which neighbor this Node.
1 for n2 in n.all_neighbors():
2  print n2.name
def psynth.psynth.Node.detail_list (   self)

Returns a list of Detail objects which are attached to this Node.

Returns
dets: list :: A list of Detail objects which are attached to this Node.
1 for d in n.detail_list():
2  print d.anchor() == n # True
def psynth.psynth.Node.details (   self)

Returns a uid-keyed dictionary of Detail objects which are attached to this Node.

Returns
dets: dict :: A uid-keyed dictionary of Detail objects which are attached to this Node.
1 for d in n.details():
2  print n.details()[d].anchor() == n # True
def psynth.psynth.Node.dictionary (   self)

Returns a dictionary with this Node's properties, as required by the API.

Generally used to build queries.

Returns
dict: dict :: A dictionary of this Node's properties.
1 q = n.dictionary()
2 q['query'] = 'newnode'
3 g.queue(q)
def psynth.psynth.Node.in_links (   self)

Returns a list of Link objects which terminate at this Node.

Returns
links: list :: A list of Link objects which terminate at this Node.
1 for link in n.in_links():
2  print link.value
def psynth.psynth.Node.in_neighbors (   self)

Returns a list of Node objects which neighbor this Node by incoming Link.

Returns
nodes: list :: A list of Node objects which neighbor this Node by incoming Link.
1 for n2 in n.in_neighbors():
2  print n2.name
def psynth.psynth.Node.out_links (   self)

Returns a list of Link objects which originate at this Node.

Returns
links: list :: A list of Link objects which originate at this Node.
1 for link in n.out_links():
2  print link.value
def psynth.psynth.Node.out_neighbors (   self)

Returns a list of Node objects which neighbor this Node by outgoing Link.

Returns
nodes: list :: A list of Node objects which neighbor this Node by outgoing Link.
1 for n2 in n.out_neighbors():
2  print n2.name
def psynth.psynth.Node.update (   self,
  callback = None 
)

Updates the register of this Node on the server.

Parameters
callbackfunction :: An optional function to handle the server's response to the query.
1 n.name = "Different Node Name"
2 n.radius += 5
3 n.update()

Member Data Documentation

psynth.psynth.Node.color

str :: The color of the Node.

e.g. '#FF0000'

psynth.psynth.Node.created

bool :: Whether or not this Node has been created on the Server.

psynth.psynth.Node.graph = None
static

Graph :: The Graph to which this Node belongs.

psynth.psynth.Node.image

str :: The URL for an image to display on this Node.

psynth.psynth.Node.name

str :: The display name of the Node.

psynth.psynth.Node.shape

int :: The number of sides of the Node shape.

0 for circle, 1 for image, otherwise n-gon.

psynth.psynth.Node.uid

str :: The global unique id of the Node.

psynth.psynth.Node.x

float :: The x-coordinate of the Node.

Assumes a web-standard grid with (0,0) at (top,left)

psynth.psynth.Node.y

float :: The y-coordinate of the Node.

Assumes a web-standard grid with (0,0) at (top,left)


The documentation for this class was generated from the following file: