Java Utililty Methods Graphics Draw Grid

List of utility methods to do Graphics Draw Grid

Description

The list of methods to do Graphics Draw Grid are organized into topic(s).

Method

voiddrawBrickGrid(Color color, Graphics2D g, int size, int maxX, int maxY)
draw Brick Grid
if (size < 1) {
    throw new IllegalArgumentException("size = " + size);
g.setColor(color);
int doubleSize = size * 2;
int y = size;
int verticalCount = 0;
while (y < maxY) {
...
voiddrawGrid(Color color, Graphics2D g, int maxX, int maxY, int hWidth, int hSpacing, int vWidth, int vSpacing, boolean emptyIntersections)
draw Grid
if (hWidth < 0) {
    throw new IllegalArgumentException("hWidth = " + hWidth);
if (vWidth < 0) {
    throw new IllegalArgumentException("vWidth = " + vWidth);
if (hSpacing <= 0) {
    throw new IllegalArgumentException("hSpacing = " + hSpacing);
...
voiddrawGrid(Graphics2D g, double lowerX, double upperX, int numX, double lowerY, double upperY, int numY)
draws a grid covering a rectangular area on the screen.
GeneralPath gp = grid(lowerX, upperX, numX, lowerY, upperY, numY);
g.draw(gp);
voiddrawIntegralCoordinateGrid(Graphics2D g, Component comp, int delta)
draws a coordinate grid with one length unit distance in each direction.
AffineTransform at = g.getTransform();
AffineTransform bt = new AffineTransform();
try {
    bt = at.createInverse();
} catch (Exception e) {
    System.out.println("Non-invertible transform");
Container c = comp.getParent();
...
voidpaintGrid(Graphics g, int width, int height, Color darkColor, Color brightColor)
paint Grid
g.setColor(darkColor);
g.fillRect(0, 0, width, height);
g.setColor(brightColor);
int inc = 5;
for (int x = 0; x < width; x += inc * 2) {
    for (int y = 0; y < height; y += inc * 2) {
        g.fillRect(x, y, inc, inc);
        g.fillRect(x + inc, y + inc, inc, inc);
...