public class Grid2D extends AbstractCompositeShape {
+ /**
+ * @param transform Grid location
+ * @param rectangle Grid dimensions
+ * @param xDivisionCount Division count along X axis
+ * @param yDivisionCount Division count along Y axis
+ * @param appearance Grid lines appearance
+ */
public Grid2D(final Transform transform, final Rectangle rectangle,
- final int divisionsX, final int divisionsY,
+ final int xDivisionCount, final int yDivisionCount,
final LineAppearance appearance) {
super(transform);
- final double stepY = rectangle.getHeight() / divisionsY;
- final double stepX = rectangle.getWidth() / divisionsX;
+ final double stepY = rectangle.getHeight() / yDivisionCount;
+ final double stepX = rectangle.getWidth() / xDivisionCount;
- for (int yslice = 0; yslice <= divisionsY; yslice++) {
- final double y = (yslice * stepY) + rectangle.getLowerY();
+ for (int ySlice = 0; ySlice <= yDivisionCount; ySlice++) {
+ final double y = (ySlice * stepY) + rectangle.getLowerY();
- for (int xslice = 0; xslice <= divisionsX; xslice++) {
- final double x = (xslice * stepX) + rectangle.getLowerX();
+ for (int xSlice = 0; xSlice <= xDivisionCount; xSlice++) {
+ final double x = (xSlice * stepX) + rectangle.getLowerX();
final Point3D p1 = new Point3D(x, y, 0);
final Point3D p2 = new Point3D(x + stepX, y, 0);
final Point3D p3 = new Point3D(x, y + stepY, 0);
- if (xslice < divisionsX)
+ if (xSlice < xDivisionCount)
addShape(appearance.getLine(p1, p2));
- if (yslice < divisionsY)
+ if (ySlice < yDivisionCount)
addShape(appearance.getLine(p1, p3));
}