예제 #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;
  }
 public GLink(
     GElement source,
     String sourceAnchorKey,
     GElement target,
     String targetAnchorKey,
     int shape,
     String pattern,
     Point mouse,
     double flateness) {
   this.source = source;
   this.target = target;
   this.sourceAnchorKey = sourceAnchorKey;
   this.targetAnchorKey = targetAnchorKey;
   this.shape = shape;
   this.pattern = pattern;
   initializeLink(flateness);
   setSourceTangentOffset(source.getDefaultAnchorOffset(sourceAnchorKey));
   setTargetTangentOffset(target.getDefaultAnchorOffset(targetAnchorKey));
   link.setDirection(Vector2D.vector(mouse).sub(target.getPosition()));
 }
 public void setMousePosition(Point mouse) {
   link.setDirection(Vector2D.vector(mouse).sub(target.getPosition()));
   link.setMousePosition(Vector2D.vector(mouse));
 }