@Override
    public void mouseDragged (MouseEvent e) {
        if (alg.isProcess()) {
            return;
        }
        int i = getRowByMouseX(e.getX());
        int j = getColumnByMouseY(e.getY());

        if (e.getModifiersEx() == MouseEvent.BUTTON1_DOWN_MASK) {
            if (draggedCell != null) {
                dragCell(i, j);

            } else {
                if (alg.getCell(i, j) instanceof EmptyCell) {
                    alg.setCell(i, j, new Wall());
                }
            }

        } else if (e.getModifiersEx() == MouseEvent.BUTTON3_DOWN_MASK) {
            if (draggedCell != null) {
                dragCell(i, j);

            } else {
                if (alg.getCell(i, j) instanceof Wall) {
                    alg.setCell(i, j, new EmptyCell());
                }
            }
        }

        mouseMoved(e);
    }