Dimension tsize = getTileSize(zoom); if (tsize.width <= 0 || tsize.height <= 0) return; int onceX = (tsize.width - (int)(horSide * zoom)) / 2; int repeatX = tsize.width - onceX; int onceY = (tsize.height - (int)(verSide * zoom)) / 2; int repeatY = tsize.height - onceY; if (repeatX <= 0 || repeatY <= 0) return;   Rectangle clipRect = g2d.getClipBounds(); int startX = clipRect.x / repeatX; int startY = clipRect.y / repeatY; int endX = (clipRect.x + clipRect.width) / repeatX + 1; int endY = (clipRect.y + clipRect.height) / repeatY + 1; int p = startY * repeatY;   Color gridColor = g2d.getColor(); g2d.setColor(Color.gray);  for (int y = startY; y < endY; y++) { g2d.drawLine(clipRect.x, p, clipRect.x + clipRect.width - 1, p); p += repeatY; } p = startX * repeatX; for (int x = startX; x < endX; x++) { g2d.drawLine(p, clipRect.y, p, clipRect.y + clipRect.height - 1); p += repeatX; }  g2d.setColor(gridColor);
    protected void paintGrid(Graphics2D g2d, double zoom) {    }