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;
|
||||
LabyModel model;
|
||||
boolean autoSize;
|
||||
boolean statusEnable = true;
|
||||
|
||||
MazeParams params = null;
|
||||
JTextField statusField = null;
|
||||
@@ -333,8 +334,10 @@ public class Display extends JFrame {
|
||||
|
||||
void addStatus(String pStatus)
|
||||
{
|
||||
if ( statusEnable ) {
|
||||
statusField.setText(pStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class MazeControler extends JPanel {
|
||||
@@ -685,7 +688,9 @@ public class Display extends JFrame {
|
||||
// model = new MazePersistRaw().parseInputStream("raw",inputStream);
|
||||
Drawing drawing = new Drawing();
|
||||
drawing.loadLinesExpanded(new DataInputStream(inputStream));
|
||||
statusEnable = false;
|
||||
maze.addDrawing(drawing,add);
|
||||
statusEnable = true;
|
||||
} catch (IOException io) {
|
||||
io.printStackTrace(System.err);
|
||||
statusField.setText("[ERROR] Can't load " + infile.getAbsolutePath());
|
||||
@@ -878,6 +883,7 @@ public class Display extends JFrame {
|
||||
boolean showAll = false;
|
||||
|
||||
// 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) {
|
||||
int pX = (int) ((double) (x - cp.getOffsetX()) / cp.getWidth());
|
||||
int pY = (int) ((double) (y - cp.getOffsetY()) / cp.getHeight());
|
||||
@@ -903,6 +909,7 @@ public class Display extends JFrame {
|
||||
}
|
||||
lastDrag = now;
|
||||
addPosition(newPosition,add);
|
||||
changed(null, null, map);
|
||||
}
|
||||
|
||||
public void resetDrawingPath()
|
||||
@@ -916,6 +923,7 @@ public class Display extends JFrame {
|
||||
{
|
||||
addDrawingLine(line, add);
|
||||
}
|
||||
changed(null, null, map);
|
||||
}
|
||||
public void addDrawingLine(DrawingLine line, boolean add)
|
||||
{
|
||||
@@ -934,7 +942,9 @@ public class Display extends JFrame {
|
||||
if (drawingPath == null) {
|
||||
drawingPath = new LinkedList<>();
|
||||
last = new DirectionPosition((short) 0, newPosition);
|
||||
if ( statusEnable) {
|
||||
addStatus("Mouse dragged Cell " + newPosition + " Button " + add);
|
||||
}
|
||||
drawingPath.addLast(last);
|
||||
} else {
|
||||
// setShowAll(true);
|
||||
@@ -953,9 +963,10 @@ public class Display extends JFrame {
|
||||
last = last.moveToAdjacentDirection();
|
||||
drawingPath.addLast(last);
|
||||
}
|
||||
if (statusEnable) {
|
||||
addStatus("Mouse dragged from Cell " + first.getPosition() + "To" + newPosition + " Button " + add);
|
||||
}
|
||||
changed(null, null, map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user