public void drawArray(final double[] a, final double min, final double max, final long[] col, final int size,
                          final int ncol)
    {
        old_a = a;
        old_min = min;
        old_max = max;
        old_col = col;
        old_size = size;
        old_ncol = ncol;

        int MARGIN;
        double mag;
        int wi,he,x,y,column;
        final int x0,y0,nrow;
        int R,G,B;
        boolean first;
        long v;
        Color c;
        final Graphics  g=canvas.getGraphics();
        final Dimension d=canvas.getSize();

        first=false;

        if (old_he==null)
        {
            old_he=new int[size];
            first=true;
        }

        MARGIN = d.width / 50;
        if ((d.height / 50) <MARGIN)
            MARGIN=d.height/50;

        final double yy=1.0*size/ncol;
        nrow=(int)(yy+0.9999);
        wi=(d.width/2-MARGIN-ncol)/ncol;

        if (wi>((d.height/2-MARGIN-nrow)/nrow))
            wi=(d.height/2-MARGIN-nrow)/nrow;
        wi=wi*2+1;

        column=0;
        x0=(d.width-(wi+1)*ncol)/2;
        y0=(d.height-(wi+1)*nrow)/2;
        x=x0; y=y0;

        Lastncol=ncol;
        Lastnrow=nrow;
        Lastx0  =x0;
        Lasty0  =y0;
        Lastwi  =wi;
        Lastsize=size;
        Lastdrawn=true;

        for (int i=0;i<size;i++)
        {
            mag=((a[i])/(max-min))*wi;
            he=(int)mag;

            if (col==null)
                c=Color.white;
            else
            {
                v=col[i];
                R=(int)(v>>16); v=v%(1<<16);
                G=(int)(v>>8) ; v=v%(1<<8);
                B=(int)v;
                c=new Color(R,G,B);
            }
            if (old_he[i]!=he || first)
                drawSArea(g,x,y,wi,he,c);
            old_he[i]=he;
            x+=wi+1; column++;
            if (column>=ncol)
            {
                column=0; y+=wi+1; x=x0;
            }
        }
    }