public static GradientMapper getGradientMapper ( int gradientType , double min , double max ) { GradientMapper gm ; switch ( gradientType ) { case BLACK_WHITE_GRADIENT : gm = new GradientMapper ( Color . BLACK , Color . WHITE ) ; gm . put ( min , Color . BLACK ) ; gm . put ( max , Color . WHITE ) ; return gm ; case WHITE_BLACK_GRADIENT : gm = new GradientMapper ( Color . WHITE , Color . BLACK ) ; gm . put ( min , Color . WHITE ) ; gm . put ( max , Color . BLACK ) ; return gm ; case RED_BLUE_GRADIENT : gm = new GradientMapper ( Color . RED , Color . BLUE ) ; gm . put ( min , Color . RED ) ; gm . put ( max , Color . BLUE ) ; return gm ; case RAINBOW_GRADIENT : { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace . getHSVColorSpace ( ) ; LinearColorInterpolator interp = new LinearColorInterpolator ( hsv ) ; interp . setInterpolationDirection ( 0 , InterpolationDirection . UPPER ) ; Color hsvLow = new Color ( hsv , new float [ ] { 0f , 1f , 1f } , 1f ) ; Color hsvHigh = new Color ( hsv , new float [ ] { 1f , 1f , 1f } , 1f ) ; gm = new GradientMapper ( hsvLow , hsvHigh , hsv ) ; gm . put ( min , hsvLow ) ; gm . put ( max , hsvHigh ) ; gm . setInterpolator ( interp ) ; return gm ; } case RAINBOW_INTENSITY_GRADIENT : { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace . getHSVColorSpace ( ) ; LinearColorInterpolator interp = new LinearColorInterpolator ( hsv ) ; interp . setInterpolationDirection ( 0 , InterpolationDirection . LOWER ) ; Color hsvLow = new Color ( hsv , new float [ ] { 1f , 1f , 1f } , 1f ) ; Color hsvHigh = new Color ( hsv , new float [ ] { 0f , 1f , 0f } , 1f ) ; gm = new GradientMapper ( hsvLow , hsvHigh , hsv ) ; gm . put ( min , hsvLow ) ; gm . put ( max , hsvHigh ) ; gm . setInterpolator ( interp ) ; return gm ; } default : throw new IllegalArgumentException ( "Unsupported gradient " + gradientType ) ; } }
Constructs a gradientMapper to draw one of the pre - defined gradients