public NetworkGraphDisplay() {
        addMouseListener(new MouseAdapter() {

            @Override
            public void mouseEntered(MouseEvent event) {
                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                mouseClickPoint = event.getPoint();
            }

            @Override
            public void mousePressed(MouseEvent event) {
                setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                mouseClickPoint = event.getPoint();
            }

            @Override
            public void mouseReleased(MouseEvent event) {
                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            }

            @Override
            public void mouseExited(MouseEvent event) {
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        addMouseMotionListener(new MouseAdapter() {

            @Override
            public void mouseMoved(MouseEvent event) {
                if (grammarWindow == null) {
                    return;
                }

                int mouseX = event.getX() - getWidth() / 2;
                int mouseY = getHeight() / 2 - event.getY();
                double zoomLevel = grammarWindow.getZoomLevel();

                for (Mass mass : networkGraph.getMasses()) {
                    int massX = (int) (mass.getX() * xScale * zoomLevel + zoomLevel * mouseDragTransformation.x);
                    int massY = (int) (mass.getY() * yScale * zoomLevel - zoomLevel * mouseDragTransformation.y);

                    if (mouseX >= massX - MASS_RADIUS
                            && mouseX <= massX + MASS_RADIUS
                            && mouseY >= massY - MASS_RADIUS
                            && mouseY <= massY + MASS_RADIUS) {
                        grammarWindow.setCoordinatesLabel(mass.getX(), mass.getY());
                        return;
                    }
                }

                grammarWindow.resetCoordinatesLabel();
            }

            @Override
            public void mouseDragged(MouseEvent event) {
                double zoomLevel = grammarWindow.getZoomLevel();
                int dx = (int) Math.round((1.0d * (event.getX() - mouseClickPoint.x) / zoomLevel) + mouseDragTransformation.x);
                int dy = (int) Math.round((1.0d * (event.getY() - mouseClickPoint.y) / zoomLevel) + mouseDragTransformation.y);
                mouseDragTransformation.setLocation(dx, dy);
                mouseClickPoint = event.getPoint();
                repaint();
            }

        });
    }