private void doRender(Graphics bufferedG, int w, int h, Graphics mainG, Boolean drawExtras) {
        boolean xtrans = false, ytrans = false;
        if (!ignoreRapaints) {
            if (minx < 0) {
                bufferedG.translate(-minx, 0);
//                mainG.translate(-minx, 0);
                xtrans = true;
            }
            if (miny < 0) {
                bufferedG.translate(0, -miny);
//                mainG.translate(0, -miny);
                ytrans = true;
            }
//                showTime(3);
            bufferedG.setColor(Color.white);

//                g.setClip(minx, miny, w, h);
            bufferedG.fillRect(minx, miny, w + Math.abs(minx), h + Math.abs(miny));
//                showTime(4);
//                g.clearRect(0,0, getWidth(), getHeight());

            for (PaintHandler p : prePaintHandlers)
                p.paint(mainG, this, drawExtras);
            render((Graphics2D) bufferedG, drawExtras);
//                showTime(5);

            mainG.drawImage(bi, 0, 0, this);
//                showTime(6);
            for (PaintHandler p : postPaintHandlers)
                p.paint(mainG, this, drawExtras);
        }
        if (!ignoreRapaints) {
            if (xtrans) {
                bufferedG.translate(minx, 0);
//                mainG.translate(minx, 0);
            }
            if (ytrans) {
                bufferedG.translate(0, miny);
//                mainG.translate(0, miny);
            }
        }
    }