* @param evt The connector event.
*/
public void connectorDropped(ConnectorEvent evt) {
Connector c = evt.getConnector();
Figure f = evt.getTarget();
Link link = (Link) c.getUserObject();
Object node = (f == null) ? null : f.getUserObject();
ActorGraphModel model = (ActorGraphModel) getController()
.getGraphModel();
switch (evt.getEnd()) {
case ConnectorEvent.HEAD_END:
if (node == link.getTail()) {
MessageHandler
.error("Cannot link both ends to the same object.");
// FIXME: The panner needs to repaint. How to get it to do that?
return;
}
model.getLinkModel().setHead(link, node);
break;
case ConnectorEvent.TAIL_END:
if (node == link.getHead()) {
MessageHandler
.error("Cannot link both ends to the same object.");
// FIXME: The panner needs to repaint. How to get it to do that?
return;
}
model.getLinkModel().setTail(link, node);
break;
default:
throw new IllegalStateException(
"Cannot handle both ends of an edge being dragged.");
}
// Set the width correctly, so we know whether or not it
// is connected. Note that this happens *after* the model
// is modified.
if ((link.getHead() != null) && (link.getTail() != null)) {
((ManhattanConnector) c).setLineWidth((float) 2.0);
} else {
((ManhattanConnector) c).setLineWidth((float) 1.0);
}
}