CompositeConstraint ccNew = cme.addCompositeConstraint();
cce.setPLType(ccNew , cct);
cce.setSourceType(ccNew , ccptSource);
cce.setSinkType(ccNew , ccptSink);
PLFigure plfNew = new PLFigure();
plfNew.setAttribute("id" , ccNew.getID());
plfNew.setAttribute("bounds" , fOld.getAttribute("bounds"));
plfNew.setAttribute("frameColor" , fOld.getAttribute("frameColor"));
if (CompositeConstraintType.L2R_Implication.equals(cct)) {
plfNew.setAttribute("PLType" , PLFigure.L2R_REQUIRE);
} else if (CompositeConstraintType.R2L_Implication.equals(cct)) {
plfNew.setAttribute("PLType" , PLFigure.R2L_REQUIRE);
} else if (CompositeConstraintType.Equivalence.equals(cct)) {
plfNew.setAttribute("PLType" , PLFigure.EQUIVALENCE);
} else {
plfNew.setAttribute("PLType" , PLFigure.MUTEX);
}
plfNew.setAttribute("SourceType" , ccptSource.getName());
plfNew.setAttribute("SinkType" , ccptSink.getName());
dv.add(plfNew);
plfNew.setDisplayBox(fOld.getDisplayBox());
for (Iterator<Feature> itFeature=fSources.iterator() ; itFeature.hasNext() ; ) {
Feature fSource = itFeature.next();
Figure figureSource = mFigure.get(fSource.getID());
CFRelation rOld = cm.getCFRelation(fSource , cOld , true);
if (rOld==null) {
rOld = cm.getCFRelation(fSource , cOld , false);
}
PLConnection plcOld = (PLConnection)mFigure.get(rOld.getID());
CFRelation rNew = cme.addCFRelation(fSource , ccNew , true
, rOld.getModifier().equals(CFRModifier.Affirmation) ? (revertSourceRelation ? CFRModifier.Negation : CFRModifier.Affirmation) : (revertSourceRelation ? CFRModifier.Affirmation : CFRModifier.Negation));
PLConnection plcNew = new PLConnection();
plcNew.setAttribute("id" , rNew.getID());
plcNew.setAttribute("frameColor" , plcOld.getAttribute("frameColor"));
plcNew.setAttribute("type" , plcOld.getAttribute("type"));
plcNew.setAttribute("CFRModifier" , rNew.getModifier().getName());
for (int i=0 ; i<plcOld.pointCount() ; i++) {
plcNew.addPoint(plcOld.pointAt(i).x , plcOld.pointAt(i).y);
}
plcNew.startPoint(plfNew.getConnectors()[0].getDisplayBox().x , plfNew.getConnectors()[0].getDisplayBox().y);
plcNew.connectStart(plfNew.getConnectors()[0]);
plcNew.endPoint(figureSource.getConnectors()[4].getDisplayBox().x , figureSource.getConnectors()[4].getDisplayBox().y);
plcNew.connectEnd(figureSource.getConnectors()[4]);
dv.add(plcNew);
}
for (Iterator<Feature> itFeature=fSinks.iterator() ; itFeature.hasNext() ; ) {
Feature fSink = itFeature.next();
Figure figureSink = mFigure.get(fSink.getID());
CFRelation rOld = cm.getCFRelation(fSink , cOld , true);
if (rOld==null) {
rOld = cm.getCFRelation(fSink , cOld , false);
}
CFRelation rNew = cme.addCFRelation(fSink , ccNew , true
, rOld.getModifier().equals(CFRModifier.Affirmation) ? (revertSinkRelation ? CFRModifier.Negation : CFRModifier.Affirmation) : (revertSinkRelation ? CFRModifier.Affirmation : CFRModifier.Negation));
PLConnection plcOld = (PLConnection)mFigure.get(rOld.getID());
PLConnection plcNew = new PLConnection();
plcNew.setAttribute("id" , rNew.getID());
plcNew.setAttribute("frameColor" , plcOld.getAttribute("frameColor"));
plcNew.setAttribute("type" , plcOld.getAttribute("type"));
plcNew.setAttribute("CFRModifier" , rNew.getModifier().getName());
for (int i=0 ; i<plcOld.pointCount() ; i++) {
plcNew.addPoint(plcOld.pointAt(i).x , plcOld.pointAt(i).y);
}
plcNew.startPoint(plfNew.getConnectors()[1].getDisplayBox().x , plfNew.getConnectors()[1].getDisplayBox().y);
plcNew.connectStart(plfNew.getConnectors()[1]);
plcNew.endPoint(figureSink.getConnectors()[3].getDisplayBox().x , figureSink.getConnectors()[3].getDisplayBox().y);
plcNew.connectEnd(figureSink.getConnectors()[3]);
dv.add(plcNew);
}