Example #1
0
  // olga
  void createGraTra() {
    createGraTraInstance(gragra);
    gratra.addGraTraListener(this);
    System.out.println("The gragra was set or not: " + gratra.setGraGra(gragra));

    gratra.getHostGraph();
  }
Example #2
0
  public static void transform(GraGra grammar, GraTraEventListener l) {
    if (grammar == null) return;

    System.out.println(grammar.getGraTraOptions().toString());
    createGraTraInstance(grammar);

    gratra.addGraTraListener(l);
    gratra.setGraGra(grammar);
    gratra.setHostGraph(grammar.getGraph());
    gratra.enableWriteLogFile(writeLogFile);

    MorphCompletionStrategy strategy = CompletionStrategySelector.getDefault();
    // strategy = new Completion_NAC(new Completion_InjCSP());

    if (grammar.getGraTraOptions().isEmpty()) {
      grammar.setGraTraOptions(strategy);
      gratra.setCompletionStrategy(strategy);
    } else {
      if (grammar.getGraTraOptions().contains("showGraphAfterStep"))
        grammar.getGraTraOptions().remove("showGraphAfterStep");
      gratra.setGraTraOptions(grammar.getGraTraOptions());
      System.out.println("Options:  " + grammar.getGraTraOptions());
      System.out.println();
    }

    grammar.destroyAllMatches();

    if (priority) ((PriorityGraTraImpl) gratra).transform();
    else if (layered) ((LayeredGraTraImpl) gratra).transform();
    else if (ruleSequence) ((RuleSequencesGraTraImpl) gratra).transform();
    else ((DefaultGraTraImpl) gratra).transform();
  }
Example #3
0
  public boolean doStep(Rule r) {
    Match match = gratra.createMatch(r);
    System.out.println("The match was: " + match.getRule().getName().toString());

    // olga
    while (match.nextCompletion()) {
      if (match.isValid()) {
        try {
          Morphism co = StaticStep.execute(match);
          System.out.println("Rule  " + match.getRule().getName() + " : step is done");
          didTransformation = true;
          Graph graph = co.getOriginal();
          Graph graph2 = co.getImage();
          System.out.println();
          //					System.out.println("The image parameters are: " + graph.toString());
          //					System.out.println("The OUTPUT parameters are: " + graph2.toString());

          // olga
          outPar = getOutputParameters(r, outPar);
          for (int i = 0; i < outPar.size(); i++) {
            VarMember p = outPar.get(i);
            String parVal = getValueOfOutputParameter(p, r, (OrdinaryMorphism) co);
            this.outParVal.put(p.getName(), parVal);
          }

          ((OrdinaryMorphism) co).dispose();
          return true;
        } catch (TypeException ex) {
          ex.printStackTrace();
          gragra.destroyMatch(match);
          System.out.println(
              "Rule  "
                  + match.getRule().getName()
                  + " : step of match failed : "
                  + ex.getMessage());
        }
      } else
        System.out.println(
            "Rule  "
                + match.getRule().getName()
                + " : a match completion is not valid; try to find the next ones");
    }
    System.out.println("Rule  " + match.getRule().getName() + " : match could not be found");
    return false;
    // gragra.destroyMatch(match);
    // match.clear();
  }