Tilepublic class Tile extends Object This class is used to represent an area of the viewport. It supports both
clipping areas, in viewport coordinates (which is why it uses integers), and
dirty area management. |
Fields Summary |
---|
public int | xStart and end x tile coordinates. | public int | maxX | public int | yStart and end y tile coordinates. | public int | maxY |
Constructors Summary |
---|
public Tile()Default constructor.
| public Tile(Tile t)Copy constructor
this();
setTile(t);
| public Tile(int x, int y, int width, int height)Constructor with the Tile's coordinates.
setTile(x, y, width, height);
|
Methods Summary |
---|
public void | addSnapBox(Box b)Adds the input Box to the tile, after snapping it to the integer grid.
b.snap();
addTile((int) b.x,
(int) b.y,
(int) (b.x + b.width - 1),
(int) (b.y + b.height - 1));
| public void | addTile(com.sun.perseus.j2d.Tile t)Adds the input tile to this tile.
addTile(t.x, t.y, t.maxX, t.maxY);
| public void | addTile(int tx, int ty, int tmaxX, int tmaxY)Adds the input tile, defined by its x, y, maxX, maxY
values, to this tile.
if (tx < x) {
x = tx;
}
if (ty < y) {
y = ty;
}
if (tmaxX > maxX) {
maxX = tmaxX;
}
if (tmaxY > maxY) {
maxY = tmaxY;
}
| public boolean | isHit(com.sun.perseus.j2d.Tile t)
return
(t.maxX >= x) // Leave out tiles to the left of this tile
&&
(t.maxY >= y) // Leave out tiles to the top of this tile
&&
(t.x <= maxX) // Leave out tiles to the right of this tile
&&
(t.y <= maxY); // Leave out tiles to the bottom of this tile
| public void | setEmptyTile()Sets this tile to be empty. Actually, this sets the tile to a one pixel tile
in the top left corner of the integer coordinate grid (i.e, in Integer.MIN_VALUE,
Integer.MIN_VALUE). This tile will never intersect with any other tile.
this.x = Integer.MIN_VALUE;
this.y = Integer.MIN_VALUE;
this.maxX = Integer.MIN_VALUE;
this.maxY = Integer.MIN_VALUE;
| public void | setTile(int x, int y, int width, int height)Sets the tile's dimension and origin.
this.x = x;
this.y = y;
this.maxX = x + width - 1;
this.maxY = y + height - 1;
| public void | setTile(com.sun.perseus.j2d.Tile t)Sets this tile to the same x/y/maxX/maxY as t.
this.x = t.x;
this.y = t.y;
this.maxX = t.maxX;
this.maxY = t.maxY;
| public void | snapBox(Box b)Sets the tile so that it snaps to the smallest pixel grid which completely
contains the input Box.
if (b == null) {
x = Integer.MIN_VALUE;
y = Integer.MIN_VALUE;
maxX = Integer.MIN_VALUE;
maxY = Integer.MIN_VALUE;
} else {
b.snap();
x = (int) b.x;
y = (int) b.y;
maxX = (int) (b.x + b.width - 1);
maxY = (int) (b.y + b.height - 1);
}
| public java.lang.String | toString()Debug.
return "minX = " + x + " minY = " + y + " maxX = " + maxX + " maxY = " + maxY;
|
|