don't redrawn each cell when loading and by redraw at end
- hide status update - don't redraw each point during file loading
This commit is contained in:
@@ -51,6 +51,7 @@ public class Display extends JFrame {
|
|||||||
MazeControler controler;
|
MazeControler controler;
|
||||||
LabyModel model;
|
LabyModel model;
|
||||||
boolean autoSize;
|
boolean autoSize;
|
||||||
|
boolean statusEnable = true;
|
||||||
|
|
||||||
MazeParams params = null;
|
MazeParams params = null;
|
||||||
JTextField statusField = null;
|
JTextField statusField = null;
|
||||||
@@ -333,8 +334,10 @@ public class Display extends JFrame {
|
|||||||
|
|
||||||
void addStatus(String pStatus)
|
void addStatus(String pStatus)
|
||||||
{
|
{
|
||||||
|
if ( statusEnable ) {
|
||||||
statusField.setText(pStatus);
|
statusField.setText(pStatus);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MazeControler extends JPanel {
|
private class MazeControler extends JPanel {
|
||||||
@@ -685,7 +688,9 @@ public class Display extends JFrame {
|
|||||||
// model = new MazePersistRaw().parseInputStream("raw",inputStream);
|
// model = new MazePersistRaw().parseInputStream("raw",inputStream);
|
||||||
Drawing drawing = new Drawing();
|
Drawing drawing = new Drawing();
|
||||||
drawing.loadLinesExpanded(new DataInputStream(inputStream));
|
drawing.loadLinesExpanded(new DataInputStream(inputStream));
|
||||||
|
statusEnable = false;
|
||||||
maze.addDrawing(drawing,add);
|
maze.addDrawing(drawing,add);
|
||||||
|
statusEnable = true;
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
io.printStackTrace(System.err);
|
io.printStackTrace(System.err);
|
||||||
statusField.setText("[ERROR] Can't load " + infile.getAbsolutePath());
|
statusField.setText("[ERROR] Can't load " + infile.getAbsolutePath());
|
||||||
@@ -878,6 +883,7 @@ public class Display extends JFrame {
|
|||||||
boolean showAll = false;
|
boolean showAll = false;
|
||||||
|
|
||||||
// for a given (x,y) pixel return cell position.
|
// for a given (x,y) pixel return cell position.
|
||||||
|
// if rightmost position of view not (0,0) this is not working.
|
||||||
Position getPosition(int x, int y) {
|
Position getPosition(int x, int y) {
|
||||||
int pX = (int) ((double) (x - cp.getOffsetX()) / cp.getWidth());
|
int pX = (int) ((double) (x - cp.getOffsetX()) / cp.getWidth());
|
||||||
int pY = (int) ((double) (y - cp.getOffsetY()) / cp.getHeight());
|
int pY = (int) ((double) (y - cp.getOffsetY()) / cp.getHeight());
|
||||||
@@ -903,6 +909,7 @@ public class Display extends JFrame {
|
|||||||
}
|
}
|
||||||
lastDrag = now;
|
lastDrag = now;
|
||||||
addPosition(newPosition,add);
|
addPosition(newPosition,add);
|
||||||
|
changed(null, null, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetDrawingPath()
|
public void resetDrawingPath()
|
||||||
@@ -916,6 +923,7 @@ public class Display extends JFrame {
|
|||||||
{
|
{
|
||||||
addDrawingLine(line, add);
|
addDrawingLine(line, add);
|
||||||
}
|
}
|
||||||
|
changed(null, null, map);
|
||||||
}
|
}
|
||||||
public void addDrawingLine(DrawingLine line, boolean add)
|
public void addDrawingLine(DrawingLine line, boolean add)
|
||||||
{
|
{
|
||||||
@@ -934,7 +942,9 @@ public class Display extends JFrame {
|
|||||||
if (drawingPath == null) {
|
if (drawingPath == null) {
|
||||||
drawingPath = new LinkedList<>();
|
drawingPath = new LinkedList<>();
|
||||||
last = new DirectionPosition((short) 0, newPosition);
|
last = new DirectionPosition((short) 0, newPosition);
|
||||||
|
if ( statusEnable) {
|
||||||
addStatus("Mouse dragged Cell " + newPosition + " Button " + add);
|
addStatus("Mouse dragged Cell " + newPosition + " Button " + add);
|
||||||
|
}
|
||||||
drawingPath.addLast(last);
|
drawingPath.addLast(last);
|
||||||
} else {
|
} else {
|
||||||
// setShowAll(true);
|
// setShowAll(true);
|
||||||
@@ -953,9 +963,10 @@ public class Display extends JFrame {
|
|||||||
last = last.moveToAdjacentDirection();
|
last = last.moveToAdjacentDirection();
|
||||||
drawingPath.addLast(last);
|
drawingPath.addLast(last);
|
||||||
}
|
}
|
||||||
|
if (statusEnable) {
|
||||||
addStatus("Mouse dragged from Cell " + first.getPosition() + "To" + newPosition + " Button " + add);
|
addStatus("Mouse dragged from Cell " + first.getPosition() + "To" + newPosition + " Button " + add);
|
||||||
}
|
}
|
||||||
changed(null, null, map);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user