@Override
    public void mouseDragged(final MouseEvent e) {
        if (this.draggedComponent == null) {
            for (final Element el : getGraphicPanel().getSelectionManager().getSelectedElements()) {
                if (el.getComponent().getHandlers().isHandlerAt(e.getPoint())) {
                    if (el instanceof Edge) {
                        this.draggedEdge = (Edge) el;
                        this.draggedComponent = this.draggedEdge.getEdgeComponent();
                        this.handlerPos = this.draggedComponent.getHandlers().getHandlerAt(e.getPoint()).getHandlerPosition();
                        if (this.handlerPos == HandlerPosition.SOURCE) {
                            this.startX = this.draggedComponent.getSourceX();
                            this.startY = this.draggedComponent.getSourceY();
                        } else if (this.handlerPos == HandlerPosition.TARGET) {
                            this.startX = this.draggedComponent.getTargetX();
                            this.startY = this.draggedComponent.getTargetY();
                        } else {
                            this.startX = e.getPoint().x;
                            this.startY = e.getPoint().y;
                        }
                        break;
                    }
                }
            }
        }

        if (this.draggedComponent == null) {
            getPanel().getStateManager().moveToState(StateType.SELECT);
        } else {
            if (this.handlerPos == HandlerPosition.SOURCE) {
                this.draggedComponent.setSourceX(e.getPoint().x);
                this.draggedComponent.setSourceY(e.getPoint().y);
            } else if (this.handlerPos == HandlerPosition.TARGET) {
                this.draggedComponent.setTargetX(e.getPoint().x);
                this.draggedComponent.setTargetY(e.getPoint().y);
            }
            getGraphicPanel().repaint();
        }
    }