Add UI to the project #29
No files matched your search
+1
-1
@@ -20,7 +20,7 @@ public class MainTest {
|
|||||||
|
|
||||||
mazeTest.saveToTextFile("data/labyOutput.txt");
|
mazeTest.saveToTextFile("data/labyOutput.txt");
|
||||||
|
|
||||||
new MazeApp(mazeTest);
|
new MazeApp();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,9 +12,9 @@ public abstract class DrawingBox extends JPanel {
|
|||||||
public DrawingBox(MazeApp mazeApp, Color color) {
|
public DrawingBox(MazeApp mazeApp, Color color) {
|
||||||
|
|
||||||
this.mazeApp = mazeApp;
|
this.mazeApp = mazeApp;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
setBackground(color);
|
setBackground(color);
|
||||||
setPreferredSize(new Dimension(20,20));
|
setPreferredSize(new Dimension(40,40));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ public class QuitMenuItem extends JMenuItem {
|
|||||||
|
|
||||||
super("Quit");
|
super("Quit");
|
||||||
this.mazeApp = mazeApp;
|
this.mazeApp = mazeApp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user