Ejemplo n.º 1
0
	def load (self) :
		"""Load SVG attributes from XML attributes
		"""
		SVGCenteredElement.load(self)
		self._width = read_float(self.get_default("width","0") )
		self._height = read_float(self.get_default("height","0") )
		self._x = read_float(self.get_default("x","0") )
		self._y = read_float(self.get_default("y","0") )
Ejemplo n.º 2
0
	def load (self) :
		"""Load SVG attributes from XML attributes
		"""
		SVGElement.load(self)
		self._x = read_float(self.get_default("x","0") )
		self._y = read_float(self.get_default("y","0") )
		
		#read txt fragments
		self.clear()
		size = self.font_size()
		for txt,size in read_text_fragments(self.child(0),size) :
			self.add_text_fragment(txt,size)
		self.clear_children()
Ejemplo n.º 3
0
	def load (self) :
		"""Load SVG attributes from XML attributes
		"""
		SVGElement.load(self)
		if self.nodename() == "line" :
			x1 = read_float(self.get_default("x1","0") )
			y1 = read_float(self.get_default("y1","0") )
			x2 = read_float(self.get_default("x2","0") )
			y2 = read_float(self.get_default("y2","0") )
			self.move_to(x1,y1,False)
			self.line_to(x2,y2,False)
		elif self.nodename() in ("polyline","polygone") :
			raise NotImplementedError("polyline to path still need to be done :)")
		else :
			path_txt = self.get_default("d","")
			self.from_string(path_txt)
Ejemplo n.º 4
0
    def load(self):
        """Load SVG attributes from XML attributes
		"""
        SVGElement.load(self)
        self._width = read_float(self.get_default("width", "0"))
        self._height = read_float(self.get_default("height", "0"))
        # svg elements load
        for ind in xrange(self.nb_children()):
            try:
                svgelm = svg_element(self.child(ind))
                svgelm.from_node(self.child(ind))
                self.set_child(ind, svgelm)
                self._elms.append(svgelm)
                svgelm.load()
            except KeyError:
                pass
Ejemplo n.º 5
0
def read_text_fragments (span_node, current_size) :
	"""Read text informations in
	a set of xml nodes
	
	:Parameters:
	 - `span_node` (XMLElement) - top node
	 - `current_size` (int) - current size of txt
	
	:Return: a list of string with
	  their font size
	
	:Returns Type: list of (str,int)
	"""
	fragments = []
	#read current size
	for gr in span_node.get_default("style","").split(";") :
		if ":" in gr :
			k,v = gr.split(":")
			if k == "font-size" :
				current_size = read_float(v)
	#walk through children to find fragments
	for node in span_node.children() :
		if node.nodetype() == ELEMENT_TYPE :
			if node.nodename() == "svg:tspan" :
				for frag in read_text_fragments(node,current_size) :
					fragments.append(frag)
		elif node.nodetype() == TEXT_TYPE :
			fragments.append( (node.get_default("data",""),current_size) )
	#return
	return fragments
Ejemplo n.º 6
0
    def load(self):
        """Load SVG attributes from XML attributes
		"""
        SVGElement.load(self)
        self._width = read_float(self.get_default("width", "0"))
        self._height = read_float(self.get_default("height", "0"))
        #svg elements load
        for ind in xrange(self.nb_children()):
            try:
                svgelm = svg_element(self.child(ind))
                svgelm.from_node(self.child(ind))
                self.set_child(ind, svgelm)
                self._elms.append(svgelm)
                svgelm.load()
            except KeyError:
                pass
Ejemplo n.º 7
0
    def load(self):
        """Load SVG attributes from XML attributes
		"""
        SVGElement.load(self)
        if self.nodename() == "line":
            x1 = read_float(self.get_default("x1", "0"))
            y1 = read_float(self.get_default("y1", "0"))
            x2 = read_float(self.get_default("x2", "0"))
            y2 = read_float(self.get_default("y2", "0"))
            self.move_to(x1, y1, False)
            self.line_to(x2, y2, False)
        elif self.nodename() in ("polyline", "polygone"):
            raise NotImplementedError(
                "polyline to path still need to be done :)")
        else:
            path_txt = self.get_default("d", "")
            self.from_string(path_txt)
Ejemplo n.º 8
0
	def load (self) :
		"""Load SVG attributes from XML attributes
		"""
		SVGCenteredElement.load(self)
		self._rx = read_float(self.get_default("r",
		                      self.get_default("rx",
		                      self.get_default("sodipodi:rx","0") ) ) )
		self._ry = read_float(self.get_default("r",
		                      self.get_default("ry",
		                      self.get_default("sodipodi:ry","0") ) ) )
		self._cx = read_float(self.get_default("cx",
		                      self.get_default("sodipodi:cx","0") ) )
		self._cy = read_float(self.get_default("cy",
		                      self.get_default("sodipodi:cy","0") ) )
		self.set_nodename("svg:ellipse")
		for key in ("r","sodipodi:rx","sodipodi:ry",
		            "sodipodi:cx","sodipodi:cy",
		            "sodipodi:type","d") :
			try :
				self.remove_attribute(key)
			except KeyError :
				pass
Ejemplo n.º 9
0
	def font_size (self) :
		"""Retrieve a unique font size
		for this text.
		
		:Returns Type: int
		"""
		try :
			size = read_float(self.get_style("font-size") )
			if size is None :
				return 0.
			else :
				return size
		except KeyError :
			return 0.