@SuppressWarnings("unchecked")
public void contributeToGraph(CompoundDirectedGraph graph, Map map) {
GraphAnimation.recordInitialState(getConnectionFigure());
Node source = (Node) map.get(getSource());
Node target = (Node) map.get(getTarget());
Edge e = null;
if (target.data != null && target.data instanceof AbstractStatePart) {
IState startState = ((IWebflowState) ((AbstractStatePart) target.data)
.getState().getElementParent()).getStartState();
IState sourceState = ((AbstractStatePart) source.data).getState();
IState targetState = ((AbstractStatePart) target.data).getState();
if (startState != null
&& startState.getId().equals(targetState.getId())) {
e = new Edge(this, target, source);
}
else {
List children = ((IWebflowState) ((AbstractStatePart) target.data)
.getState().getElementParent()).getStates();
int sourceIndex = children.indexOf(sourceState);
int targetIndex = children.indexOf(targetState);
if (targetIndex < sourceIndex) {
e = new Edge(this, target, source);
}
else {
e = new Edge(this, source, target);
}
}
}
else {
List children = ((IWebflowState) ((AbstractStatePart) target.data)
.getState().getElementParent()).getStates();
int sourceIndex = children.indexOf(source);
int targetIndex = children.indexOf(target);
if (targetIndex < sourceIndex) {
e = new Edge(this, target, source);
}
else {
e = new Edge(this, source, target);
}
}
if (getTransitionModel().getActions().size() > 0) {
// e.weight = 3;
}