gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r2511 - gnunet-gtk/src/plugins/stats


From: grothoff
Subject: [GNUnet-SVN] r2511 - gnunet-gtk/src/plugins/stats
Date: Tue, 14 Mar 2006 22:44:45 -0800 (PST)

Author: grothoff
Date: 2006-03-14 22:44:35 -0800 (Tue, 14 Mar 2006)
New Revision: 2511

Modified:
   gnunet-gtk/src/plugins/stats/functions.c
   gnunet-gtk/src/plugins/stats/statistics.c
Log:
fixing Mantis 1003

Modified: gnunet-gtk/src/plugins/stats/functions.c
===================================================================
--- gnunet-gtk/src/plugins/stats/functions.c    2006-03-15 05:37:43 UTC (rev 
2510)
+++ gnunet-gtk/src/plugins/stats/functions.c    2006-03-15 06:44:35 UTC (rev 
2511)
@@ -115,7 +115,7 @@
                         NULL,
                         "# of connected peers"))
     return SYSERR;
-  data[0][0] = 0.8 * val / connectionGoal;
+  data[0][0] = ((gfloat) val) / connectionGoal;
   return OK;
 }
 
@@ -128,7 +128,7 @@
                         NULL,
                        "% of allowed cpu load"))
     return SYSERR;
-  data[0][0] = val / 125.0;
+  data[0][0] = (gfloat) val / 100.0;
   return OK;
 }
 
@@ -196,10 +196,10 @@
     data[0][3] = 0.0;
     return OK;
   }
-  data[0][0] = 0.8 * noise / (banddown * dtime / cronSECONDS); /* red */
-  data[0][1] = 0.8 * (content+noise) / (banddown * dtime / cronSECONDS); /* 
green */
-  data[0][2] = 0.8 * (queries+content+noise) / (banddown * dtime / 
cronSECONDS); /* yellow */
-  data[0][3] = 0.8 * total / (banddown * dtime / cronSECONDS); /* blue */
+  data[0][0] = ((gfloat) noise) / (banddown * dtime / cronSECONDS); /* red */
+  data[0][1] = ((gfloat) (content+noise)) / (banddown * dtime / cronSECONDS); 
/* green */
+  data[0][2] = ((gfloat)(queries+content+noise)) / (banddown * dtime / 
cronSECONDS); /* yellow */
+  data[0][3] = ((gfloat) total) / (banddown * dtime / cronSECONDS); /* blue */
   /*printf("I: %f %f %f\n",
         data[0][0],
         data[0][1],
@@ -248,7 +248,7 @@
   i = 0;
   SNPRINTF(buffer,
           512,
-           "# bytes received of type %d",
+           "# bytes transmitted of type %d",
           P2P_PROTO_gap_QUERY);
   if (OK != getStatValue(&queries,
                         &lqueries,
@@ -271,10 +271,10 @@
     data[0][3] = 0.0;
     return OK;
   }
-  data[0][0] = 0.8 * noise / (bandup * dtime / cronSECONDS); /* red */
-  data[0][1] = 0.8 * (noise + content) / (bandup*dtime / cronSECONDS); /* 
green */
-  data[0][2] = 0.8 * (noise + content + queries) / (bandup*dtime / 
cronSECONDS); /* yellow */
-  data[0][3] = 0.8 * total / (bandup*dtime / cronSECONDS); /* blue */
+  data[0][0] = ((gfloat) noise) / (bandup * dtime / cronSECONDS); /* red */
+  data[0][1] = ((gfloat) (noise + content)) / (bandup*dtime / cronSECONDS); /* 
green */
+  data[0][2] = ((gfloat) (noise + content + queries)) / (bandup*dtime / 
cronSECONDS); /* yellow */
+  data[0][3] = ((gfloat) total) / (bandup*dtime / cronSECONDS); /* blue */
   /* printf("O: %f %f %f\n",
      data[0][0],
      data[0][1],

Modified: gnunet-gtk/src/plugins/stats/statistics.c
===================================================================
--- gnunet-gtk/src/plugins/stats/statistics.c   2006-03-15 05:37:43 UTC (rev 
2510)
+++ gnunet-gtk/src/plugins/stats/statistics.c   2006-03-15 06:44:35 UTC (rev 
2511)
@@ -67,6 +67,8 @@
   guint j;
   gint dely;
   float delx;
+  float max;
+  GdkFont * font;
 
   if (!g->disp->window)
     return;
@@ -111,13 +113,48 @@
                      g->draw_width,
                      g->disp->allocation.height);
 
-  dely = g->draw_height / 5;
-  for (i = 1; i <5; i++) {
+  max = 0.26; /* force showing at least the 25% line */
+  for (i = 0; i < g->num_points - 1; i++) 
+    for (j=0;j<g->count;j++) 
+      if (g->data[i][j] > max)
+       max = g->data[i][j];
+  max = max * 1.01; /* leave top 1% free */
+
+  font = gdk_font_load("fixed"); /* deprecated, but pango is far more than
+                                   what we need here -- fix later? */
+  /* draw lines at 25%, 50%, 75% and 100% of max */
+  dely = g->draw_height / max / 4;
+  for (i = 1; i < 5; i++) {
     gint y1 = g->draw_height + 1 - i * dely;
-    gdk_draw_line (g->pixmap, g->gc,
-                  0, y1, g->draw_width, y1);
+    if ( (dely < 30) && (i != 4) )
+      continue; /* only print additional 
+                  lines if there is enough space! */
+    if (y1 > 0) {
+      const gchar * label[] = {
+       NULL,
+       " 25%",
+       " 50%",
+       " 75%",
+       "100%",
+      };
+      gdk_draw_string(g->pixmap,
+                     font,
+                     g->gc,
+                     10,
+                     y1 - 8,
+                     label[i]);
+      gdk_draw_line (g->pixmap, g->gc,
+                    0, y1, g->draw_width, y1);
+      if (i == 4) {
+       /* extra-thick line at 100% */
+       gdk_draw_line (g->pixmap, g->gc,
+                      0, y1 - 1, g->draw_width, y1 - 1);
+       gdk_draw_line (g->pixmap, g->gc,
+                      0, y1 + 1, g->draw_width, y1 + 1);
+       
+      }
+    }
   }
-
   gdk_gc_set_line_attributes(g->gc,
                             2,
                             GDK_LINE_SOLID,
@@ -130,8 +167,8 @@
     for (i = 0; i < g->num_points - 1; i++) {
       gint x1 = i * delx;
       gint x2 = (i + 1) * delx;
-      gint y1 = g->data[i][j] * g->draw_height - 1;
-      gint y2 = g->data[i+1][j] * g->draw_height - 1;
+      gint y1 = g->data[i][j] / max * g->draw_height - 1;
+      gint y2 = g->data[i+1][j] / max * g->draw_height - 1;
 
       if ((g->data[i][j] != -1) && (g->data[i+1][j] != -1)) {
        if (stats[g->statIdx].fill == NO) {
@@ -153,8 +190,8 @@
            points[2].y = g->draw_height;
            points[3].y = g->draw_height;
          } else {
-           gint ly1 = g->data[i][j-1] * g->draw_height - 1;
-           gint ly2 = g->data[i+1][j-1] * g->draw_height - 1;
+           gint ly1 = g->data[i][j-1] / max * g->draw_height - 1;
+           gint ly2 = g->data[i+1][j-1] / max * g->draw_height - 1;
            points[2].y = g->draw_height - ly1;
            points[3].y = g->draw_height - ly2;
          }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]