refactoring, deploy Position and XYGridIterator
- try to use more Position instead of (x,y) - create PositionWithDpeth for its specific usage in path finding - create a XYGridITerator that walk cells from grid X then Y.
This commit is contained in:
@@ -82,25 +82,25 @@ public class MazeCellRenderer {
|
||||
Math.max(0,color.getBlue() - greylevel));
|
||||
return greyedColor;
|
||||
}
|
||||
public void drawBackground(Graphics g, int pX, int pY, short walls) {
|
||||
int x = offsetX + (int) (pX * width);
|
||||
int y = offsetY + (int) (pY * height);
|
||||
public void drawBackground(Graphics g, Position cell, short walls) {
|
||||
int x = offsetX + (int) (cell.getX() * width);
|
||||
int y = offsetY + (int) (cell.getY() * height);
|
||||
Color savecolor = g.getColor();
|
||||
int greylevel = walls << 2;
|
||||
g.setColor(getGreyedColor(savecolor,greylevel));
|
||||
//g.fillRect(x+1,y+1,((int)width) -1,((int)height) - 1);
|
||||
g.fillRect(x,y,((int)width),((int)height));
|
||||
}
|
||||
public void drawWalls(Graphics g, int pX, int pY, short walls) {
|
||||
int x = offsetX + (int) (pX * width);
|
||||
int y = offsetY + (int) (pY * height);
|
||||
if ((pY == 0) && ( Brick.isFlagSet( Brick.UP, walls)))
|
||||
public void drawWalls(Graphics g, Position cell, short walls) {
|
||||
int x = offsetX + (int) (cell.getX() * width);
|
||||
int y = offsetY + (int) (cell.getY() * height);
|
||||
if ((cell.getY() == 0) && ( Brick.isFlagSet( Brick.UP, walls)))
|
||||
g.drawLine(x, y, x + (int) width, y);
|
||||
if (Brick.isFlagSet( Brick.DOWN, walls))
|
||||
g.drawLine(x, y + (int) height, x + (int) width, y + (int) height);
|
||||
if (Brick.isFlagSet( Brick.RIGHT, walls))
|
||||
g.drawLine(x + (int) width, y, x + (int) width, y + (int) height);
|
||||
if ((pX == 0) && (Brick.isFlagSet( Brick.LEFT, walls)))
|
||||
if ((cell.getX() == 0) && (Brick.isFlagSet( Brick.LEFT, walls)))
|
||||
g.drawLine(x, y, x, y + (int) height);
|
||||
}
|
||||
|
||||
@@ -145,23 +145,23 @@ public class MazeCellRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawDot(Graphics g, Position dot, int pX, int pY, int mX, int mY) {
|
||||
public void drawDot(Graphics g, Position dot, Position min, Position max) {
|
||||
double h = getHeight();
|
||||
double radius = (h > width) ? width : h;
|
||||
int a = (int) (radius / 4);
|
||||
if ((dot.getX() >= pX) && (dot.getY() >= pY) && (dot.getX() < mX) && (dot.getY() < mY)) {
|
||||
if ((dot.getX() >= min.getX()) && (dot.getY() >= min.getY()) && (dot.getX() < max.getX()) && (dot.getY() < max.getY())) {
|
||||
int x = offsetX + (int) (dot.getX() * width);
|
||||
int y = offsetY + (int) (dot.getY() * h);
|
||||
int r2 = (int) radius ; //(int) ((radius * 3) / 4);
|
||||
g.drawOval(x, y, r2, r2);
|
||||
// g.drawLine(x+a,y+a,x+width-a,y+height-a);
|
||||
// g.drawLine(x+a,y+height-a,x+width-a,y+a);
|
||||
|
||||
} else {
|
||||
int x = offsetX + (int) (pX * width);
|
||||
int y = offsetY + (int) (pY * h);
|
||||
}
|
||||
/* why do we drwa anything at all ?
|
||||
else {
|
||||
int x = offsetX + (int) (min.getX() * width);
|
||||
int y = offsetY + (int) (min.getY() * h);
|
||||
g.drawLine(x + 1, y + 1, x + (int) width - 1, y + (int) h - 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user