minor chnages / renaming / path painting

- draw resolved path as showAll correctly
it was displaying all direction of same cell as solution while only one direction is ok
- Renderer renaming for class rendering cells
- draw directions as arrows
This commit is contained in:
philippe lhardy
2020-12-28 13:16:35 +01:00
parent afbe26065b
commit 0bab1d51b1
7 changed files with 58 additions and 44 deletions

View File

@@ -27,7 +27,7 @@ public class MazeComponent
private static final long serialVersionUID = 3163272907991176390L;
LabyModelProvider map;
final MazeCellParameters cp;
final MazeCellRenderer cp;
Position current = null;
LinkedList<DirectionPosition> solvedPath = null;
LinkedList<DirectionPosition> drawingPath = null;
@@ -216,7 +216,7 @@ public class MazeComponent
* offsetX, offsetY of upper left corner
**/
// public MazeComponent(WallsProvider map, MazeCellParameters cp)
public MazeComponent(LabyModel map, MazeCellParameters cp, StatusListener statusListener) {
public MazeComponent(LabyModel map, MazeCellRenderer cp, StatusListener statusListener) {
super();
this.cp = cp;
this.map = map;
@@ -350,22 +350,6 @@ public class MazeComponent
}
}
pX = aX;
pY = aY;
synchronized (lockChange) {
g.setColor(colorMap.goal);
if (current != null) {
cp.drawDot(g, current, pX, pY, mX, mY);
}
if (solvedPath != null) {
for (DirectionPosition resolved : solvedPath) {
// cp.drawDot(g, resolved.getPosition(), pX, pY, mX, mY);
cp.drawPath(g, resolved, pX, pY, mX, mY);
}
}
}
if (this.showAll) {
statusListener.addStatus("*");
pX = aX;
@@ -375,11 +359,7 @@ public class MazeComponent
for (; pY < mY; pY++) {
for (pX = 0; pX < mX; pX++) {
path = map.getPath(pX, pY);
if ((path & LabyModel.SOLVED) == LabyModel.SOLVED) {
g.setColor(colorMap.resolved_path);
} else {
g.setColor(colorMap.path);
}
g.setColor(colorMap.path);
if (path != 0) {
DirectionPosition dp = new DirectionPosition(path, new Position(pX, pY));
cp.drawPath(g, dp, pX, pY, pX + 1, pY + 1);
@@ -387,6 +367,24 @@ public class MazeComponent
}
}
}
pX = aX;
pY = aY;
synchronized (lockChange) {
g.setColor(colorMap.goal);
if (current != null) {
cp.drawDot(g, current, pX, pY, mX, mY);
}
g.setColor(colorMap.resolved_path);
if (solvedPath != null) {
for (DirectionPosition resolved : solvedPath) {
cp.drawDot(g, resolved.getPosition(), pX, pY, mX, mY);
cp.drawPath(g, resolved, pX, pY, mX, mY);
}
}
}
}
@@ -402,9 +400,15 @@ public class MazeComponent
}
public void notifySearchError(String error) {
System.err.println(error);
notifySearchInfoLevel(0,error);
}
public void notifySearchInfoLevel(int infoLevel, String pInfo)
{
statusListener.addStatus(pInfo);
}
public void notifyCompletion(LinkedList<DirectionPosition> solvedPath) {
LinkedList<DirectionPosition> newPath = new LinkedList<>(solvedPath);
statusListener.addStatus("resolution completed");