{
return super.editorArea;
}
protected void refreshFigures() {
DrawingView dv = this.getEditorArea().view();
// remove all figures
Collection<Figure> figures = new ArrayList<Figure>();
FigureEnumeration fe = dv.getDrawing().getFigures();
while (fe.hasMoreElements())
figures.add(fe.nextFigure());
for (Iterator<Figure> itFigure = figures.iterator() ; itFigure.hasNext() ; )
dv.remove(itFigure.next());
super.idToFigureMap.clear();
if (this.featureModel==null || featureModel.getAllFeature().values().size()==0) {
return;
}
// add new figures
Hashtable<String , Figure> htFigures = new Hashtable<String , Figure>();
AutoLayout_Feature featureLayout = new AutoLayout_Feature();
for (Iterator itFeature = this.featureModel.getAllFeature().values().iterator() ; itFeature.hasNext() ; )
{
Feature feature = (Feature)itFeature.next();
PatternFeatureFigure figure = new PatternFeatureFigure();
figure.setText(feature.getName());
figure.setAttribute("id" , feature.getID());
figure.setAttribute(FeatureProperties.VARIABILITY , feature.getVariability().getName());
figure.setAttribute(de.FeatureModellingTool.Pattern.ConstantDefinition.FEATURE_ATTRIBUTE_COUNT , Integer.toString(this.template.getParameters().getFeatureNum(feature.getID())));
dv.add(figure);
htFigures.put(feature.getID() , figure);
super.idToFigureMap.add(feature.getID() , figure);
featureLayout.addFeature(feature , figure.size().width , figure.size().height);
}
featureLayout.caculateLayout();
for (Iterator itFeature = this.featureModel.getAllFeature().values().iterator() ; itFeature.hasNext() ; )
{
Feature feature = (Feature)itFeature.next();
AutoLayout_Feature.FeatureLayout fl = featureLayout.getFeatureLayout(feature);
Figure figure = htFigures.get(feature.getID());
figure.moveBy(30 + fl.x, 30 + fl.y);
// figure.setDisplayBox(new Rectangle(fl.x , fl.y));
}
if (this.featureModel.getAllFeatureRelation()!=null)
for (Iterator itRelation = this.featureModel.getAllFeatureRelation().values().iterator() ; itRelation.hasNext() ; )
{
FeatureRelation featureRelation = (FeatureRelation)itRelation.next();
ConnectionFigure cf = null;
if (FeatureRelation.ATTRIBUTE.equals(featureRelation.getName())) {
AttributeConnection dvc = new AttributeConnection();
cf = dvc;
} else if (FeatureRelation.DECOMPOSE.equals(featureRelation.getName())) {
DecomposeConnection ic = new DecomposeConnection();
cf = ic;
} else if (FeatureRelation.REQUIRE.equals(featureRelation.getName())) {
ConstraintConnection cc = new ConstraintConnection(FeatureRelation.REQUIRE);
cc.setEndDecoration(new ArrowTip());
cf = cc;
} else if (FeatureRelation.EXCLUDE.equals(featureRelation.getName())) {
ConstraintConnection cc = new ConstraintConnection(FeatureRelation.EXCLUDE);
cc.setMidDecoration(new CrossDecoration(5));
cf = cc;
}
if (cf!=null) {
cf.setAttribute("id" , featureRelation.getID());
cf.startPoint(htFigures.get(featureRelation.getStartFeature().getID()).center().x , htFigures.get(featureRelation.getStartFeature().getID()).center().y);
cf.endPoint(htFigures.get(featureRelation.getEndFeature().getID()).center().x , htFigures.get(featureRelation.getEndFeature().getID()).center().y);
if (de.FeatureModellingTool.Pattern.ConstantDefinition.isStructRelation(featureRelation)) {
cf.connectStart(htFigures.get(featureRelation.getStartFeature().getID()).getConnectors()[2]);
cf.connectEnd(htFigures.get(featureRelation.getEndFeature().getID()).getConnectors()[1]);
} else {
cf.connectStart(htFigures.get(featureRelation.getStartFeature().getID()).getConnectors()[0]);
cf.connectEnd(htFigures.get(featureRelation.getEndFeature().getID()).getConnectors()[0]);
}
dv.add(cf);
cf.updateConnection();
htFigures.put(featureRelation.getID() , cf);
super.idToFigureMap.add(featureRelation.getID() , cf);
}