new Rectangle(startX-1, startY-1, (endX - startX)+1, (endY - startY+1));
new Rectangle(startX, startY, (endX - startX), (endY - startY));
    public void repaintRegion(Rectangle region) {        Dimension tsize = getTileSize(zoom);        if (tsize.width <= 0 || tsize.height <= 0) return;        int toffset = (((modeFlags & PF_GRIDMODE) != 0) ? 1 : 0);        int maxExtraHeight =            (int)((myMap.getTileHeightMax() * zoom + toffset) - tsize.height);        // Calculate the visible corners of the region        int startX = region.x * tsize.width + toffset;        int startY = region.y * tsize.height + toffset - maxExtraHeight;        int endX = (region.x + region.width) * tsize.width;        int endY = (region.y + region.height) * tsize.height;        Rectangle dirty =            new Rectangle(startX-1, startY-1, (endX - startX)+1, (endY - startY+1));        repaint(dirty);    }