Add UI to the project #29
No files matched your search
@@ -8,7 +8,6 @@ import java.util.Observable;
|
|||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
import dijkstra.VertexInterface;
|
import dijkstra.VertexInterface;
|
||||||
import maze.EBox;
|
|
||||||
import dijkstra.Dijkstra;
|
import dijkstra.Dijkstra;
|
||||||
import dijkstra.Previous;
|
import dijkstra.Previous;
|
||||||
|
|
||||||
@@ -78,17 +77,4 @@ public class MazeAppModel extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintShortestPath(Graphics2D g, int width, int height) {
|
|
||||||
|
|
||||||
g.setColor(Color.ORANGE);
|
|
||||||
int dimensionX = maze.getDimensionX();
|
|
||||||
int dimensionY = maze.getDimensionY();
|
|
||||||
int boxWidth = width/dimensionX;
|
|
||||||
int boxHeight = height/dimensionY;
|
|
||||||
for (VertexInterface vertex : shortest) {
|
|
||||||
EBox box = (EBox) vertex;
|
|
||||||
g.fillOval(box.getX()*boxHeight, box.getY()*boxWidth, boxWidth, boxHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package ui;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import maze.Maze;
|
import maze.Maze;
|
||||||
import model.MazeAppModel;
|
import model.MazeAppModel;
|
||||||
|
import maze.EBox;
|
||||||
|
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
@@ -40,4 +41,17 @@ public class MazeApp extends JFrame
|
|||||||
System.out.println("New maze detected");
|
System.out.println("New maze detected");
|
||||||
windowPanel.notifyForUpdates(param);
|
windowPanel.notifyForUpdates(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void paintShortestPath(Graphics2D g, int width, int height) {
|
||||||
|
|
||||||
|
g.setColor(Color.ORANGE);
|
||||||
|
int dimensionX = maze.getDimensionX();
|
||||||
|
int dimensionY = maze.getDimensionY();
|
||||||
|
int boxWidth = width/dimensionX;
|
||||||
|
int boxHeight = height/dimensionY;
|
||||||
|
for (VertexInterface vertex : shortest) {
|
||||||
|
EBox box = (EBox) vertex;
|
||||||
|
g.fillOval(box.getX()*boxHeight, box.getY()*boxWidth, boxWidth, boxHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user