コード例 #1
0
 def plot_text_mm(self,
                  x,
                  y,
                  text,
                  style_dict=None,
                  class_=None,
                  angle=0.0,
                  dy=0.0):
     class_ = "" if class_ is None else ' class="%s"' % class_
     transform = ("" if angle == 0 else ' transform="rotate(%s %s %s)"' %
                  (angle, x, y))
     text = '<tspan dy="%s">%s</tspan>' % (dy, text) if dy != 0 else text
     s = ' <text x="%s" y="%s"%s%s%s>%s</text>\n'
     font_size = style_dict.get('font-size', 2)
     text_anchor = style_dict.get('text-anchor', 'left')
     #print "text %s in font size %s adjustment %s" % (text, font_size, text_anchor)
     length = len(text)
     x1_factor = {'left': 0, 'middle': -0.5, 'end': -1}[text_anchor]
     x2_factor = {'left': 1, 'middle': 0.5, 'end': 0}[text_anchor]
     x1 = x + x1_factor * length * font_size / 2
     y1 = y - font_size + 1
     x2 = x + x2_factor * length * font_size / 2
     y2 = y + 1
     #print "set-pixels x1-x2 %s-%s y1-y2 %s-%s" % (x1, x2, y1, y2)
     if self.pixels is None:
         is_free = True
     else:
         is_free = self.pixels.rectangle_is_empty(x1, y1, x2, y2)
     if not is_free:
         #print "text is not free %s" % text
         return ""
     if self.pixels is not None:
         self.pixels.set(x1, y1, x2, y2)
     return s % (fmt.mm2(x), fmt.mm2(y), self.style(style_dict), class_,
                 transform, text)
コード例 #2
0
ファイル: kajsvg.py プロジェクト: afrigeo/kajgps
 def plot_text_mm(self, x, y, text, style_dict=None, class_=None, angle=0.0, dy=0.0):
     class_ = "" if class_ is None else ' class="%s"' % class_
     transform = "" if angle == 0 else ' transform="rotate(%s %s %s)"' % (angle, x, y)
     text = '<tspan dy="%s">%s</tspan>' % (dy, text) if dy != 0 else text
     s = ' <text x="%s" y="%s"%s%s%s>%s</text>\n'
     font_size = style_dict.get("font-size", 2)
     text_anchor = style_dict.get("text-anchor", "left")
     # print "text %s in font size %s adjustment %s" % (text, font_size, text_anchor)
     length = len(text)
     x1_factor = {"left": 0, "middle": -0.5, "end": -1}[text_anchor]
     x2_factor = {"left": 1, "middle": 0.5, "end": 0}[text_anchor]
     x1 = x + x1_factor * length * font_size / 2
     y1 = y - font_size + 1
     x2 = x + x2_factor * length * font_size / 2
     y2 = y + 1
     # print "set-pixels x1-x2 %s-%s y1-y2 %s-%s" % (x1, x2, y1, y2)
     if self.pixels is None:
         is_free = True
     else:
         is_free = self.pixels.rectangle_is_empty(x1, y1, x2, y2)
     if not is_free:
         # print "text is not free %s" % text
         return ""
     if self.pixels is not None:
         self.pixels.set(x1, y1, x2, y2)
     return s % (fmt.mm2(x), fmt.mm2(y), self.style(style_dict), class_, transform, text)
コード例 #3
0
 def plot_rect_mm(self, x, y, width, height, style_dict=None):
     r = ' <rect x="%s" y="%s" width="%s" height="%s" %s/>\n'
     return r % (fmt.mm2(x), fmt.mm2(y), fmt.mm2(width), fmt.mm2(height),
                 self.style(style_dict))
コード例 #4
0
 def plot_line_mm(self, x1, y1, x2, y2, style_dict=None):
     line = ' <line x1="%s" y1="%s" x2="%s" y2="%s" %s/>\n'
     return line % (fmt.mm2(x1), fmt.mm2(y1), fmt.mm2(x2), fmt.mm2(y2),
                    self.style(style_dict))
コード例 #5
0
ファイル: kajsvg.py プロジェクト: afrigeo/kajgps
 def plot_rect_mm(self, x, y, width, height, style_dict=None):
     r = ' <rect x="%s" y="%s" width="%s" height="%s" %s/>\n'
     return r % (fmt.mm2(x), fmt.mm2(y), fmt.mm2(width), fmt.mm2(height), self.style(style_dict))
コード例 #6
0
ファイル: kajsvg.py プロジェクト: afrigeo/kajgps
 def plot_line_mm(self, x1, y1, x2, y2, style_dict=None):
     line = ' <line x1="%s" y1="%s" x2="%s" y2="%s" %s/>\n'
     return line % (fmt.mm2(x1), fmt.mm2(y1), fmt.mm2(x2), fmt.mm2(y2), self.style(style_dict))