public static RGB hsv (int hue, float saturation, float value) {
    // from http://www.cs.rit.edu/~ncs/color/t_convert.html

    float red = 0, green = 0, blue = 0;

    if (saturation == 0)
      // achromatic (grey)
      red = green = blue = value;

    else {
      float h = hue / 60;      
      int sector = (int) Math.floor (h); // sector 0 to 5
      float fraction = h - sector;

      float v = value;
      float p = value * (1 - saturation);
      float q = value * (1 - saturation * fraction);
      float t = value * (1 - saturation * (1 - fraction));

      switch (sector) {
      case 0:
        red = v;
        green = t;
        blue = p;
        break;

      case 1:
        red = q;
        green = v;
        blue = p;
        break;

      case 2:
        red = p;
        green = v;
        blue = t;
        break;

      case 3:
        red = p;
        green = q;
        blue = v;
        break;

      case 4:
        red = t;
        green = p;
        blue = v;
        break;

      case 5:
        red = v;
        green = p;
        blue = q;
        break;
      }
    }
    
    return new RGB ((int) red*0xffff, (int) green*0xffff, (int) blue*0xffff);    
  }