private static void paintGrid(Graphics g, ImageComponent ic) {
    Dimension size = ic.getCanvasSize();
    BufferedImage image = ic.getDocument().getValue();
    int imageWidth = image.getWidth();
    int imageHeight = image.getHeight();
    double zoomX = (double)size.width / (double)imageWidth;
    double zoomY = (double)size.height / (double)imageHeight;
    double zoomFactor = (zoomX + zoomY) / 2.0d;
    if (zoomFactor >= ic.getGridLineZoomFactor()) {
      g.setColor(ic.getGridLineColor());
      int ls = ic.getGridLineSpan();
      for (int dx = ls; dx < imageWidth; dx += ls) {
        LinePainter2D.paint((Graphics2D)g, (int)((double)dx * zoomX), 0, (int)((double)dx * zoomX), size.height);
      }
      for (int dy = ls; dy < imageHeight; dy += ls) {
        LinePainter2D.paint((Graphics2D)g, 0, (int)((double)dy * zoomY), size.width, (int)((double)dy * zoomY));
      }
    }
  }
private static void paintGrid(Graphics g, ImageComponent ic)