Feature newF = featureModel.getFeature(newEFID);
String relationID = (String) focusConnection.getAttribute("id");
CFRelation oldR = constraintModel.getCFRelation(relationID);
CFRModifier modifier = oldR.getModifier();
boolean isSource = oldR.isSource();
constraintModelEditor.removeCFRelation(relationID);
//����id��figure��ӳ���
if (idToFigureMap != null) {
idToFigureMap.remove(relationID, focusConnection);
}
CFRelation plRelation = plRelation = constraintModelEditor.addCFRelation(relationID, newF, c, isSource, modifier);
if (plRelation != null) {
focusConnection.setAttribute("id", plRelation.getID());
//����id��figure��ӳ���
if (idToFigureMap != null) {
idToFigureMap.add(plRelation.getID(), focusConnection);
}
}
} else if (!oldSFID.equals(newSFID)) { //��ϵ��Լ���˷����仯
Constraint cNew = constraintModel.getConstraint(newSFID);
Feature newF = featureModel.getFeature(newEFID);
String relationID = (String) focusConnection.getAttribute("id");
CFRModifier modifier = constraintModel.getCFRelation(relationID).getModifier();
constraintModelEditor.removeCFRelation(relationID);
//����id��figure��ӳ���
if (idToFigureMap != null) {
idToFigureMap.remove(relationID, focusConnection);
}
ConstraintFigure cf = (ConstraintFigure) newStartFigure;
CFRelation plRelation = null;
if (cf instanceof PLFigure) {
int direction = focusConnection.getStartConnector().getDirection();
if (direction == Connector.WEST_DIRECTION || direction == Connector.NORTH_DIRECTION) {
plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, true, modifier);
} else if (direction == Connector.EAST_DIRECTION || direction == Connector.SOUTH_DIRECTION) {
plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, false, modifier);
} else {
assert false;
}
} else if (cf instanceof GroupConstraintFigure) {
GroupConstraintFigure gcf = (GroupConstraintFigure) cf;
Integer pp = (Integer) gcf.getAttribute(GroupConstraintFigure.PortPosition);
int value = pp.intValue();
boolean isSource = false;
switch (value) {
case SwingConstants.NORTH:
case SwingConstants.WEST:
isSource = true;
break;
case SwingConstants.EAST:
case SwingConstants.SOUTH:
isSource = false;
break;
default:
assert false;
break;
}
plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, isSource, modifier);
} else if (cf instanceof VPConstraintFigure) {
int direction = focusConnection.getStartConnector().getDirection();
if (direction == Connector.WEST_DIRECTION || direction == Connector.NORTH_DIRECTION) {
plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, true, modifier);
} else if (direction == Connector.EAST_DIRECTION || direction == Connector.SOUTH_DIRECTION) {
plRelation = constraintModelEditor.addCFRelation(relationID, newF, cNew, false, modifier);
} else {
assert false;
}
} else {
assert false;
}
if (plRelation != null) {
focusConnection.setAttribute("id", plRelation.getID());
//����id��figure��ӳ���
if (idToFigureMap != null) {
idToFigureMap.add(plRelation.getID(), focusConnection);
}
}
} else
if (oldSFID.equals(newSFID) && (oldStartConnector != focusConnection.getStartConnector())) {//��ϵԼ���˵������ӷ����仯
String relationIDOld = (String) focusConnection.getAttribute("id");
CFRelation plRelationOld = constraintModel.getCFRelation(relationIDOld);
boolean isSource = plRelationOld.isSource();
Feature feature = plRelationOld.getFeature();
Constraint plc = (Constraint) plRelationOld.getConstraint();
CFRModifier modifier = constraintModel.getCFRelation(relationIDOld).getModifier();
constraintModelEditor.removeCFRelation(relationIDOld);
//����id��figure��ӳ���
if (idToFigureMap != null) {
idToFigureMap.remove(relationIDOld, focusConnection);