Graphics2D imageGraphics = (Graphics2D)gridImage.getGraphics();
setRenderingHints(imageGraphics);
imageGraphics.scale(gridScale, gridScale);
paintGridLines(imageGraphics, gridScale, 0, mainGridSize, 0, mainGridSize, gridSize, mainGridSize);
imageGraphics.dispose();
g2D.setPaint(new TexturePaint(gridImage, new Rectangle2D.Float(0, 0, mainGridSize, mainGridSize)));
g2D.fill(new Rectangle2D.Float(xMin, yMin, xMax - xMin, yMax - yMin));
} else {