/** * This method is invoked, when the Figure is being removed from a Drawing. * This method invokes handleConnect, if the Figure is connected. * * @see #handleConnect */ @Override public void addNotify(Drawing drawing) { super.addNotify(drawing); if (getStartConnector() != null && getEndConnector() != null) { handleConnect(getStartConnector(), getEndConnector()); updateConnection(); } }
/** * This method is invoked, when the Figure is being removed from a Drawing. * This method invokes handleDisconnect, if the Figure is connected. * * @see #handleDisconnect */ @Override public void removeNotify(Drawing drawing) { if (getStartConnector() != null && getEndConnector() != null) { handleDisconnect(getStartConnector(), getEndConnector()); } // Note: we do not set the connectors to null here, because we // need them when we are added back to a drawing again. For example, // when an undo is performed, after the LineConnection has been // deleted. /* setStartConnector(null); setEndConnector(null); */ super.removeNotify(drawing); }
@Override public void updateConnection() { willChange(); if (getStartConnector() != null) { Point2D.Double start = getStartConnector().findStart(this); if (start != null) { setStartPoint(start); } } if (getEndConnector() != null) { Point2D.Double end = getEndConnector().findEnd(this); if (end != null) { setEndPoint(end); } } changed(); }
@Override public void setNode(int index, BezierPath.Node p) { if (index != 0 && index != getNodeCount() - 1) { if (getStartConnector() != null) { Point2D.Double start = getStartConnector().findStart(this); if (start != null) { setStartPoint(start); } } if (getEndConnector() != null) { Point2D.Double end = getEndConnector().findEnd(this); if (end != null) { setEndPoint(end); } } } super.setNode(index, p); } /*
@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 protected void writePoints(DOMOutput out) throws IOException { super.writePoints(out); out.openElement("startConnector"); out.writeObject(getStartConnector()); out.closeElement(); out.openElement("endConnector"); out.writeObject(getEndConnector()); out.closeElement(); }
@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(); } } } } }
setEndConnector(newEndFigure.findCompatibleConnector(getEndConnector(), false)); } else { if (disconnectIfNotInMap) {