コード例 #1
0
ファイル: base.py プロジェクト: breezer00/dotSkapes
class Element (object):
    def __init__ (self, **attr):
        if attr.has_key ('name'):
            self.name = attr['name']
        else:
            self.name = None
        if attr.has_key ('id'):
            self.id = attr['id']
        else:
            self.id = None
        if attr.has_key ('className'):
            self.className = attr['className']
        else:
            self.className = None
        self.parent = None
        self.style = Style ()
        self.xml = {}

    def root (self):
        parent = self
        while not parent.parent is None:
            parent = parent.parent
        return parent

    def createDef (self, element):
        if not hasattr (self, 'defs') :
            self.defs = Defs ()
        node = self.defs.getElementById (element.id)
        if node is None:
            self.defs.draw (element)
            return True
        else:
            return False

    def setSVG (self):
        attr = {'class': self.className,
                'id': self.id}
        attr.update (self.style.setSVG ())
        xml = {}
        for key, value in self.xml.iteritems ():
            xml[clean (str (key))] = clean (str(value))
        attr.update (xml)
        return attr

    def SVG (self, indent):
        attr = self.setSVG ()
        return indent + '<' + self.name + ' ' + attributesToSVG (attr) + ' />\n'
コード例 #2
0
ファイル: base.py プロジェクト: BhagyaGH/eden
class Element(object):
    def __init__(self, **attr):
        if attr.has_key("name"):
            self.name = attr["name"]
        else:
            self.name = None
        if attr.has_key("id"):
            self.id = attr["id"]
        else:
            self.id = None
        if attr.has_key("className"):
            self.className = attr["className"]
        else:
            self.className = None
        self.parent = None
        self.style = Style()
        self.xml = {}

    def root(self):
        parent = self
        while not parent.parent is None:
            parent = parent.parent
        return parent

    def createDef(self, element):
        if not hasattr(self, "defs"):
            self.defs = Defs()
        node = self.defs.getElementById(element.id)
        if node is None:
            self.defs.draw(element)
            return True
        else:
            return False

    def setSVG(self):
        attr = {"class": self.className, "id": self.id}
        attr.update(self.style.setSVG())
        attr.update(self.xml)
        return attr

    def SVG(self, indent):
        attr = self.setSVG()
        return indent + "<" + self.name + " " + attributesToSVG(attr) + " />\n"
コード例 #3
0
ファイル: base.py プロジェクト: gnarula/eden_deployment
class Element(object):
    def __init__(self, **attr):
        if attr.has_key('name'):
            self.name = attr['name']
        else:
            self.name = None
        if attr.has_key('id'):
            self.id = attr['id']
        else:
            self.id = None
        if attr.has_key('className'):
            self.className = attr['className']
        else:
            self.className = None
        self.parent = None
        self.style = Style()
        self.xml = {}

    def root(self):
        parent = self
        while not parent.parent is None:
            parent = parent.parent
        return parent

    def createDef(self, element):
        if not hasattr(self, 'defs'):
            self.defs = Defs()
        node = self.defs.getElementById(element.id)
        if node is None:
            self.defs.draw(element)
            return True
        else:
            return False

    def setSVG(self):
        attr = {'class': self.className, 'id': self.id}
        attr.update(self.style.setSVG())
        attr.update(self.xml)
        return attr

    def SVG(self, indent):
        attr = self.setSVG()
        return indent + '<' + self.name + ' ' + attributesToSVG(attr) + ' />\n'
コード例 #4
0
ファイル: base.py プロジェクト: Koperj/SahanaEden
class Element:
    def __init__ (self, **attr):
        if attr.has_key ('name'):
            self.name = attr['name']
        else:
            self.name = None
        if attr.has_key ('id'):
            self.id = attr['id']
        else:
            self.id = None
        if attr.has_key ('className'):
            self.className = attr['className']
        else:
            self.className = None
        self.parent = None
        self.style = Style ()
        self.xml = {}

    def createDef (self, element):
        if not hasattr (self, 'defs') :
            self.defs = Defs ()
        node = self.defs.getElementById (element.id)
        if node is None:
            self.defs.draw (element)
            return True
        else:
            return False

    def setSVG (self):
        attr = {'class': self.className,
                'id': self.id}
        attr.update (self.style.setSVG ())
        attr.update (self.xml)
        return attr

    def SVG (self, indent):
        attr = self.setSVG ()
        return indent + '<' + self.name + ' ' + attributesToSVG (attr) + ' />\n'