[hamster-applet/gnome-2-28] rounding area coordinates and dimensions, when doing fillArea in canvas



commit 57fdf86738ae14c7b35a6a8a1422da036a7feedc
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Nov 16 23:35:42 2009 +0000

    rounding area coordinates and dimensions, when doing fillArea in canvas

 hamster/charting.py      |   16 ++++++++--------
 hamster/edit_activity.py |    7 +++++--
 hamster/stats.py         |    8 +++++---
 3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/hamster/charting.py b/hamster/charting.py
index 7f746ef..d98004d 100644
--- a/hamster/charting.py
+++ b/hamster/charting.py
@@ -329,30 +329,31 @@ class BarChart(Chart):
 
             bar_start = 0
             base_color = self.bar_base_color or (220, 220, 220)
-            bar_x = self.graph_x + bar_width * i + gap
+            bar_x = round(self.graph_x + bar_width * i + gap)
 
             if self.stack_keys:
                 for j in range(len(self.integrators[i])):
                     factor = self.integrators[i][j].value
     
                     if factor > 0:
-                        bar_size = max_bar_size * factor
+                        bar_size = round(max_bar_size * factor)
                         bar_start += bar_size
                         
                         self.draw_bar(bar_x,
                                       self.graph_height - bar_start,
-                                      bar_width - (gap * 2),
+                                      round(bar_width - (gap * 2)),
                                       bar_size,
                                       self.get_bar_color(j))
             else:
                 factor = self.integrators[i].value
-                bar_size = max_bar_size * factor
+                bar_size = round(max_bar_size * factor)
                 bar_start = bar_size
 
                 self.draw_bar(bar_x,
                               self.graph_y + self.graph_height - bar_size,
-                              bar_width - (gap * 2),
-                              bar_size, base_color)
+                              round(bar_width - (gap * 2)),
+                              bar_size,
+                              base_color)
 
         #fill with white background (necessary for those dragging cases)
         if self.background:
@@ -529,8 +530,7 @@ class HorizontalBarChart(Chart):
                 bar_size = round(max_bar_size * factor)
                 bar_start = bar_size
 
-                bar_height = bar_width - (gap * 2)
-                
+                bar_height = round(bar_width - (gap * 2))
                 self.draw_bar(self.graph_x, bar_y, bar_size, bar_height,
                                                                      base_color)
 
diff --git a/hamster/edit_activity.py b/hamster/edit_activity.py
index 6ec860b..14383b9 100644
--- a/hamster/edit_activity.py
+++ b/hamster/edit_activity.py
@@ -268,8 +268,11 @@ class Dayline(graphics.Area):
             if self.get_pixel(end_minutes) > 0 and \
                 self.get_pixel(start_minutes) < self.width:
                     context.set_source_rgba(0.86, 0.86, 0.86, 0.5)
-                    context.rectangle(self.get_pixel(start_minutes), graph_y,
-                                      self.get_pixel(end_minutes) - self.get_pixel(start_minutes), graph_height - 1)
+
+                    context.rectangle(round(self.get_pixel(start_minutes)),
+                                      graph_y,
+                                      round(self.get_pixel(end_minutes) - self.get_pixel(start_minutes)),
+                                      graph_height - 1)
                     context.fill()
                     context.stroke()
 
diff --git a/hamster/stats.py b/hamster/stats.py
index 79fcb6e..83bf1e1 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -286,9 +286,11 @@ class TimeLine(graphics.Area):
                             total_length += fact["delta"]
                         total_length = total_length.seconds / 60 / 60.0 + total_length.days * 24
                         total_length = total_length / float(self.max_hours) * self.height - 16
-                        self.fill_area(ticker_pos * self.x_factor,
-                                       self.height - total_length,
-                                       self.x_factor, total_length,
+
+                        self.fill_area(round(ticker_pos * self.x_factor),
+                                       round(self.height - total_length),
+                                       round(self.x_factor),
+                                       round(total_length),
                                        (190,190,190))
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]