public void addLinkToOperation(GElementTMOperation op, String pattern) {
   Set symbols = Tool.symbolsInPattern(pattern);
   Set variables = Tool.variablesInPattern(pattern);
   if (symbols.size() == 0) {
     operation.addLinkToOperation(op.operation, "", variables);
   } else {
     Iterator iterator = symbols.iterator();
     while (iterator.hasNext()) {
       String symbol = (String) iterator.next();
       operation.addLinkToOperation(op.operation, symbol, variables);
     }
   }
 }
 public void removeLinkToOperation(GElementTMOperation op, String pattern) {
   Set symbols = Tool.symbolsInPattern(pattern);
   if (symbols.size() == 0) {
     operation.removeLinkToOperation(op.operation, "");
   } else {
     Iterator iterator = symbols.iterator();
     while (iterator.hasNext()) {
       String symbol = (String) iterator.next();
       operation.removeLinkToOperation(op.operation, symbol);
     }
   }
 }
Exemplo n.º 3
0
 public GLink getTransition(FATransition transition) {
   ListIterator e = elements.listIterator();
   while (e.hasNext()) {
     GElement element = (GElement) e.next();
     if (element.getClass().equals(GLink.class)) {
       GLink link = (GLink) element;
       if (getState1(link).state.name.equals(transition.s1)
           && getState2(link).state.name.equals(transition.s2)
           && Tool.symbolsInPattern(link.pattern).contains(transition.symbol)) {
         return link;
       }
     }
   }
   return null;
 }
Exemplo n.º 4
0
  public void reconstruct() {
    elements.clear();
    List stateNames = machine.getStateList();

    ListIterator iterator = stateNames.listIterator(stateNames.size());

    int x = 0;
    int y = 0;
    while (iterator.hasPrevious()) {
      addElement(new GElementFAState((FAState) iterator.previous(), 100 + x * 200, 50 + y * 200));
      x++;
      if (x > 4) {
        y++;
        x = 0;
      }
    }

    List transitions = machine.getTransitions().getTransitions();
    iterator = transitions.listIterator();
    while (iterator.hasNext()) {
      FATransition transition = (FATransition) iterator.next();

      GElementFAState s1 = getState(transition.s1);
      GElementFAState s2 = s1;
      if (transition.s1.equals(transition.s2) == false) s2 = getState(transition.s2);

      GLink link = getLink(s1, s2);
      if (link == null)
        addElement(
            new GLink(
                s1,
                GElementFAState.ANCHOR_CENTER,
                s2,
                GElementFAState.ANCHOR_CENTER,
                GLink.SHAPE_ARC,
                transition.symbol,
                20));
      else link.pattern = Tool.addSymbolToPattern(link.pattern, transition.symbol);
    }
  }