Пример #1
0
 private Set<String> calculateAddedFeatures(FeatureModel oldModel, FeatureModel newModel) {
   Set<String> addedFeatures = new HashSet<String>();
   for (Feature feature : newModel.getFeatures())
     if (feature.isConcrete()) {
       String name = newModel.getRenamingsManager().getOldName(feature.getName());
       Feature associatedFeature =
           oldModel.getFeature(oldModel.getRenamingsManager().getNewName(name));
       if (associatedFeature == null || associatedFeature.isAbstract()) addedFeatures.add(name);
     }
   return addedFeatures;
 }
Пример #2
0
 public static int getNumberOfReasonsOfRequiresConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return constraint.getNumberOfReasons();
       }
     }
   }
   return -1;
 }
Пример #3
0
 public static boolean existsRequiresConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       }
     }
   }
   return false;
 }
Пример #4
0
 private String createProductDefinition(Configuration configuration) {
   String ret =
       "product " + this.configName + " from " + this.featureModel.getRoot().getName() + " : {";
   int i = 0;
   for (Iterator<Feature> iter = configuration.getSelectedFeatures().iterator();
       iter.hasNext(); ) {
     Feature feature = iter.next();
     if (!feature.isAbstract()) {
       if (i++ != 0) ret += ", ";
       ret += feature.getName();
     }
   }
   return ret + "}";
 }
Пример #5
0
 public static boolean existsExcludeConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.MUTUALLY_EXCLUDES)) {
       // check f1 excludes f2 and viceversa
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       } else if (f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f1.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       }
     }
   }
   return false;
 }
Пример #6
0
 public static List<Feature> getFeatureRequiredFeatures(
     FeatureModel fm, List<IConstraint> constraints, Feature f1) {
   List<Feature> required = new ArrayList<Feature>();
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName()
           .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))) {
         required.add(
             fm.getFeature(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName())));
       }
     }
   }
   return required;
 }
 public RelationDecoration(boolean fill, Feature lastChild, LinkedList<Feature> children) {
   super();
   this.fill = fill;
   this.children = children;
   this.lastChild = lastChild;
   final Color decoratorForgroundColor = FMPropertyManager.getDecoratorForgroundColor();
   setForegroundColor(decoratorForgroundColor);
   setBackgroundColor(decoratorForgroundColor);
   final int diameter = getTargetAnchorDiameter();
   setSize(diameter, diameter >> 1);
   if (lastChild != null) {
     featureModel = lastChild.getFeatureModel();
     this.vertical = FeatureUIHelper.hasVerticalLayout(featureModel);
   }
 }
  @Override
  protected void outlineShape(Graphics graphics) {
    if (fill) return;

    Rectangle r = calculateRectangle();

    double highestAngle1 = Integer.MAX_VALUE;
    double highestAngle2 = Integer.MIN_VALUE;

    if (this instanceof LegendRelationDecoration) {
      highestAngle2 = HALF_ARC ? 360 : calculateAngle(r.getCenter(), getFeatureLocation());
      highestAngle1 = HALF_ARC ? 180 : calculateAngle(r.getCenter(), referencePoint);
      graphics.drawArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1));
    } else {

      if (children != null) {
        for (int i = 0; i < children.size(); i++) {
          Feature temp;
          temp = this.lastChild;
          this.lastChild = children.get(i);
          if (!(this.lastChild.isHidden() && !FeatureUIHelper.showHiddenFeatures(featureModel))) {
            double angle2 = HALF_ARC ? 360 : calculateAngle(r.getCenter(), getFeatureLocation());
            double angle1 = HALF_ARC ? 180 : calculateAngle(r.getCenter(), getFeatureLocation());
            if (angle2 > 450 && !vertical) {
              highestAngle1 = 180;
            } else {
              if (angle1 < highestAngle1) highestAngle1 = angle1;

              if (angle2 > highestAngle2) highestAngle2 = angle2;
              else this.lastChild = temp;
            }
          }
        }
      } else {
        highestAngle2 = HALF_ARC ? 360 : calculateAngle(r.getCenter(), getFeatureLocation());
      }
      r.shrink(7, 7);
      r.y += FeatureUIHelper.getSize(lastChild.getParent()).height / 2;
      if (vertical) {
        r.shrink(2, 2);
        if (highestAngle2 < 270) graphics.drawArc(r.x - 20, r.y, r.width, r.height, 270, (180));
        else
          graphics.drawArc(
              r.x - 20,
              r.y,
              r.width,
              r.height,
              (int) highestAngle1,
              (int) (highestAngle2 - highestAngle1));
      } else {
        if (highestAngle1 > 360) graphics.drawArc(r.x, r.y - 10, r.width, r.height, 180, 180);
        if (highestAngle2 > 450)
          graphics.fillArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1));
        else
          graphics.drawArc(
              r.x,
              r.y - 10,
              r.width,
              r.height,
              (int) (highestAngle1),
              (int) (highestAngle2 - highestAngle1));
      }
    }
  }