public void toggleStartState(GElementFAState state) { if (state.isStart() == false) { Iterator iterator = elements.iterator(); while (iterator.hasNext()) { GElement element = (GElement) iterator.next(); if (element instanceof GElementFAState) { ((GElementFAState) element).setStart(false); } } } state.toggleStart(); }
/** * @param name The name of the state / node * @return Index of the state with the given name */ private Integer getLatexId(String name) { // List <FAState> states = machine.getStateList(); List<GElementFAState> states = getStates(); int i = 0; for (GElementFAState a : states) { if (a.getLabel().equals(name)) return i; i++; } java.lang.System.err.print("Error getting transition node ID"); java.lang.System.exit(1); return 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 Vector2D getScaleFactor(List<GElementFAState> states) { double minX, minY, maxX, maxY; double scaleX, scaleY; Iterator<GElementFAState> iterator = states.iterator(); if (iterator.hasNext()) { GElementFAState node = iterator.next(); minX = node.getPositionX(); maxX = minX; minY = node.getPositionY(); maxY = minY; while (iterator.hasNext()) { node = iterator.next(); if (node.getPositionX() < minX) { minX = node.getPositionX(); } else if (node.getPositionX() > maxX) { maxX = node.getPositionX(); } if (node.getPositionY() < minY) { minY = node.getPositionY(); } else if (node.getPositionY() > maxY) { maxY = node.getPositionY(); } } this.top = (int) minY; this.left = (int) minX; this.right = (int) maxX; this.bottom = (int) maxY; scaleX = ((maxX - minX) / 13); scaleY = ((maxY - minY) / 10); } else { scaleX = 100; scaleY = 100; } return new Vector2D(scaleX, scaleY); }