1 43 44 package org.jfree.chart; 45 46 import java.awt.GradientPaint ; 47 import java.awt.Paint ; 48 49 54 public class HashUtilities { 55 56 64 public static int hashCodeForPaint(Paint p) { 65 if (p == null) 66 return 0; 67 int result = 0; 68 if (p instanceof GradientPaint ) { 70 GradientPaint gp = (GradientPaint ) p; 71 result = 193; 72 result = 37 * result + gp.getColor1().hashCode(); 73 result = 37 * result + gp.getPoint1().hashCode(); 74 result = 37 * result + gp.getColor2().hashCode(); 75 result = 37 * result + gp.getPoint2().hashCode(); 76 } 77 else { 78 result = p.hashCode(); 82 } 83 return result; 84 } 85 86 94 public static int hashCodeForDoubleArray(double[] a) { 95 if (a == null) { 96 return 0; 97 } 98 int result = 0; 99 long temp; 100 for (int i = 0; i < a.length; i++) { 101 temp = Double.doubleToLongBits(a[i]); 102 result = (int) (temp ^ (temp >>> 32)); 103 } 104 return result; 105 } 106 107 } 108 | Popular Tags |