Update of /cvsroot/freenet/freenet/src/freenet/support/graph
In directory sc8-pr-cvs1:/tmp/cvs-serv8807/src/freenet/support/graph

Modified Files:
      Tag: stable
        Bitmap.java Color.java 
Log Message:
5030: Merge minor(ish) changes from unstable:
Open Connections infolet
     Minor implementation changes on normal mode
     Show total bytes transmitted/received so far
     Much new information on the PeerHandler mode
Fixed tons of eclipse warnings (almost all are style issues, not functional changes - 
relating to logger and imports mostly). Remove deprecated FieldSet.add(String,String).
      Update TestLocalNIOInterface to current API
Make 5029 mandatory (it can't connect to us anyway, only vice versa).
If incoming HTL is 25, 50% chance of not decrementing it, so we have some plausible 
deniability when we send out an HTL 25 request (the client level HTL perturb mechanism 
is insufficient although useful).
Don't use seednodes with no physical address.
Use our own URLEncoder/URLDecoder's, catch the exceptions. We were using java's, which 
are deprecated.
Add support for deprecated options. These will be read form config file and handled, 
but will not be written to it by --config. Currently bandwidthLimit and 
averageBandwidthLimit are in this category. Separate code logs an error when these are 
set.
Change the way bandwidthLimit set but others not set, to prevent it from constantly 
getting 100% load due to bandwidth limit (0!) exceeded.
Set priority of entropy thread to MIN.
Remove old datastore code, GOOD RIDDENS!
Add a memory usage test for the Failure Table
Increase size of failure table to 20,000 (from 2,000).
Don't show the key request form in simple mode on the default infolet.
Major refactoring of HTML reporting, writing to disk, in NGRouting estimators.
Relative times in (for example) ?date= in fproxy: ?date=-1year gives the edition of a 
DBR one year ago.
NIO refactoring (ASL.ChannelAttachmentPairQueue).
Logging.


Index: Bitmap.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/graph/Bitmap.java,v
retrieving revision 1.1.6.4
retrieving revision 1.1.6.5
diff -u -w -r1.1.6.4 -r1.1.6.5
--- Bitmap.java 28 Oct 2003 20:20:45 -0000      1.1.6.4
+++ Bitmap.java 1 Nov 2003 16:55:36 -0000       1.1.6.5
@@ -8,8 +8,7 @@
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Benjamin Coates</a>
  */
-public final class Bitmap implements Surface
-{    
+public final class Bitmap implements Surface {
     private int pen;
     private Rectangle coord;
     private float x, y;
@@ -20,8 +19,7 @@
     
     private Vector pallette; // Vector of Color
     
-    public Bitmap(int width, int height)
-    {
+       public Bitmap(int width, int height) {
         // clear will set these
         pixels = null;
         pallette = null;
@@ -44,16 +42,17 @@
     }
     
     // todo: not go insane when the 257th color is selected
-    public Color setPenColor(Color c)
-    {
+       public Color setPenColor(Color c) {
         Color ret = pallette.isEmpty() ? c : (Color) pallette.elementAt(pen);
         
         pen = pallette.indexOf(c);
-       if(pen > 255) throw new IllegalArgumentException("No more colors!");
+               if (pen > 255)
+                       throw new IllegalArgumentException("No more colors!");
         
         if (pen == -1) {
             pen = pallette.size();
-           if(pen > 255) throw new IllegalArgumentException("No more colors!");
+                       if (pen > 255)
+                               throw new IllegalArgumentException("No more colors!");
             pallette.addElement(c);
         }
        
@@ -68,13 +67,9 @@
     }
     
     /**
-     * slightly odd behavior: if the Bitmap is cleared to a color different 
-     * than the current pen, the current pen will get index 1 even if no 
-     * drawing is ever done with it.  So set the pen first then clear if
-     * you care about optimal pallette usage.
+        * slightly odd behavior: if the Bitmap is cleared to a color different than 
the current pen, the current pen will get index 1 even if no drawing is ever done with 
it. So set the pen first then clear if you care about optimal pallette usage.
      */
-    public void clear(Color c)
-    {
+       public void clear(Color c) {
         // I'm going to assume memory allocation is 
         // faster than any array-setting loop i could write.
         pixels = new byte[width][height];
@@ -85,18 +80,15 @@
         setPenColor(setPenColor(c));
     }
     
-    public void moveTo(float newx, float newy)
-    {
+       public void moveTo(float newx, float newy) {
         x = newx;
         y = newy;
     }
     
     /**
-     * Draws in pixel-array coordinates px,py with the current pen,
-     * does clipping.
+        * Draws in pixel-array coordinates px,py with the current pen, does clipping.
      */
-    public void setPixel(int px, int py)
-    {
+       public void setPixel(int px, int py) {
         if (px >= 0 && px < width && py >= 0 && py < height)
             pixels[px][py] = (byte)pen;
     }
@@ -112,11 +104,11 @@
     public int getPixel(int px, int py) {
        if (px >= 0 && px < width && py >= 0 && py < height) {
            return ((pixels[px][py]) & 0xff);
-       } else return -1;
+               } else
+                       return -1;
     }
     
-    public void drawTo(float newx, float newy)
-    {
+       public void drawTo(float newx, float newy) {
         int x1 = Math.round(xPix(x));
         int y1 = Math.round(yPix(y));
         int x2 = Math.round(xPix(newx));
@@ -124,24 +116,18 @@
         
         int dx, dy, xdir, ydir;
         
-        if (x2 >= x1)
-        {
+               if (x2 >= x1) {
             dx = x2 - x1;
             xdir = 1;
-        }
-        else
-        {
+               } else {
             dx = x1 - x2;
             xdir = -1;
         }
         
-        if (y2 >= y1)
-        {
+               if (y2 >= y1) {
             dy = y2 - y1;
             ydir = 1;
-        } 
-        else
-        {
+               } else {
             dy = y1 - y2;
             ydir = -1;
         }
@@ -153,29 +139,22 @@
         // todo: initialize e based on rounding error
         int e = 0;
         
-        if (dx > dy)
-        {
+               if (dx > dy) {
             // horizontal, x-stepping version
-            for ( ; x1 != x2; x1 += xdir)
-            {
+                       for (; x1 != x2; x1 += xdir) {
                 setPixel(x1, y1);
                 e += dy;
-                if (e >= dx)
-                {
+                               if (e >= dx) {
                     y1 += ydir;
                     e -= dx;
                 }
             }
-        }
-        else
-        {
+               } else {
             // vertical, y-stepping version
-            for ( ; y1 != y2; y1 += ydir)
-            {
+                       for (; y1 != y2; y1 += ydir) {
                 setPixel(x1, y1);
                 e += dx;
-                if (e >= dy)
-                {
+                               if (e >= dy) {
                     x1 += xdir;
                     e -= dy;
                 }
@@ -185,8 +164,7 @@
         moveTo(newx, newy);            
     }
     
-    public void scaleView(Rectangle r)
-    {
+       public void scaleView(Rectangle r) {
         // scale x to between 0 and 1, then unscale it to the new coords
         x = ((x - coord.left) / (coord.left - coord.right)) * (r.left - r.right) + 
r.left;
         y = ((x - coord.top) / (coord.top - coord.bottom)) * (r.top - r.bottom) + 
r.top;
@@ -195,39 +173,31 @@
     }
     
     /**
-     * Convert from a point in user-coordinates to a point on the pixel array.
-     * use Math.round() on the result to get the actual offset into pixels.
-     * happily returns values outside the view box.
+        * Convert from a point in user-coordinates to a point on the pixel array. use 
Math.round() on the result to get the actual offset into pixels. happily returns 
values outside the view box.
      *
      * Be sure to clip based on the rounded result; -0.4 is inside the view box, -0.6 
is not.
      */
-    private float xPix(float xu)
-    {
+       private float xPix(float xu) {
         return ((xu - coord.left) / (coord.left - coord.right)) * (0.5f - (float) 
width) + 0.5f;
     }
     
-    private float yPix(float yu)
-    {
+       private float yPix(float yu) {
         return ((yu - coord.top) / (coord.top - coord.bottom)) * (0.5f - (float) 
height) + 0.5f;
     }
     
-    byte[][] getPixels()
-    {
+       byte[][] getPixels() {
         return pixels;
     }
     
-    int getWidth()
-    {
+       public int getWidth() {
         return width;
     }
     
-    int getHeight()
-    {
+       public int getHeight() {
         return height;
     }
     
-    Vector getPallette()
-    {
+       Vector getPallette() {
         return pallette;
     }
 }

Index: Color.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/graph/Color.java,v
retrieving revision 1.1.6.1
retrieving revision 1.1.6.2
diff -u -w -r1.1.6.1 -r1.1.6.2
--- Color.java  8 Apr 2003 23:49:51 -0000       1.1.6.1
+++ Color.java  1 Nov 2003 16:55:36 -0000       1.1.6.2
@@ -57,4 +57,16 @@
            return r == c.r && g == c.g && b == c.b;
        } else return false;
     }
+    public String toHexString(){
+       String sr = Integer.toHexString((int)(r & 0xFF));
+       if(sr.length() == 1)
+               sr = "0"+sr;
+               String sg = Integer.toHexString((int)(g & 0xFF));
+               if(sg.length() == 1)
+                       sg = "0"+sg;
+               String sb = Integer.toHexString((int)(b & 0xFF));
+               if(sb.length() == 1)
+                       sb = "0"+sb;
+       return sr+sg+sb;
+    }
 }

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to