Пример #1
0
	def calc_label_dimension(self, scale, is_height, major_selector, minor_selector):
		"""
		Calculates the maximum width/height of a scale's labels.
		"""
		
		major_style = self.style[major_selector]
		minor_style = self.style[minor_selector]
		
		# Work out the maxiumum label width
		max_size = 0
		for linepos, title, is_major in scale.get_lines():
			
			label_style = (is_major and major_style or minor_style).sub('label')
			
			width, height = text_bounds(
				title,
				label_style.get_float("font-size"), 
				label_style.get_font(),
				label_style.get_cairo_font_style(),
				label_style.get_cairo_font_weight(),
			)
			padding = label_style.get_float("padding")
			
			max_size = max(max_size, is_height and height or width + padding)
		return max_size
Пример #2
0
    def calc_label_dimension(self, scale, is_height, major_selector,
                             minor_selector):
        """
        Calculates the maximum width/height of a scale's labels.
        """

        major_style = self.style[major_selector]
        minor_style = self.style[minor_selector]

        # Work out the maxiumum label width
        max_size = 0
        for linepos, title, is_major in scale.get_lines():

            label_style = (is_major and major_style
                           or minor_style).sub('label')

            width, height = text_bounds(
                title,
                label_style.get_float("font-size"),
                label_style.get_font(),
                label_style.get_cairo_font_style(),
                label_style.get_cairo_font_weight(),
            )
            padding = label_style.get_float("padding")

            max_size = max(max_size, is_height and height or width + padding)
        return max_size
Пример #3
0
    def calc_plot_height(self):

        # Are we ignoring the bottom labels?
        if self.no_bottom_labels:
            self.plot_height = self.height
            return

        major_style = self.style['linegraph grid.major']
        minor_style = self.style['linegraph grid.minor']

        # Work out the maxiumum label width
        max_height = 0
        for linepos, title, ismajor in self.scale.get_lines():

            if ismajor:
                this_style = major_style
            else:
                this_style = minor_style

            label_style = this_style.sub('label')

            width, height = text_bounds(
                title,
                label_style.get_float("font-size"),
                label_style.get_font(),
                label_style.get_cairo_font_style(),
                label_style.get_cairo_font_weight(),
            )
            padding = label_style.get_float("padding")

            max_height = max(max_height, height + padding)
        self.plot_height = self.height - max_height
Пример #4
0
	def calc_plot_height(self):
		
		# Are we ignoring the bottom labels?
		if self.no_bottom_labels:
			self.plot_height = self.height
			return
		
		major_style = self.style['linegraph grid.major']
		minor_style = self.style['linegraph grid.minor']
		
		# Work out the maxiumum label width
		max_height = 0
		for linepos, title, ismajor in self.scale.get_lines():
			
			if ismajor:
				this_style = major_style
			else:
				this_style = minor_style
			
			label_style = this_style.sub('label')
			
			width, height = text_bounds(
				title,
				label_style.get_float("font-size"), 
				label_style.get_font(),
				label_style.get_cairo_font_style(),
				label_style.get_cairo_font_weight(),
			)
			padding = label_style.get_float("padding")
			
			max_height = max(max_height, height + padding)
		self.plot_height = self.height - max_height
Пример #5
0
	def get_text_ratio(self, text):
		from graphication.text import text_bounds
		
		w, h = text_bounds(text, 10, self.style['wavegraph curve label'].get_font())
		
		if h and w:
			return (w/float(h))
		else:
			return 1
Пример #6
0
    def get_text_ratio(self, text):
        from graphication.text import text_bounds

        w, h = text_bounds(text, 10,
                           self.style['wavegraph curve label'].get_font())

        if h and w:
            return (w / float(h))
        else:
            return 1