some eclipse stuff
provide artlogjavaformat to reformat code
This commit is contained in:
23
artlogjavaformat.epf
Normal file
23
artlogjavaformat.epf
Normal file
File diff suppressed because one or more lines are too long
3
devenv_params
Normal file
3
devenv_params
Normal file
@@ -0,0 +1,3 @@
|
||||
DEV_ENV=~/artisanlogiciel/devel_tools
|
||||
JDK_PATH=~/artisanlogiciel/devel_tools/jdk1.8.0_74
|
||||
ECLIPSE_PATH=~/artisanlogiciel/devel_tools/eclipse
|
||||
7
java/.classpath
Normal file
7
java/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
||||
23
java/.project
Normal file
23
java/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Karmazoff</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -2,19 +2,21 @@ package org.artisanlogiciel.games;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Container;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@@ -22,19 +24,17 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
/**
|
||||
Display
|
||||
* Display
|
||||
**/
|
||||
public class Display extends JFrame
|
||||
|
||||
{
|
||||
Object param;
|
||||
// to please eclipse, not supposed to be serialized
|
||||
private static final long serialVersionUID = 8500214871372184418L;
|
||||
|
||||
MazeComponent maze;
|
||||
MazeControler controler;
|
||||
LabyModel model;
|
||||
@@ -44,7 +44,6 @@ public class Display extends JFrame
|
||||
{
|
||||
super("Maze display");
|
||||
maze = comp;
|
||||
this.param=param;
|
||||
this.model = model;
|
||||
Container con = this.getContentPane();
|
||||
con.add(new JScrollPane(comp), BorderLayout.CENTER);
|
||||
@@ -82,8 +81,7 @@ public class Display extends JFrame
|
||||
maze.setWallSize(size);
|
||||
}
|
||||
|
||||
private static class MazeParamEditor
|
||||
implements MazeParams
|
||||
private static class MazeParamEditor implements MazeParams
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
@@ -91,21 +89,14 @@ public class Display extends JFrame
|
||||
File labdir;
|
||||
String name;
|
||||
|
||||
public MazeParamEditor()
|
||||
{
|
||||
name=null;
|
||||
labdir = new File("lab");
|
||||
}
|
||||
|
||||
public MazeParamEditor(File saveDir)
|
||||
{
|
||||
name = null;
|
||||
labdir = saveDir;
|
||||
}
|
||||
|
||||
public void consoleRead()
|
||||
public void read(Scanner console)
|
||||
{
|
||||
Scanner console = new Scanner(System.in);
|
||||
width = console.nextInt();
|
||||
height = console.nextInt();
|
||||
maxdepth = console.nextInt();
|
||||
@@ -139,16 +130,21 @@ public class Display extends JFrame
|
||||
{
|
||||
return labdir;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MazeControler extends JPanel
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MazeControler()
|
||||
{
|
||||
controlPanel = new JPanel();
|
||||
JButton button = new JButton("Resolve");
|
||||
button.addActionListener(new ActionListener() {
|
||||
button.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
@@ -157,6 +153,7 @@ public class Display extends JFrame
|
||||
}
|
||||
});
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
Action goNorth = new AbstractAction()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
@@ -168,7 +165,9 @@ public class Display extends JFrame
|
||||
};
|
||||
JButton north = addDirection(this, "North", "UP", goNorth);
|
||||
|
||||
Action goEast = new AbstractAction() {
|
||||
@SuppressWarnings("serial")
|
||||
Action goEast = new AbstractAction()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
@@ -176,10 +175,12 @@ public class Display extends JFrame
|
||||
goEast();
|
||||
}
|
||||
};
|
||||
|
||||
JButton east = addDirection(this, "East", "RIGHT", goEast);
|
||||
|
||||
|
||||
Action goWest = new AbstractAction() {
|
||||
@SuppressWarnings("serial")
|
||||
Action goWest = new AbstractAction()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
@@ -189,7 +190,9 @@ public class Display extends JFrame
|
||||
};
|
||||
JButton west = addDirection(this, "West", "LEFT", goWest);
|
||||
|
||||
Action goSouth = new AbstractAction() {
|
||||
@SuppressWarnings("serial")
|
||||
Action goSouth = new AbstractAction()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
@@ -206,7 +209,8 @@ public class Display extends JFrame
|
||||
controlPanel.add(south, BorderLayout.SOUTH);
|
||||
add(controlPanel, BorderLayout.NORTH);
|
||||
final JSlider slider = new JSlider(2, 40);
|
||||
slider.addChangeListener(new ChangeListener() {
|
||||
slider.addChangeListener(new ChangeListener()
|
||||
{
|
||||
public void stateChanged(ChangeEvent e)
|
||||
{
|
||||
setWallSize(slider.getValue());
|
||||
@@ -230,10 +234,10 @@ public class Display extends JFrame
|
||||
return button;
|
||||
}
|
||||
|
||||
private static class MazeComponent extends JComponent
|
||||
implements MazeCreationListener,
|
||||
MazeResolutionListener
|
||||
private static class MazeComponent extends JComponent implements MazeCreationListener, MazeResolutionListener
|
||||
{
|
||||
private static final long serialVersionUID = 3163272907991176390L;
|
||||
|
||||
WallsProvider map;
|
||||
int width = 10;
|
||||
int height = 10;
|
||||
@@ -256,6 +260,7 @@ public class Display extends JFrame
|
||||
System.out.println("Exit found by human !");
|
||||
}
|
||||
}
|
||||
|
||||
void goNorth()
|
||||
{
|
||||
resetResolution();
|
||||
@@ -347,7 +352,8 @@ public class Display extends JFrame
|
||||
Object waiter = new Object();
|
||||
synchronized (waiter)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
waiter.wait(10);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
@@ -359,14 +365,19 @@ public class Display extends JFrame
|
||||
|
||||
private void drawWalls(Graphics g, int x, int y, short walls, boolean full)
|
||||
{
|
||||
if ( (full) && (( walls & Brick.UP ) == Brick.UP )) g.drawLine(x, y, x+width, y);
|
||||
if ( ( walls & Brick.DOWN ) == Brick.DOWN ) g.drawLine(x, y+height, x+width, y+height);
|
||||
if ( ( walls & Brick.RIGHT ) == Brick.RIGHT ) g.drawLine(x+width, y, x+width, y+height);
|
||||
if ( (full) && (( walls & Brick.LEFT ) == Brick.LEFT )) g.drawLine(x, y, x, y+height);
|
||||
if ((full) && ((walls & Brick.UP) == Brick.UP))
|
||||
g.drawLine(x, y, x + width, y);
|
||||
if ((walls & Brick.DOWN) == Brick.DOWN)
|
||||
g.drawLine(x, y + height, x + width, y + height);
|
||||
if ((walls & Brick.RIGHT) == Brick.RIGHT)
|
||||
g.drawLine(x + width, y, x + width, y + height);
|
||||
if ((full) && ((walls & Brick.LEFT) == Brick.LEFT))
|
||||
g.drawLine(x, y, x, y + height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
@@ -382,10 +393,14 @@ public class Display extends JFrame
|
||||
int pX = (int) ((double) (r.getX() - offsetX) / width);
|
||||
int pY = (int) ((double) (r.getY() - offsetY) / height);
|
||||
|
||||
if ( pX < 0) pX = 0;
|
||||
if ( pY < 0) pY = 0;
|
||||
if ( pX >= map.getWidth()) return;
|
||||
if ( pY >= map.getHeight()) return;
|
||||
if (pX < 0)
|
||||
pX = 0;
|
||||
if (pY < 0)
|
||||
pY = 0;
|
||||
if (pX >= map.getWidth())
|
||||
return;
|
||||
if (pY >= map.getHeight())
|
||||
return;
|
||||
|
||||
mX = mX + pX;
|
||||
mY = mY + pY;
|
||||
@@ -480,7 +495,7 @@ public class Display extends JFrame
|
||||
|
||||
public void notifyCompletion(LinkedList<Position> solvedPath)
|
||||
{
|
||||
LinkedList<Position> newPath = (LinkedList<Position>) solvedPath.clone();
|
||||
LinkedList<Position> newPath = new LinkedList<>(solvedPath);
|
||||
System.out.println("resolution completed");
|
||||
synchronized (lockChange)
|
||||
{
|
||||
@@ -505,7 +520,8 @@ public class Display extends JFrame
|
||||
|
||||
if (pArgs.length > 0)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
model = new LabyModel("raw", new FileInputStream(pArgs[0]));
|
||||
}
|
||||
catch (IOException io)
|
||||
@@ -515,8 +531,10 @@ public class Display extends JFrame
|
||||
|
||||
int w = W / model.getWidth();
|
||||
int h = H / model.getHeight();
|
||||
if ( w < 5 ) w = 5;
|
||||
if ( h < 5 ) h = 5;
|
||||
if (w < 5)
|
||||
w = 5;
|
||||
if (h < 5)
|
||||
h = 5;
|
||||
MazeComponent comp = new MazeComponent(model, w, h, 3, 3);
|
||||
Display display = new Display(model, comp);
|
||||
model.setMazeListener(comp);
|
||||
@@ -527,13 +545,15 @@ public class Display extends JFrame
|
||||
else
|
||||
{
|
||||
System.out.println("enter width height and maxdepth");
|
||||
MazeParamEditor params = new MazeParamEditor();
|
||||
params.consoleRead();
|
||||
MazeParamEditor params = new MazeParamEditor(new File("lab"));
|
||||
params.read(new Scanner(System.in));
|
||||
model = new LabyModel(params, new java.util.Random());
|
||||
int w = W / params.getWidth();
|
||||
int h = H / params.getHeight();
|
||||
if ( w < 5 ) w = 5;
|
||||
if ( h < 5 ) h = 5;
|
||||
if (w < 5)
|
||||
w = 5;
|
||||
if (h < 5)
|
||||
h = 5;
|
||||
MazeComponent comp = new MazeComponent(model, w, h, 3, 3);
|
||||
Display display = new Display(model, comp);
|
||||
model.setMazeListener(comp);
|
||||
@@ -542,7 +562,7 @@ public class Display extends JFrame
|
||||
display.setVisible(true);
|
||||
|
||||
model.generateWithEntry(0, 0);
|
||||
LinkedList<Position> exits = new LinkedList<Position>();
|
||||
|
||||
model.addEntryOrExit(-1, 0);
|
||||
model.addEntryOrExit(params.getWidth(), params.getHeight() - 1);
|
||||
System.out.println("Generation completed");
|
||||
@@ -550,7 +570,8 @@ public class Display extends JFrame
|
||||
if (!outfile.exists())
|
||||
{
|
||||
System.out.println("Saving to " + outfile + " ...");
|
||||
try {
|
||||
try
|
||||
{
|
||||
FileOutputStream out = new FileOutputStream(outfile);
|
||||
model.streamOut("raw", out);
|
||||
out.flush();
|
||||
@@ -562,14 +583,16 @@ public class Display extends JFrame
|
||||
io.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
System.out.println("" + outfile + " already exists");
|
||||
}
|
||||
outfile = new File(params.getSaveDir(), params.getName() + ".stl");
|
||||
if (!outfile.exists())
|
||||
{
|
||||
System.out.println("Saving to " + outfile + " ...");
|
||||
try {
|
||||
try
|
||||
{
|
||||
FileOutputStream out = new FileOutputStream(outfile);
|
||||
Wall3d.streamWallsOut(params.getName(), (WallsProvider) model, out);
|
||||
out.flush();
|
||||
@@ -581,7 +604,8 @@ public class Display extends JFrame
|
||||
io.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
System.out.println("" + outfile + " already exists");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user