@Override
    public void mousePressed(final MouseEvent e) {
        final Point p = e.getPoint();
        final Element element = getGraphicPanel().getElementAt(p);
        if (element instanceof Vertex) {
            final Vertex vertex = (Vertex) element;
            if (this.edge == null) {
                this.edge = new Edge(getPanel().getProcess().getNameGenerator().nextEdgeName());
                if (vertex.canHaveOutput()) {
                    final BPComponent vertexComponent = (BPComponent) vertex.getComponent();
                    this.edge.getEdgeComponent().setSourceX(p.x);
                    this.edge.getEdgeComponent().setSourceY(p.y);
                    this.edge.getEdgeComponent().setTargetX(p.x);
                    this.edge.getEdgeComponent().setTargetY(p.y);
                    this.edge.getEdgeComponent().updateComponent(vertexComponent, null);

                    getPanel().getProcess().addElement(this.edge);
                    this.edge.updateSource(vertex, null);
                    // TODO: limit repaint region
                    getPanel().repaint();
                }
            } else {
                if (vertex.canHaveInput() && !vertex.equals(this.edge.getSource())) {
                    this.edge.updateTarget(vertex, null);
                    final BPComponent vertexComponent = (BPComponent) vertex.getComponent();
                    this.edge.getEdgeComponent().setTargetX(p.x);
                    this.edge.getEdgeComponent().setTargetY(p.y);
                    this.edge.getEdgeComponent().updateComponent(null, vertexComponent);

                    // TODO: limit repaint region
                    getPanel().repaint();

                    this.edge = null;
                }
            }
        }
    }