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

Modified Files:
        Bitmap.java 
Log Message:
Made getWidth() and getHeight() public

Index: Bitmap.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/graph/Bitmap.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- Bitmap.java 30 Aug 2003 23:16:54 -0000      1.5
+++ Bitmap.java 29 Oct 2003 23:06:55 -0000      1.6
@@ -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;
     }
 }

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

Reply via email to