def create_colorscale(self):
    """
    create the colorscale image
    """
    #---array characteristics : thresholds and invalid values
    (val_min,val_max,invalid)=variable[self.variable][2]
    inc=float(val_max-val_min)/(self.browse_img_size[1]-1.)

    #---build an array of increasing values
    data=numpy.arange(val_max,val_min-inc,-inc, "f")
    data=numpy.repeat(data,COLORSCALE_WIDTH,0)
    data=data.reshape((COLORSCALE_WIDTH,-1))

    #---build the image of this array
    img_factory=data2img(data,colormap=self.colormap_name,val_min=val_min,val_max=val_max,invalid_val=invalid,)
    return img_factory.pil_img

def draw_colorscale_grad(self,draw):
    """
    draw the graduations of the colorscale on the given image
    """
    (val_min,val_max,invalid)=variable[self.variable][2]
    # draw the max graduation and its text
    draw.line([self.colorscale_pos,(self.colorscale_pos[0]+COLORSCALE_WIDTH+COLORSCALE_GRAD_WIDTH,self.colorscale_pos[1])],fill="#000000")
    
    # center the text
    (w,h)=draw.textsize(str(val_max),font=self.grad_font)
    draw.text((self.colorscale_pos[0]+COLORSCALE_WIDTH+COLORSCALE_GRAD_WIDTH+10,self.colorscale_pos[1]-int(h/2)),str(val_max),fill="#000000",font=self.grad_font)
    
    # draw the min graduation and its text
    draw.line([(self.colorscale_pos[0],self.colorscale_pos[1]+self.browse_img_size[1]),(self.colorscale_pos[0]+COLORSCALE_WIDTH+COLORSCALE_GRAD_WIDTH,self.colorscale_pos[1]+self.browse_img_size[1])],fill="#000000")
    draw.text((self.colorscale_pos[0]+COLORSCALE_WIDTH+COLORSCALE_GRAD_WIDTH+10,self.colorscale_pos[1]+self.browse_img_size[1]-int(h/2)),str(val_min),fill="#000000",font=self.grad_font)

#---put the colorscale
# initialize the colorscale
colorscale_img=self.create_colorscale()
#---draw the colorscale graduations
self.draw_colorscale_grad(draw)