Add UI to the project #29

Manually merged
regar42 merged 45 commits from mvc into master 2018-01-03 11:03:09 +00:00
7 changed files with 24 additions and 13 deletions
Showing only changes of commit 892d7e6ff3 - Show all commits

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ public class MainTest {
mazeTest.saveToTextFile("data/labyOutput.txt"); mazeTest.saveToTextFile("data/labyOutput.txt");
new MazeApp(mazeTest); new MazeApp();
} }
+10
View File
@@ -1,6 +1,16 @@
package model; package model;
import maze.Maze;
public class MazeAppModel { public class MazeAppModel {
private Maze maze = new Maze("data/labyrinthe.txt");
public void setMaze(Maze maze) {
this.maze = maze;
}
public Maze getMaze() {
return maze;
}
} }
+1 -1
View File
@@ -15,6 +15,6 @@ public abstract class DrawingBox extends JPanel {
this.color = color; this.color = color;
setBackground(color); setBackground(color);
setPreferredSize(new Dimension(20,20)); setPreferredSize(new Dimension(40,40));
} }
} }
+2 -2
View File
@@ -13,10 +13,10 @@ public class DrawingPanelGrid extends JPanel {
private int dimensionX; private int dimensionX;
private int dimensionY; private int dimensionY;
public DrawingPanelGrid(MazeApp mazeApp, Maze maze) { public DrawingPanelGrid(MazeApp mazeApp) {
this.mazeApp = mazeApp; this.mazeApp = mazeApp;
this.maze = maze; this.maze = mazeApp.getMazeAppModel().getMaze();
this.dimensionX = maze.getDimensionX(); this.dimensionX = maze.getDimensionX();
this.dimensionY = maze.getDimensionY(); this.dimensionY = maze.getDimensionY();
+7 -4
View File
@@ -2,25 +2,28 @@ package ui;
import javax.swing.*; import javax.swing.*;
import maze.Maze; import maze.Maze;
import model.MazeAppModel;
public class MazeApp extends JFrame { public class MazeApp extends JFrame {
private final MazeMenuBar mazeMenuBar; private final MazeMenuBar mazeMenuBar;
private final WindowPanel windowPanel; private final WindowPanel windowPanel;
private Maze maze; private MazeAppModel mazeAppModel = new MazeAppModel();
public MazeApp(Maze maze) { public MazeApp() {
super("Maze Solving Application"); super("Maze Solving Application");
setJMenuBar(mazeMenuBar = new MazeMenuBar(this)); setJMenuBar(mazeMenuBar = new MazeMenuBar(this));
setContentPane(windowPanel = new WindowPanel(this, maze)) ; setContentPane(windowPanel = new WindowPanel(this)) ;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack(); pack();
setVisible(true); setVisible(true);
} }
public MazeAppModel getMazeAppModel() {
return mazeAppModel;
}
} }
-1
View File
@@ -10,7 +10,6 @@ public class QuitMenuItem extends JMenuItem {
super("Quit"); super("Quit");
this.mazeApp = mazeApp; this.mazeApp = mazeApp;
} }
} }
+3 -4
View File
@@ -7,13 +7,12 @@ import java.awt.*;
public class WindowPanel extends JPanel public class WindowPanel extends JPanel
{ {
private final DrawingPanelGrid drawingPanelGrid; private final DrawingPanelGrid drawingPanelGrid;
private Maze maze;
public WindowPanel(MazeApp mazeApp, Maze maze) public WindowPanel(MazeApp mazeApp) {
{
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(drawingPanelGrid = new DrawingPanelGrid(mazeApp, maze), BorderLayout.CENTER); add(drawingPanelGrid = new DrawingPanelGrid(mazeApp), BorderLayout.CENTER);
} }
} }