/** * Manipulates connections in a context dependent way. If the * mouse down hits a figure start a new connection. If the mousedown * hits a connection split a segment or join two segments. */ @Override public void mousePressed(MouseEvent evt) { super.mousePressed(evt); getView().clearSelection(); Point2D.Double startPoint = viewToDrawing(anchor); Figure startFigure = getDrawing().findFigure(startPoint); startConnector = (startFigure == null) ? null : startFigure.findConnector(startPoint, prototype); if (startConnector != null && canConnect(prototype, startConnector)) { Point2D.Double anchor = startConnector.getAnchor(); createdFigure = createFigure(); createdFigure.setStartPoint(anchor); createdFigure.setEndPoint(anchor); getDrawing().add(createdFigure); Rectangle r = new Rectangle(getView().drawingToView(anchor)); r.grow(ANCHOR_WIDTH, ANCHOR_WIDTH); fireAreaInvalidated(r); } else { startConnector = null; createdFigure = null; } endConnector = null; }