private void printGraph() {
    // GUITARLog.log.info("Graph");

    List<EventType> eventList = efg.getEvents().getEvent();
    int eventGraphSize = eventList.size();
    EventGraphType eventGraph = efg.getEventGraph();

    for (int row = 0; row < eventGraphSize; row++) {

      EventType currentEvent = eventList.get(row);
      Vector<EventType> s = new Vector<EventType>();

      for (int col = 0; col < eventGraphSize; col++) {

        EventType event = eventList.get(col);

        int relation = eventGraph.getRow().get(row).getE().get(col);

        if (relation == GUITARConstants.FOLLOW_EDGE) {
          GUITARLog.log.info(
              currentEvent.getEventId()
                  + ","
                  + currentEvent.getWidgetId()
                  + "->"
                  + event.getEventId()
                  + ","
                  + event.getWidgetId());
        }
      }
      GUITARLog.log.info("");
    }
  }
Exemple #2
0
  /** Get follow relations in the input graph */
  private void parseFollowRelations() {

    if (inputGraph == null) return;

    List<EventType> eventList = inputGraph.getEvents().getEvent();
    int eventGraphSize = eventList.size();
    EventGraphType eventGraph = inputGraph.getEventGraph();

    succs = new Hashtable<EventType, Vector<EventType>>();
    preds = new Hashtable<EventType, Vector<EventType>>();

    for (int row = 0; row < eventGraphSize; row++) {

      EventType currentEvent = eventList.get(row);
      // String currentEventType = currentEvent.getType();

      Vector<EventType> s = new Vector<EventType>();

      for (int col = 0; col < eventGraphSize; col++) {

        // EventType other = eventList.get(col);
        // String eventType = other .getType();

        int relation = eventGraph.getRow().get(row).getE().get(col);
        // int relation = eventGraph.getRow().get(col).getE().get(row);

        // Other is followed by current event: current -> other
        if (relation != GUITARConstants.NO_EDGE) {

          EventType otherEvent = eventList.get(col);
          s.add(otherEvent);

          if (relation == GUITARConstants.REACHING_EDGE
              && !otherEvent.getEventId().equals(currentEvent.getEventId())) {

            // Create preds list
            Vector<EventType> p = preds.get(otherEvent);
            if (p == null) {
              p = new Vector<EventType>();
            }
            p.add(currentEvent);
            preds.put(otherEvent, p);
          }
        }
        succs.put(currentEvent, s);
      }
    }
  }
Exemple #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * edu.umd.cs.guitar.graph.plugin.G2GPlugin#parseGraph(edu.umd.cs.guitar
   * .model.data.EFG)
   */
  @Override
  public boolean parseGraph() {
    // initialize
    parseFollowRelations();
    parseInitialEvents();

    outputGraph = factory.createEFG();
    map = factory.createMapping();

    EventsType eventList = factory.createEventsType();
    EventGraphType eventGraph = factory.createEventGraphType();

    // select interaction events
    List<EventType> lEventList = getEventList();

    // set initial events
    InitialMappingListType lInitialMappingList = factory.createInitialMappingListType();

    for (EventType event : lEventList) {
      LinkedList<EventType> pathToRoot = pathToRoot(event);

      if (pathToRoot != null) {
        pathToRoot.removeLast();
        if (pathToRoot.size() > 0) {

          event.setInitial(true);
          InitialMappingType initialMapping = factory.createInitialMappingType();

          initialMapping.setEventId(event.getEventId());

          PathType mappingPathToRoot = factory.createPathType();
          for (EventType eventToRoot : pathToRoot)
            mappingPathToRoot.getEventId().add(eventToRoot.getEventId());

          initialMapping.setPath(mappingPathToRoot);
          lInitialMappingList.getIntialMapping().add(initialMapping);
        }
      }
    }

    map.setInitialMappingList(lInitialMappingList);

    eventList.setEvent(lEventList);
    outputGraph.setEvents(eventList);

    // mapping edge
    EdgeMappingListType edgeMappingList = factory.createEdgeMappingListType();

    // build edge
    List<RowType> lRowList = new ArrayList<RowType>();
    for (EventType firstEvent : lEventList) {
      int indexFirst = lEventList.indexOf(firstEvent);
      // System.out.println("Anlyzing row: " + indexFirst);
      RowType row = factory.createRowType();

      for (EventType secondEvent : lEventList) {
        int indexSecond = lEventList.indexOf(secondEvent);

        List<EventType> path = getInteractionFreePath(firstEvent, secondEvent);
        int cellValue;

        if (path != null) {

          cellValue = 1;

          if (path.size() > 0) {
            EdgeMappingType edgeMapping = factory.createEdgeMappingType();
            edgeMapping.setSourceId(firstEvent.getEventId());
            edgeMapping.setTargetId(secondEvent.getEventId());

            PathType eventPath = factory.createPathType();

            for (EventType event : path) eventPath.getEventId().add(event.getEventId());

            edgeMapping.setPath(eventPath);
            edgeMappingList.getEdgeMapping().add(edgeMapping);
          }

        } else {
          cellValue = 0;
        }

        row.getE().add(indexSecond, cellValue);
      }

      lRowList.add(indexFirst, row);
    }

    eventGraph.setRow(lRowList);
    outputGraph.setEventGraph(eventGraph);

    map.setEdgeMappingList(edgeMappingList);

    // debug
    System.out.println("===========================");
    System.out.println("OUTPUT GRAPH");
    printGraph(outputGraph);

    return true;
  }