Exemplo n.º 1
0
    def __init__(self, id=None):
        """Constructor
		
		:Parameters:
		 - `id` (str) - a unique id for this node
		"""
        SVGElement.__init__(self, id, None, "svg:path")
        self._commands = []
Exemplo n.º 2
0
	def __init__ (self, id=None) :
		"""Constructor
		
		:Parameters:
		 - `id` (str) - a unique id for this node
		"""
		SVGElement.__init__(self,id,None,"svg:path")
		self._commands = []
    def save(self):
        """Save SVG attributes as XML attributes
		"""
        self.set_attribute("width", "%f" % self._width)
        self.set_attribute("height", "%f" % self._height)
        SVGElement.save(self)
        # save elements in the group
        for svgelm in self.elements():
            svgelm.save()
    def save(self):
        """Save SVG attributes as XML attributes
		"""
        self.set_attribute("width", "%f" % self._width)
        self.set_attribute("height", "%f" % self._height)
        SVGElement.save(self)
        #save elements in the group
        for svgelm in self.elements():
            svgelm.save()
Exemplo n.º 5
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()
Exemplo n.º 6
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)
    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
    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
Exemplo n.º 9
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)
Exemplo n.º 10
0
    def __init__(self, width, height, id=None):
        """Constructor
		
		widht and height do not define a clipping
		box. Hence, all objects in this group do
		not necessarily lie inside (width,height)
		
		:Parameters:
		 - `width` (float) - actual width
		   of the group.
		 - `height` (float) - actual height
		   of the group
		 - `id` (str) - unique id for this element
		"""
        SVGElement.__init__(self, id, None, "svg:g")
        self._width = width
        self._height = height
        self._elms = []
Exemplo n.º 11
0
	def __init__ (self, x, y, txt, font_size = 8, id=None) :
		"""Constructor
		
		:Parameters:
		 - `x` (float) - x coordinate of the
		    top left corner of the text
		    (in svg coordinates)
		 - `y` (float) - y coordinate of the
		    top left corner of the text
		    (in svg coordinates)
		 - `txt` (str) - message to display
		 - `font_size` (int) - height of the text
		 - `id` (str) - unique id for this element
		"""
		SVGElement.__init__(self,id,None,"svg:text")
		self._x = x
		self._y = y
		self.set_text(txt,font_size)
Exemplo n.º 12
0
    def __init__(self, width, height, id=None):
        """Constructor
		
		widht and height do not define a clipping
		box. Hence, all objects in this group do
		not necessarily lie inside (width,height)
		
		:Parameters:
		 - `width` (float) - actual width
		   of the group.
		 - `height` (float) - actual height
		   of the group
		 - `id` (str) - unique id for this element
		"""
        SVGElement.__init__(self, id, None, "svg:g")
        self._width = width
        self._height = height
        self._elms = []
Exemplo n.º 13
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
Exemplo n.º 14
0
	def save (self) :
		"""Save SVG attributes as XML attributes
		"""
		path_txt = self.to_string()
		self.set_attribute("d",path_txt)
		SVGElement.save(self)
Exemplo n.º 15
0
    def save(self):
        """Save SVG attributes as XML attributes
		"""
        path_txt = self.to_string()
        self.set_attribute("d", path_txt)
        SVGElement.save(self)