* default with 60,60,15 labyrinth
* display labyrinth at re-recreation. * save only labyrinth view ( png without background ).
This commit is contained in:
@@ -56,7 +56,7 @@ public class Display extends JFrame
|
||||
LabyModel model;
|
||||
JPanel controlPanel;
|
||||
boolean autoSize;
|
||||
// MazeParamsFixed fixedParams = null;
|
||||
|
||||
MazeParams params = null;
|
||||
|
||||
Display(LabyModel model,int W, int H, MazeParams params)
|
||||
@@ -100,8 +100,7 @@ public class Display extends JFrame
|
||||
|
||||
void recreateModel()
|
||||
{
|
||||
// recreate labyrinth TODO / FIXME
|
||||
System.out.println("TODO recreateModel");
|
||||
// recreate labyrinth
|
||||
if (params != null)
|
||||
{
|
||||
params = controler.getSettings().getParams();
|
||||
@@ -109,9 +108,14 @@ public class Display extends JFrame
|
||||
maze.resetWallsProvider(model);
|
||||
model.setMazeListener(maze);
|
||||
|
||||
// we are in GUI event thread, need to release it and do it outside.
|
||||
new Thread() {
|
||||
public void run() {
|
||||
model.generateWithEntry(0, 0);
|
||||
model.addEntryOrExit(-1, 0);
|
||||
model.addEntryOrExit(params.getWidth(), params.getHeight() - 1);
|
||||
}
|
||||
}.start();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -158,9 +162,11 @@ public class Display extends JFrame
|
||||
void savePng()
|
||||
{
|
||||
File file = new File("snapshot.png");
|
||||
BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_ARGB);
|
||||
// BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage bi = new BufferedImage(maze.getSize().width, maze.getSize().height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bi.createGraphics();
|
||||
this.paint(g);
|
||||
// this.paint(g);
|
||||
maze.paint(g);
|
||||
g.dispose();
|
||||
try{
|
||||
ImageIO.write(bi,"png",file);
|
||||
@@ -186,6 +192,8 @@ public class Display extends JFrame
|
||||
}
|
||||
|
||||
void createSettingsGui()
|
||||
{
|
||||
if ( params != null )
|
||||
{
|
||||
JButton buttonCreate = new JButton(labels.getString("create"));
|
||||
buttonCreate.addActionListener(new ActionListener()
|
||||
@@ -196,6 +204,7 @@ public class Display extends JFrame
|
||||
}
|
||||
});
|
||||
add(buttonCreate);
|
||||
}
|
||||
if ( params != null )
|
||||
{
|
||||
JLabel widthLabel = new JLabel(labels.getString("width"));
|
||||
@@ -223,7 +232,7 @@ public class Display extends JFrame
|
||||
|
||||
}
|
||||
|
||||
private class MazeParamsFixed implements MazeParams
|
||||
private static class MazeParamsFixed implements MazeParams
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
@@ -848,9 +857,7 @@ public class Display extends JFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("enter width height and maxdepth");
|
||||
MazeParamEditor params = new MazeParamEditor(new File("lab"));
|
||||
params.read(new Scanner(System.in));
|
||||
MazeParamsFixed params = new MazeParamsFixed(new File("lab"),60,60,15);
|
||||
model = new LabyModel(params, new java.util.Random());
|
||||
|
||||
setupDisplay(model,W,H,params);
|
||||
|
||||
@@ -123,6 +123,9 @@ public class Wall3d
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
write triangles as stl text
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
String s = "";
|
||||
|
||||
Reference in New Issue
Block a user