Package de.FeatureModellingTool.FeatureModel

Examples of de.FeatureModellingTool.FeatureModel.VPConstraint


            }
        } else if (refineType == Refinement.Specialize) {
            PLConnection topRelation = new PLConnection();
            CFRelation topCFRelation = null;
            VPConstraintFigure vp = new VPConstraintFigure();
            VPConstraint vpConstraint = null;

            int xDis, yDis;
            xDis = 80;
            yDis = 60;

            anchor.translate(0, yDis);

            Rectangle parentBounds = parent.getDisplayBox();
            Rectangle bounds = vp.getDisplayBox();
            vp.moveBy(anchor.x + parentBounds.width / 2 - (bounds.x + bounds.width) / 2, anchor.y - (bounds.y + bounds.height) / 2);

            vpConstraint = constraintModelEditor.addVPConstraint();

            vp.setAttribute("id", vpConstraint.getID());
            drawingView.add(vp);

            topRelation.startPoint(anchor.x, anchor.y);
            topRelation.endPoint(anchor.x, anchor.y);
            drawingView.add(topRelation);
            topRelation.connectStart(vp.getStartConnector());
            topRelation.connectEnd(parent.getConnectors()[TextFigure.SOUTH]);
            topRelation.setAttribute(PLConnection.DISPLAY_MODE, PLConnection.H_V_MODE);
            topRelation.updateConnection();


            topCFRelation = constraintModelEditor.addCFRelation(parentFeature, vpConstraint, true, CFRModifier.Affirmation);
            topRelation.setAttribute("id", topCFRelation.getID());

            //����id��figure��ӳ���
            if (idToFigureMap != null) {
                idToFigureMap.add(vpConstraint.getID(), vp);
                idToFigureMap.add(topCFRelation.getID(), topRelation);
            }

            PLConnection relation[] = new PLConnection[childCount];
            CFRelation childCFRelation[] = new CFRelation[childCount];
View Full Code Here


    public boolean canConnect(String featureId, String constraintId, boolean isSource) {
  if ((featureId == null) || (constraintId == null))
      return false;
 
  //--not vp constraint: no validation
  VPConstraint vpConstraint = getConstraintModel().getVPConstraint(constraintId);
  if (vpConstraint == null)
      return true;
 
  //--connect to vp constraint source: feature as parent of other features
  if (isSource) {
      int sourceCount = vpConstraint.getSourceFeatureSet().size();
      if (sourceCount > 1)
    throw new RuntimeException("model error founded: mutiple sources in a vp constraint");
      else if (sourceCount == 1)
    return false;

      //--if the root of feature is a node of vp constraint sinks
      Feature root = getRoot(featureId);
      Iterator<Feature> itF = vpConstraint.getSinkFeatureSet().iterator();
      while (itF.hasNext()) {
    Feature sink = itF.next();
    Feature sinkParent = getParent(sink.getID());
    if (sinkParent != null)
        return false;
    if (root.getID().equals(sink.getID()))
        return false;
      }
      return true;
  }
 
  //--connect to vp constaint sink:
  Feature parent = getParent(featureId);
  if (parent != null)
      return false;
  //--if the root of vp constraint source is the feature
  Set<Feature> setF = vpConstraint.getSourceFeatureSet();
  if (setF.size() > 1)
      throw new RuntimeException("model error founded: mutiple sources in a vp constraint");
  else if (setF.size() == 0)
      return true;
  Feature source = setF.iterator().next();
View Full Code Here

 
  if (newEntityId.equals(featureId) || newEntityId.equals(constraintId))
      return true;
 
  if (isSource && !bChangeConstraint) { //---change parent feature
      VPConstraint vpConstraint = getConstraintModel().getVPConstraint(constraintId);
      Set<Feature> setSinkFeature = vpConstraint.getSinkFeatureSet();
      Iterator<Feature> itSinkFeature = setSinkFeature.iterator();
      while (itSinkFeature.hasNext()) {
    String sinkFeatureId = itSinkFeature.next().getID();
    if (sinkFeatureId.equals(newEntityId))
        return false;
View Full Code Here

        return false;
      }
      if (!(constraint instanceof VPConstraint)) {
        return false;
      }
      VPConstraint vpc = (VPConstraint)constraint;
      if (vpc.getSourceFeatureSet().contains(node.getFeature())) {
        label.setIcon(getNodeIcon(node));
        render.setHorizontalAlignment(SwingConstants.LEFT);
        return true;
      }
      if (vpc.getSinkFeatureSet().contains(node.getFeature())) {
        label.setIcon(getNodeIcon(node));
        render.setHorizontalAlignment(SwingConstants.RIGHT);
        return true;
      }
      return false;
View Full Code Here

 
    public ImageIcon getConstraintIcon(Object cons , ConstraintModel constraintModel , CustomizationVersion cv) {
      if (!(cons instanceof VPConstraint)) {
        return null;
      }
      VPConstraint vp = (VPConstraint)cons;
      CompositeConstraintPortType lType = null;
      if (vp.getType().equals(VPConstraintType.SingleVP)) {
        lType = CompositeConstraintPortType.Single;
      } else if (vp.getType().equals(VPConstraintType.MultiVP)) {
        lType = CompositeConstraintPortType.Multi;
      } else if (vp.getType().equals(VPConstraintType.AllVP)) {
        lType = CompositeConstraintPortType.All;
      }
      CompositeConstraintPortType rType = lType;
      if (cv==null) {
          return ImageManager.getInstance().getCompositeConstraintHeader(lType , rType , CompositeConstraintType.Equivalence , null , null , ImageManager.ConstraintStat.csNone);
      } else {
        List<Customization> sCustomization = new ArrayList<Customization>();
        for (Iterator<Feature> itFeature=vp.getSourceFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature feature = itFeature.next();
          CFRelation cf = constraintModel.getCFRelation(feature , vp , true);
          if (cf==null) {
              cf = constraintModel.getCFRelation(feature , vp , false);
          }
          sCustomization.add(super.convertCustomization(cv.getFinalCustomizationById(feature.getID()) , cf));
        }
        Customization lValue = Customization.Undecided;
        if (lType.getName().equals(CompositeConstraintPortType.Single.getName())) {
          if (super.getCustomizationCount(sCustomization , Customization.Undecided)>0) {
            lValue = Customization.Undecided;
          } else if (super.getCustomizationCount(sCustomization , Customization.Selected)==1) {
            lValue = Customization.Selected;
          } else {
            lValue = Customization.Unselected;
          }
        } else if (lType.getName().equals(CompositeConstraintPortType.All.getName())) {
          if (super.getCustomizationCount(sCustomization , Customization.Undecided)>0) {
            lValue = Customization.Undecided;
          } else if (super.getCustomizationCount(sCustomization , Customization.Unselected)==0) {
            lValue = Customization.Selected;
          } else {
            lValue = Customization.Unselected;
          }
        } else /*if (gc.getType().getName().equals(GroupConstraintType.SingleGroup))*/ {
          if (super.getCustomizationCount(sCustomization , Customization.Selected)>0) {
            lValue = Customization.Selected;
          } else if (super.getCustomizationCount(sCustomization , Customization.Undecided)>0) {
            lValue = Customization.Undecided;
          } else {
            lValue = Customization.Unselected;
          }
        }
       
        sCustomization = new ArrayList<Customization>();
        for (Iterator<Feature> itFeature=vp.getSinkFeatureSet().iterator() ; itFeature.hasNext() ; ) {
          Feature feature = itFeature.next();
          CFRelation cf = constraintModel.getCFRelation(feature , vp , true);
          if (cf==null) {
              cf = constraintModel.getCFRelation(feature , vp , false);
          }
View Full Code Here

    public boolean isRelatedFeature(Object cons , Feature feature) {
      if (!(cons instanceof VPConstraint)) {
        return false;
      }
      VPConstraint vpc = (VPConstraint)cons;
      return vpc.getSourceFeatureSet().contains(feature) || vpc.getSinkFeatureSet().contains(feature);
    }
View Full Code Here

   
    public Set<Feature> getRelatedFeatures(Object cons) {
      if (!(cons instanceof VPConstraint)) {
        return null;
      }
      VPConstraint vpc = (VPConstraint)cons;
      Set<Feature> result = new HashSet<Feature>();
      result.addAll(vpc.getSourceFeatureSet());
      result.addAll(vpc.getSinkFeatureSet());
      return result;
    }
View Full Code Here

//    Map<Feature,  AtomedFeature>  allAtomedFeature  =  atomSet.getAllAtomedFeatures();
    Map  vpConstraint  =  constraintModel.getAllVPConstraint();
    Iterator  e  =  vpConstraint.keySet().iterator();
    while(e.hasNext()){
    //  System.out.println("************Building_VPConstraint");
      VPConstraint  c  =  (VPConstraint)vpConstraint.get(e.next());
      if(c.getSourceFeatureSet().isEmpty() || c.getSinkFeatureSet().isEmpty())
        continue;
      Feature  sourceFeature  =  c.getSourceFeatureSet().iterator().next();
      AtomedFeature  sourceAtomedFeature  =  allAtomedFeatures.get(sourceFeature);
      Set  sinkFeature    =  c.getSinkFeatureSet();
      VPConstraintType  type  =  c.getType();
      int  tempBdd  =  -1;
     
//      ����sink��BDD
      if      (type  ==  VPConstraintType.AllVP){
        Iterator  i  =  sinkFeature.iterator();
View Full Code Here

        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllVPConstraint().values());
        for (Iterator<VPConstraint> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            VPConstraint gc = itConstraint.next();

            boolean newFeature = false;
            boolean allNewFeature = true;
            for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }
            for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                Feature constraintFeature = itFeature.next();
                if (htNameMap.containsKey(constraintFeature.getID())) {
                    newFeature = true;
                } else {
                    allNewFeature = false;
                }
            }

            if (newFeature) {
                VPConstraint newConstraint = null;
                if (allNewFeature) {
                    newConstraint = constraintModelEditor.addVPConstraint();
                    vpConstraintEditor.setType(newConstraint, gc.getType());
                    htNameMap.put(gc.getID(), newConstraint.getID());
                } else {
                    newConstraint = gc;
                }

                for (Iterator<Feature> itFeature = gc.getSourceFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        vpConstraintEditor.addSourceFeature(newConstraint, constraintFeature);
                    }
                }

                for (Iterator<Feature> itFeature = gc.getSinkFeatureSet().iterator(); itFeature.hasNext();) {
                    Feature constraintFeature = itFeature.next();
                    if (allNewFeature || htNameMap.containsKey(constraintFeature.getID())) {
                        constraintFeature = featureModel.getFeature(htNameMap.get(constraintFeature.getID()));
                        vpConstraintEditor.addSinkFeature(newConstraint, constraintFeature);
                    }
                }
            }
        }

        constraints.clear();
        constraints.addAll(constraintModel.getAllCFRelation().values());
        for (Iterator<CFRelation> itConstraint = constraints.iterator(); itConstraint.hasNext();) {
            CFRelation gc = itConstraint.next();

            boolean newFeature = false;
            Feature cfFeature = gc.getFeature();
            if (htNameMap.containsKey(gc.getFeature().getID())) {
                cfFeature = featureModel.getFeature(htNameMap.get(gc.getFeature().getID()));
                newFeature = true;
            }
            Constraint cfConstraint = gc.getConstraint();
            if (htNameMap.containsKey(gc.getConstraint().getID())) {
                cfConstraint = constraintModel.getConstraint(htNameMap.get(gc.getConstraint().getID()));
                newFeature = true;
            }
            if (newFeature) {
                CFRelation newConstraint = constraintModelEditor.addCFRelation(cfFeature, cfConstraint, gc.isSource(), gc.getModifier());
                htNameMap.put(gc.getID(), newConstraint.getID());
            }
        }
    }
View Full Code Here

                //--���������VPConstraint�ϵĹ�ϵ��
                CFRelation relation = (CFRelation) evt.getNewValue();
                Constraint constraint = relation.getConstraint();

                if (constraint instanceof VPConstraint) {
                    VPConstraint vpc = (VPConstraint) constraint;
                    Feature feature = relation.getFeature();
                    FeatureNode featureNode = getTreeNode(root, feature);

                    boolean isSource = relation.isSource();
                    if (isSource) { //--������source��ϵ: ���е�sink��Ϊsource���ӽڵ�
                        Iterator<Feature> it = vpc.getSinkFeatureSet().iterator();
                        while (it.hasNext()) {
                            Feature sink = it.next();
                            FeatureNode child = getTreeNode(root, sink);
                            ///---���û��һ�������ϵ�Ľڵ㣬������һ�������Ľڵ�
                            FeatureNode specNode = featureNode.getSpecilizationNode();
                            if (specNode == null) {
                                specNode = new FeatureNode(context, FeatureNode.NODE_TYPE_SPECILIZATION);
                                //featureNode.add(specNode);
                                treeTableModel.insertNodeInto(specNode, featureNode, featureNode.getChildCount());
                            }
                            //specNode.add(child);
                            treeTableModel.removeNodeFromParent(child);
                            treeTableModel.insertNodeInto(child, specNode, specNode.getChildCount());
                        }
                    } else { //--������sink��ϵ: ������sink��Ϊsource��specNode���ӽڵ�
                        Iterator<Feature> it = vpc.getSourceFeatureSet().iterator();
                        if (it.hasNext()) {
                            Feature source = it.next();
                            FeatureNode parent = getTreeNode(root, source);
                            FeatureNode specNode = parent.getSpecilizationNode();
                            if (specNode == null) {
                                specNode = new FeatureNode(context, FeatureNode.NODE_TYPE_SPECILIZATION);
                                //parent.add(specNode);
                                treeTableModel.insertNodeInto(specNode, parent, parent.getChildCount());
                            }
                            //specNode.add(featureNode);
                            treeTableModel.removeNodeFromParent(featureNode);
                            treeTableModel.insertNodeInto(featureNode, specNode, specNode.getChildCount());
                        }
                    }
                }
            } else if (propertyName.equals(ConstraintModelProperties.RELATION_REMOVED)) {
                //--���������VPConstraint�ϵĹ�ϵ��
                CFRelation relation = (CFRelation) evt.getOldValue();
                Constraint constraint = relation.getConstraint();

                if (constraint instanceof VPConstraint) {
                    VPConstraint vpc = (VPConstraint) constraint;
                    Feature feature = relation.getFeature();
                    FeatureNode featureNode = getTreeNode(root, feature);

                    boolean isSource = relation.isSource();
                    if (isSource) { //--ɾ����source��ϵ: ���е�sink��Ϊ���ڵ㣬��������������Ƿ�ɾ��������ϵ�ڵ�
                        Iterator<Feature> it = vpc.getSinkFeatureSet().iterator();
                        FeatureNode specNode = null;
                        while (it.hasNext()) {
                            Feature sink = it.next();
                            FeatureNode sinkNode = getTreeNode(root, sink);
                            specNode = (FeatureNode) sinkNode.getParent();
View Full Code Here

TOP

Related Classes of de.FeatureModellingTool.FeatureModel.VPConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.