|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjabble.Grid
public abstract class Grid
Represents a Grid, that is a collection of points that have the topology of a Grid.
| Constructor Summary | |
|---|---|
Grid()
|
|
| Method Summary | |
|---|---|
abstract java.lang.Iterable<Point> |
blackPoints()
Returns an object usable to retrieve an iterator over all the black point of the Grid. |
static Grid |
createGrid(int... sizes)
Creates a Grid of the specified size. |
abstract int |
getDimension()
Returns the number of directions in the Grid, that is the dimension of the grid (2 for 2D, 3 for 3D, ...) |
abstract int |
getNPoints()
Returns the total number of points on the Grid. |
abstract int |
getSize(int dirIndex)
Returns the number of point along the given direction. |
abstract boolean |
isInGrid(Point point)
Returns true if the Point was defined in this Grid. |
abstract boolean |
isPeriodicBoundary(int dirIndex)
Returns true if the dirIndex direction has period boundary conditions set. |
abstract java.util.Iterator<Point> |
iterator()
Returns an iterator over all points of the Grid. |
abstract Point |
origin()
Returns the point at the corner of the grid where all coordinates are 0. |
abstract Point |
pointAt(int... location)
Returns the Point on the Grid at the given location. |
abstract void |
setPeriodicBoundaries(boolean... periodicBoundaries)
Specifies whether the boundary in each direction is periodic or not. |
abstract void |
setPeriodicBoundary(int dirIndex)
Specifies that the boundary along the dirIndex direction is going to be periodic. |
abstract java.lang.Iterable<Point> |
subgrid(int... steps)
Returns an object usable to retrieve an iterator over a subset of the points of the Grid. |
abstract java.lang.Iterable<Point> |
subgrid(Point firstPoint,
Point lastPoint)
Returns an object usable to retrieve an iterator over a subset of the points of the Grid. |
abstract java.lang.Iterable<Point> |
subgrid(Point firstPoint,
Point lastPoint,
int... steps)
Returns an object usable to retrieve an iterator over a subset of the points of the Grid. |
abstract java.lang.Iterable<Point> |
whitePoints()
Returns an object usable to retrieve an iterator over all the white point of the Grid. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Grid()
| Method Detail |
|---|
public static Grid createGrid(int... sizes)
sizes - The number of points in each direction.public abstract void setPeriodicBoundaries(boolean... periodicBoundaries)
periodicBoundaries - a true/false argument for each boundary
java.lang.IllegalArgumentException - if the number of arguments doesn't match
the number of directions of the Grid
java.lang.IllegalStateException - if one attempts to modify the periodic
boundary conditions after a Point has been requested from the Grid (it
ensures that all calculation done on the Grid is consistent)public abstract void setPeriodicBoundary(int dirIndex)
dirIndex - a direction on the Grid
java.lang.IllegalStateException - if one attempts to modify the periodic
boundary conditions after a Point has been requested from the Grid (it
ensures that all calculation done on the Grid is consistent)public abstract boolean isPeriodicBoundary(int dirIndex)
dirIndex - a direciton on the Grid
public abstract Point origin()
public abstract Point pointAt(int... location)
location - the position of the Point along each coordinate
java.lang.IllegalArgumentException - if the number of components for the location
doesn't match the number of directions of the gridpublic abstract int getSize(int dirIndex)
dirIndex - A direction of the grid.
public abstract int getNPoints()
public abstract boolean isInGrid(Point point)
point - A point
public abstract int getDimension()
public abstract java.util.Iterator<Point> iterator()
This method allows the grid to be used within an enhanced for loop as in the following example:
for (Point point : grid) {
// doSomething(point);
}
iterator in interface java.lang.Iterable<Point>public abstract java.lang.Iterable<Point> blackPoints()
You can use this method within an enhanced for loop as in the following example:
for (Point point : grid.blackPoints()) {
// doSomething(point);
}
public abstract java.lang.Iterable<Point> whitePoints()
You can use this method within an enhanced for loop as in the following example:
for (Point point : grid.whitePoints()) {
// doSomething(point);
}
public abstract java.lang.Iterable<Point> subgrid(Point firstPoint,
Point lastPoint)
subgrid(Point, Point, int...) for
futher details.
You can use this method within an enhanced for loop as in the following examples:
for (Point point : grid.subgrid(grid.pointAt(1, 1),
grid.pointAt(10, 10))) {
// doSomething(point);
}
firstPoint - the first point of the subgrid which establishes the
low end of the range for all directions in the subgridlastPoint - the last point of the subgrid which establishes the
high end of the range for all directions in the subgrid
public abstract java.lang.Iterable<Point> subgrid(int... steps)
subgrid(Point, Point, int...) for
futher details.
You can use this method within an enhanced for loop as in the following examples:
for (Point point : grid.subgrid(2, 2)) {
// doSomething(point);
}
steps - how far apart should one skip in each direction to find
the next point along that direction
public abstract java.lang.Iterable<Point> subgrid(Point firstPoint,
Point lastPoint,
int... steps)
The firstPoint and lastPoint define the area of the subgrid: the firstPoint will define the starting range for all locations of the point of the subgrid while the lastPoint will define the ending range. The steps will define how fare apart will be the next point along each direction. For example, a step of 2 in one direction will mean that only 1 point every 2 will be taken, effectively skipping half of the points.
You can use this method within an enhanced for loop as in the following examples:
for (Point point : grid.subgrid(grid.pointAt(1, 1),
grid.pointAt(10, 10),
3, 3)) {
// doSomething(point);
}
for (Point point : grid.subgrid(pointA, pointB, 2, 2)) {
// doSomething(point);
}
firstPoint - the first point of the subgrid which establishes the
low end of the range for all directions in the subgridlastPoint - the last point of the subgrid which establishes the
high end of the range for all directions in the subgridsteps - how far apart should one skip in each direction to find
the next point along that direction
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||