Fixing lines and spaces and restoring labyOutput
This commit is contained in:
16 files changed
+45
-55
No files matched your search
@@ -7,5 +7,4 @@ public class ArrivalDrawingBox extends DrawingBox {
|
||||
public ArrivalDrawingBox(MazeApp mazeApp, Color color) {
|
||||
super(mazeApp, color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,5 +7,4 @@ public class DepartureDrawingBox extends DrawingBox {
|
||||
public DepartureDrawingBox(MazeApp mazeApp, Color color) {
|
||||
super(mazeApp, color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,12 @@ public abstract class DrawingBox extends JPanel {
|
||||
|
||||
private final MazeApp mazeApp;
|
||||
private Color color;
|
||||
|
||||
|
||||
public DrawingBox(MazeApp mazeApp, Color color) {
|
||||
|
||||
|
||||
this.mazeApp = mazeApp;
|
||||
this.color = color;
|
||||
|
||||
|
||||
setBackground(color);
|
||||
setPreferredSize(new Dimension(40,40));
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@ public class DrawingPanelGrid extends JPanel {
|
||||
private Maze maze;
|
||||
private int dimensionX;
|
||||
private int dimensionY;
|
||||
|
||||
|
||||
public DrawingPanelGrid(MazeApp mazeApp) {
|
||||
|
||||
|
||||
this.mazeApp = mazeApp;
|
||||
this.maze = mazeApp.getMazeAppModel().getMaze();
|
||||
this.dimensionX = maze.getDimensionX();
|
||||
this.dimensionY = maze.getDimensionY();
|
||||
|
||||
|
||||
setLayout(new GridLayout(this.dimensionX, this.dimensionY));
|
||||
initFromMaze(maze);
|
||||
|
||||
|
||||
setPreferredSize(new Dimension(256, 256));
|
||||
}
|
||||
|
||||
|
||||
private void initFromMaze(Maze maze) {
|
||||
|
||||
int dimensionX = maze.getDimensionX();
|
||||
int dimensionY = maze.getDimensionY();
|
||||
|
||||
|
||||
for (int i = 0; i < dimensionX; i++) {
|
||||
for (int j = 0; j < dimensionY; j++) {
|
||||
if (maze.getMaze()[j][i].isWalkable()) {
|
||||
@@ -49,6 +49,5 @@ public class DrawingPanelGrid extends JPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,4 @@ public class EmptyDrawingBox extends DrawingBox {
|
||||
public EmptyDrawingBox(MazeApp mazeApp, Color color) {
|
||||
super(mazeApp, color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,15 +7,13 @@ public class FileMenu extends JMenu {
|
||||
private final MazeApp mazeApp;
|
||||
private final QuitMenuItem quitMenuItem;
|
||||
private final LoadMazeMenuItem loadMazeMenuItem;
|
||||
|
||||
|
||||
public FileMenu(MazeApp mazeApp) {
|
||||
|
||||
|
||||
super("File");
|
||||
this.mazeApp = mazeApp;
|
||||
|
||||
|
||||
add(quitMenuItem = new QuitMenuItem(mazeApp));
|
||||
add(loadMazeMenuItem = new LoadMazeMenuItem(mazeApp));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,14 +15,14 @@ public class LoadMazeMenuItem extends JMenuItem
|
||||
implements ActionListener {
|
||||
|
||||
private final MazeApp mazeApp;
|
||||
|
||||
|
||||
public LoadMazeMenuItem(MazeApp mazeApp) {
|
||||
|
||||
super("Load maze");
|
||||
this.mazeApp = mazeApp;
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
|
||||
MazeAppModel mazeAppModel = mazeApp.getMazeAppModel();
|
||||
|
||||
+6
-6
@@ -5,24 +5,24 @@ import maze.Maze;
|
||||
import model.MazeAppModel;
|
||||
|
||||
public class MazeApp extends JFrame {
|
||||
|
||||
|
||||
private final MazeMenuBar mazeMenuBar;
|
||||
private final WindowPanel windowPanel;
|
||||
private MazeAppModel mazeAppModel = new MazeAppModel();
|
||||
|
||||
public MazeApp() {
|
||||
|
||||
|
||||
super("Maze Solving Application");
|
||||
|
||||
|
||||
setJMenuBar(mazeMenuBar = new MazeMenuBar(this));
|
||||
setContentPane(windowPanel = new WindowPanel(this)) ;
|
||||
|
||||
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
public MazeAppModel getMazeAppModel() {
|
||||
return mazeAppModel;
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ public class MazeMenuBar extends JMenuBar {
|
||||
|
||||
private final MazeApp mazeApp;
|
||||
private final FileMenu fileMenu;
|
||||
|
||||
|
||||
public MazeMenuBar(MazeApp mazeApp) {
|
||||
|
||||
|
||||
super();
|
||||
this.mazeApp = mazeApp;
|
||||
|
||||
|
||||
add(fileMenu = new FileMenu(mazeApp));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,18 +12,18 @@ public class QuitMenuItem extends JMenuItem
|
||||
implements ActionListener {
|
||||
|
||||
private final MazeApp mazeApp;
|
||||
|
||||
|
||||
public QuitMenuItem(MazeApp mazeApp) {
|
||||
|
||||
super("Quit");
|
||||
this.mazeApp = mazeApp;
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
|
||||
MazeAppModel mazeAppModel = mazeApp.getMazeAppModel();
|
||||
|
||||
|
||||
if (mazeAppModel.isModified()) {
|
||||
int response = JOptionPane.showInternalOptionDialog(this,
|
||||
"Maze not saved. Save it ?",
|
||||
@@ -41,6 +41,6 @@ public class QuitMenuItem extends JMenuItem
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.exit(0) ;
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,4 @@ public class WallDrawingBox extends DrawingBox {
|
||||
public WallDrawingBox(MazeApp mazeApp, Color color) {
|
||||
super(mazeApp, color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,12 +7,11 @@ import java.awt.*;
|
||||
public class WindowPanel extends JPanel
|
||||
{
|
||||
private final DrawingPanelGrid drawingPanelGrid;
|
||||
|
||||
|
||||
public WindowPanel(MazeApp mazeApp) {
|
||||
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
|
||||
add(drawingPanelGrid = new DrawingPanelGrid(mazeApp), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user