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

Modified Files:
        Color.java 
Log Message:
Was a very stupid idea to make the add and subtract methods members of the class.. 
You'll never know when some code you call will modify the Color instance you supply to 
it.. Make them static instead.

Index: Color.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/graph/Color.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- Color.java  3 Nov 2003 15:23:59 -0000       1.4
+++ Color.java  3 Nov 2003 16:19:13 -0000       1.5
@@ -19,15 +19,11 @@
         b = (byte) blue;
     }
     
-    public void subtract(Color other){
-       r = (byte)Math.max(0,getRedAsInt()-other.getRedAsInt());
-               g = (byte)Math.max(0,getGreenAsInt()-other.getGreenAsInt());
-               b = (byte)Math.max(0,getBlueAsInt()-other.getBlueAsInt());
+    public static Color subtract(Color nr1,Color nr2){
+       return new 
Color(Math.max(0,nr1.getRedAsInt()-nr2.getRedAsInt()),Math.max(0,nr1.getGreenAsInt()-nr2.getGreenAsInt()),Math.max(0,nr1.getBlueAsInt()-nr2.getBlueAsInt()));
     }
-       public void add(Color other){
-               r = (byte)Math.min(255,getRedAsInt()+other.getRedAsInt());
-               g = (byte)Math.min(255,getGreenAsInt()+other.getGreenAsInt());
-               b = (byte)Math.min(255,getBlueAsInt()+other.getBlueAsInt());
+       public static Color add(Color nr1,Color nr2){
+               return new 
Color(Math.min(255,nr1.getRedAsInt()+nr2.getRedAsInt()),Math.min(255,nr1.getGreenAsInt()+nr2.getGreenAsInt()),Math.min(255,nr1.getBlueAsInt()+nr2.getBlueAsInt()));
        }
     
     /**

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

Reply via email to