def __init__(self, field, id, cell0, cell1, effects=None, color=None): """Store basic info and create a DataElement object""" # process passed params if color is None: self.m_color = DEF_LINECOLOR else: self.m_color = color # store other params self.m_shape = Line() self.m_path = [] self.m_score = 0 super(MyConnector,self).__init__(field,id,cell0,cell1,effects)
class MyConnector(Connector): """Represents a connector between two cells. Create a connector as a subclass of the basic data element. Stores the following values: m_cell0, m_cell1: the two cells connected by this connector makeBasicShape: create the set of arcs that will define the shape """ def __init__(self, field, id, cell0, cell1, effects=None, color=None): """Store basic info and create a DataElement object""" # process passed params if color is None: self.m_color = DEF_LINECOLOR else: self.m_color = color # store other params self.m_shape = Line() self.m_path = [] self.m_score = 0 super(MyConnector,self).__init__(field,id,cell0,cell1,effects) # move to superclass? def addPath(self,path): """Record the path of this connector.""" self.m_path = path def render(self): if self.m_cell0.m_location and self.m_cell1.m_location: self.m_shape.update(self.m_field, self.m_cell0.m_location, self.m_cell0.m_location, self.m_cell0.m_radius, self.m_cell1.m_radius, self.m_color,self.m_path) #print ("Render Connector(%s):%s to %s" % (self.m_id,cell0.m_location,cell1.m_location)) self.m_shape.render() def draw(self): if self.m_cell0.m_location and self.m_cell1.m_location: self.m_shape.draw()