Revert "Fix NullPointerException"

This reverts commit 9ee498cb07837a1fa8049c6ea950a77eb3d9d76a
This commit is contained in:
Nikita Iryupin 2020-03-03 21:25:56 +01:00
parent 9ee498cb07
commit c108d3e987

View File

@ -12,7 +12,6 @@ public class WindowOfFreeMove extends JFrame {
private static boolean canPersonMove; private static boolean canPersonMove;
private static boolean preventDoubleMove; private static boolean preventDoubleMove;
private static boolean isReadyToPaint;
static final int KEY_LEFT = 37; static final int KEY_LEFT = 37;
static final int KEY_UP = 38; static final int KEY_UP = 38;
@ -50,7 +49,6 @@ public class WindowOfFreeMove extends JFrame {
} }
public WindowOfFreeMove() { public WindowOfFreeMove() {
isReadyToPaint = false;
canPersonMove = true; canPersonMove = true;
preventDoubleMove = true; preventDoubleMove = true;
lp = getLayeredPane(); lp = getLayeredPane();
@ -133,7 +131,6 @@ public class WindowOfFreeMove extends JFrame {
setMap(m1); setMap(m1);
map.createMap(); map.createMap();
isReadyToPaint = true;
// //
// lp.remove(dialogBar); // lp.remove(dialogBar);
// //
@ -159,7 +156,7 @@ public class WindowOfFreeMove extends JFrame {
//setCanPersonMove(false); //setCanPersonMove(false);
// lp.add(jf, JLayeredPane.POPUP_LAYER); // lp.add(jf, JLayeredPane.POPUP_LAYER);
timer = new Timer( 16, new ActionListener() { timer = new Timer(5, new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (!map.getPerson().getIsMoving()) { if (!map.getPerson().getIsMoving()) {
@ -174,18 +171,16 @@ public class WindowOfFreeMove extends JFrame {
static class Canvas extends JPanel { static class Canvas extends JPanel {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
if (isReadyToPaint) { super.paint(g);
super.paint(g); Graphics2D g2D = (Graphics2D) g;
Graphics2D g2D = (Graphics2D) g; g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.VALUE_ANTIALIAS_ON); for (Cell cell : map.getBlocks()) {
for (Cell cell : map.getMoveToCells()) { cell.paint(g2D);
cell.paint(g2D); }
} map.getPerson().paint(g2D);
map.getPerson().paint(g2D); for (Cell cell : map.getMoveToCells()) {
for (Cell cell : map.getBlocks()) { cell.paint(g2D);
cell.paint(g2D);
}
} }
} }
} }