create new maze with a given size
- fixme ratio paramaters are not reset.
This commit is contained in:
@@ -65,7 +65,7 @@ public class Display extends JFrame
|
||||
maze = createMazeComponent(model,W,H);
|
||||
Container con = this.getContentPane();
|
||||
con.add(new JScrollPane(maze), BorderLayout.CENTER);
|
||||
controler = new MazeControler();
|
||||
controler = new MazeControler(params);
|
||||
con.add(controler.getMoveControl(), BorderLayout.NORTH);
|
||||
con.add(controler.getGenerationControl(), BorderLayout.SOUTH);
|
||||
|
||||
@@ -98,6 +98,7 @@ public class Display extends JFrame
|
||||
System.out.println("TODO recreateModel");
|
||||
if (params != null)
|
||||
{
|
||||
params = controler.getSettings().getParams();
|
||||
model = new LabyModel(params, new java.util.Random());
|
||||
maze.resetWallsProvider(model);
|
||||
model.setMazeListener(maze);
|
||||
@@ -164,17 +165,17 @@ public class Display extends JFrame
|
||||
|
||||
private class MazeSettings extends JPanel
|
||||
{
|
||||
MazeParamsFixed params;
|
||||
MazeParams params;
|
||||
|
||||
JTextField textWidth = null;
|
||||
JTextField textHeight = null;
|
||||
JTextField textDepth = null;
|
||||
|
||||
// TODO set width and height and depth of maze with gui
|
||||
public MazeSettings()
|
||||
public MazeSettings(MazeParams params)
|
||||
{
|
||||
super();
|
||||
params = new MazeParamsFixed();
|
||||
this.params = params;
|
||||
createSettingsGui();
|
||||
}
|
||||
|
||||
@@ -190,20 +191,26 @@ public class Display extends JFrame
|
||||
});
|
||||
add(buttonCreate);
|
||||
JLabel widthLabel = new JLabel("width");
|
||||
textWidth = new JTextField("010");
|
||||
textWidth = new JTextField("0" + params.getWidth());
|
||||
add(widthLabel);
|
||||
add(textWidth);
|
||||
JLabel heightLabel = new JLabel("height");
|
||||
textHeight = new JTextField("010");
|
||||
textHeight = new JTextField("0" + params.getHeight());
|
||||
add(heightLabel);
|
||||
add(textHeight);
|
||||
JLabel depthLabel = new JLabel("depth");
|
||||
textDepth = new JTextField("015");
|
||||
textDepth = new JTextField("0" + params.getMaxDepth());
|
||||
add(depthLabel);
|
||||
add(textDepth);
|
||||
}
|
||||
|
||||
|
||||
public MazeParams getParams()
|
||||
{
|
||||
return new MazeParamsFixed(params.getSaveDir(),
|
||||
Integer.parseInt(textWidth.getText()),
|
||||
Integer.parseInt(textHeight.getText()),
|
||||
Integer.parseInt(textDepth.getText()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -219,6 +226,11 @@ public class Display extends JFrame
|
||||
{
|
||||
}
|
||||
|
||||
public MazeParamsFixed(MazeParams params)
|
||||
{
|
||||
setParams(params.getSaveDir(),params.getWidth(),params.getHeight(),params.getMaxDepth());
|
||||
}
|
||||
|
||||
public void setParams(File saveDir, int W, int H, int MD)
|
||||
{
|
||||
labdir = saveDir;
|
||||
@@ -274,10 +286,10 @@ public class Display extends JFrame
|
||||
private MazeSettings settings = null;
|
||||
|
||||
|
||||
public MazeControler()
|
||||
public MazeControler(MazeParams params)
|
||||
{
|
||||
controlPanel = new JPanel();
|
||||
settings = new MazeSettings();
|
||||
settings = new MazeSettings(params);
|
||||
JButton button = new JButton("Resolve");
|
||||
button.addActionListener(new ActionListener()
|
||||
{
|
||||
@@ -378,7 +390,6 @@ public class Display extends JFrame
|
||||
controlDisplayPanel.add(autoSlide, BorderLayout.EAST);
|
||||
controlDisplayPanel.add(savePngButton, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
add(controlDisplayPanel, BorderLayout.SOUTH);
|
||||
add(settings,BorderLayout.EAST);
|
||||
}
|
||||
@@ -393,6 +404,11 @@ public class Display extends JFrame
|
||||
return settings;
|
||||
}
|
||||
|
||||
public MazeSettings getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private JButton addDirection(final JPanel panel, final String direction, String key, Action goAction)
|
||||
|
||||
Reference in New Issue
Block a user