Пример #1
0
    def load(self):
        """Load SVG attributes from XML attributes
		"""
        XMLElement.load(self)
        self._style.update(self.load_style())
        #transformation
        if self.has_attribute("transform"):
            txt = self.attribute("transform")
            self._transform.read(txt)
	def load (self) :
		"""Load SVG attributes from XML attributes
		"""
		XMLElement.load(self)
		self._style.update(self.load_style() )
		#transformation
		if self.has_attribute("transform") :
			txt = self.attribute("transform")
			self._transform.read(txt)
Пример #3
0
	def __init__ (self, filename) :
		XMLFileWriter.__init__(self,filename)
		doc = XMLElement(None,Document.DOCUMENT_NODE,"#document")
		comment = XMLElement(None,Document.COMMENT_NODE,"#comment")
		comment.set_attribute("data","created from python svgdraw module")
		doc.add_child(comment)
		self._svg_doc = doc
	def __init__ (self, nodeid=None, parent=None, nodename="svg") :
		"""Constructor
		
		:Parameters:
		 - `nodeid` (str) - a unique id for this node
		 - `parent` (:class:`SVGElement`) - owner of
		    this node. Default None means that this
		    element is top level.
		 - `nodename` (str) - name of this particular
		    type of node
		"""
		XMLElement.__init__(self,parent,SVG_ELEMENT_TYPE,nodename,nodeid)
		
		#graphic style
		self._style = {}
		
		#transformation
		self._transform = SVGTransform()#transformation matrix expressed
		                                #in parent frame
		                                #pos_Rparent = transform * pos_Rlocal
		
		#filename for abs path
		self._svgfilename = None
Пример #5
0
    def __init__(self, nodeid=None, parent=None, nodename="svg"):
        """Constructor
		
		:Parameters:
		 - `nodeid` (str) - a unique id for this node
		 - `parent` (:class:`SVGElement`) - owner of
		    this node. Default None means that this
		    element is top level.
		 - `nodename` (str) - name of this particular
		    type of node
		"""
        XMLElement.__init__(self, parent, SVG_ELEMENT_TYPE, nodename, nodeid)

        #graphic style
        self._style = {}

        #transformation
        self._transform = SVGTransform()  #transformation matrix expressed
        #in parent frame
        #pos_Rparent = transform * pos_Rlocal

        #filename for abs path
        self._svgfilename = None
	def save (self) :
		"""Save SVG attributes as XML attributes
		"""
		XMLElement.save(self)
		self.save_style()
		self.set_attribute("transform",self._transform.write() )
Пример #7
0
	def __init__ (self, parent=None) :
		XMLElement.__init__(self,parent,ELEMENT_TYPE,"variant")
		self._name=None
		self._scale=1.
		self._rep=None
Пример #8
0
    def save(self):
        """Save SVG attributes as XML attributes
		"""
        XMLElement.save(self)
        self.save_style()
        self.set_attribute("transform", self._transform.write())
Пример #9
0
	def save (self) :
		"""Save SVG attributes as XML attributes
		"""
		self.set_attribute("x","%f" % self._x)
		self.set_attribute("y","%f" % self._y)
		self.set_attribute("xml:space","preserve")
		
		#text fragments
		self.clear_children()
		for txt,size in self._txt_fragments :
			#span
			span = XMLElement(None,ELEMENT_TYPE,"svg:tspan")
			self.add_child(span)
			span.set_attribute("x","%f" % self._x)
			span.set_attribute("y","%f" % self._y)
			span.set_attribute("sodipodi:role","line")
			span.set_attribute("style","font-size:%s" % write_float(size) )
			#txt
			txtelm = XMLElement(None,TEXT_TYPE)
			span.add_child(txtelm)
			txtelm.set_attribute("data","%s" % txt)
		#save
Пример #10
0
	def read (self) :
		doc = parse(self._filename)
		elm = XMLElement()
		elm.load_xml(doc)
		return elm
Пример #11
0
	def from_xml (self, data) :
		doc = parseString(data)
		elm = XMLElement()
		elm.load_xml(doc)
		return elm
Пример #12
0
 def __init__(self, parent=None):
     XMLElement.__init__(self, parent, ELEMENT_TYPE, "variant")
     self._name = None
     self._scale = 1.
     self._rep = None