@Override public void setEndConnector(Connector newEnd) { if (newEnd != endConnector) { if (endConnector != null) { getEndFigure().removeFigureListener(connectionHandler); if (getStartFigure() != null) { if (getDrawing() != null) { handleDisconnect(getStartConnector(), getEndConnector()); } } } endConnector = newEnd; if (endConnector != null) { getEndFigure().addFigureListener(connectionHandler); if (getStartFigure() != null && getEndFigure() != null) { if (getDrawing() != null) { handleConnect(getStartConnector(), getEndConnector()); updateConnection(); } } } } }
if (getEndFigure() != null) { newEndFigure = (Figure) oldToNew.get(getEndFigure()); if (newEndFigure == null && !disconnectIfNotInMap) { newEndFigure = getEndFigure();
@Override public void figureChanged(FigureEvent e) { if (!owner.isChanging()) { if (e.getSource() == owner.getStartFigure() || e.getSource() == owner.getEndFigure()) { owner.willChange(); owner.updateConnection(); owner.changed(); } } } };
@Override public void setStartConnector(Connector newStart) { if (newStart != startConnector) { if (startConnector != null) { getStartFigure().removeFigureListener(connectionHandler); if (getEndFigure() != null) { handleDisconnect(getStartConnector(), getEndConnector()); } } startConnector = newStart; if (startConnector != null) { getStartFigure().addFigureListener(connectionHandler); if (getStartFigure() != null && getEndFigure() != null) { handleConnect(getStartConnector(), getEndConnector()); updateConnection(); } } } }
@Override public LineConnectionFigure clone() { LineConnectionFigure that = (LineConnectionFigure) super.clone(); that.connectionHandler = new ConnectionHandler(that); if (this.liner != null) { that.liner = (Liner) this.liner.clone(); } // FIXME - For safety reasons, we clone the connectors, but they would // work, if we continued to use them. Maybe we should state somewhere // whether connectors should be reusable, or not. // To work properly, that must be registered as a figure listener // to the connected figures. if (this.startConnector != null) { that.startConnector = (Connector) this.startConnector.clone(); that.getStartFigure().addFigureListener(that.connectionHandler); } if (this.endConnector != null) { that.endConnector = (Connector) this.endConnector.clone(); that.getEndFigure().addFigureListener(that.connectionHandler); } if (that.startConnector != null && that.endConnector != null) { //that.handleConnect(that.getStartConnector(), that.getEndConnector()); that.updateConnection(); } return that; }