@Override
    public void mousePressed(MouseEvent e) {
        if (calculated) {
            return;
        }
        Tile targetTile = getTileAt(e.getX(), e.getY());
        int button = e.getButton();
        if (targetTile != null) {
            targetTile.handleClick(button);
            if (targetTile.getState().equals(State.START)) {
                if (start != null) {
                    start.reset();
                }
                start = targetTile;
            }
            if (targetTile.getState().equals(State.END)) {
                if (end != null) {
                    end.reset();
                }
                end = targetTile;
            }
        }
    }