public byte [ ] getColor ( float cat ) { /* First check to see if the category * value is within the range of this rule. */ float diff = cat - low ; if ( diff <= 0f ) return catColor ; // else if (diff < 0) // { // /* Category value below lowest value in this rule. */ // return new byte[]{(byte)catColor[0], (byte)catColor[1], // (byte)catColor[2], (byte)catColor[3]}; // } else if ( diff > range ) { return new byte [ ] { ( byte ) ( ( int ) ( rmul * range ) + ( int ) catColor [ 0 ] ) , ( byte ) ( ( int ) ( gmul * range ) + ( int ) catColor [ 1 ] ) , ( byte ) ( ( int ) ( bmul * range ) + ( int ) catColor [ 2 ] ) , ( byte ) catColor [ 3 ] } ; } /* Calculate the color from the gradient */ return new byte [ ] { ( byte ) ( ( int ) ( rmul * diff ) + ( int ) catColor [ 0 ] ) , ( byte ) ( ( int ) ( gmul * diff ) + ( int ) catColor [ 1 ] ) , ( byte ) ( ( int ) ( bmul * diff ) + ( int ) catColor [ 2 ] ) , ( byte ) catColor [ 3 ] } ; }
Return the colour tupple for specified category value