Beispiel #1
0
 /*
  * (non-Javadoc)
  *
  * @see rationals.transformations.UnaryTransformation#transform(rationals.Automaton)
  */
 public Automaton transform(Automaton a) {
   Automaton b = new Automaton();
   Map qm = new HashMap();
   for (Iterator i = a.states().iterator(); i.hasNext(); ) {
     State q = (State) i.next();
     State p = b.addState(q.isInitial(), q.isTerminal());
     qm.put(q, p);
   }
   Set alph = new HashSet();
   for (Iterator it = a.states().iterator(); it.hasNext(); ) {
     State q = (State) it.next();
     alph.addAll(alphabet);
     for (Iterator i2 = a.delta(q).iterator(); i2.hasNext(); ) {
       Transition tr = (Transition) i2.next();
       try {
         b.addTransition(
             new Transition((State) qm.get(tr.start()), tr.label(), (State) qm.get(tr.end())));
       } catch (NoSuchStateException e) {
       }
       alph.remove(tr.label());
     }
     for (Iterator i2 = alph.iterator(); i2.hasNext(); ) {
       try {
         b.addTransition(new Transition(q, i2.next(), q));
       } catch (NoSuchStateException e) {
       }
     }
     alph.clear();
   }
   return b;
 }
 /**
  * The layout initializes a private Map from coordinates to state where all coordinates are set to
  * (0,0)
  *
  * @see rationals.converters.algorithms.LayoutAlgorithm#layout(Automaton)
  */
 public void layout(Automaton aut) throws ConverterException {
   automata = aut;
   // create a coord object for each state with default values
   Iterator it = automata.states().iterator();
   while (it.hasNext()) {
     Coord c = new Coord(0, 0);
     statesCoord.put(c, (State) it.next());
   }
 }