Esempio n. 1
0
  /**
   * @param states - List of geometric nodes (GElementFAState) for all nodes in the FA
   * @param scale - Vector2D of X scale and Y scale factors
   * @return The string that contains all of the node declarations and positioning information
   */
  private String nodesToLatex(List<GElementFAState> states, Vector2D scale) {

    List<String> latexNodes = new LinkedList<String>();

    int i = 0;
    for (GElementFAState a : states) {
      String latexOneNode = "";

      String name = a.getState().name;
      String id = "q" + i;
      i += 1;

      FAState state = a.getState();

      latexOneNode += "\\node";

      if (state.isAccepted() && state.isStart()) {
        latexOneNode += " [state, initial, accepting]";
      } else if (state.isStart()) {
        latexOneNode += " [state, initial]";
      } else if (state.isAccepted()) {
        latexOneNode += " [state, accepting]";
      } else {
        latexOneNode += " [state]";
      }

      int x_pos = (int) ((a.getPositionX() - this.left) / scale.getX());
      int y_pos = (int) ((a.getPositionY() - this.top) / scale.getY());
      y_pos *= -1;
      latexOneNode += " (" + id + ")";
      latexOneNode += " at (" + x_pos + "," + y_pos + ")";
      latexOneNode += " {" + name + "};";

      latexNodes.add(latexOneNode);
    }

    String s = "";
    for (String a : latexNodes) s += a + "\n";
    return s;
  }