Search in sources :

Example 1 with StartAnimationCommand

use of de.prob.animator.command.StartAnimationCommand in project prob2 by bendisposto.

the class StateSpaceProvider method loadFromCommand.

public StateSpace loadFromCommand(final AbstractModel model, final AbstractElement mainComponent, final Map<String, String> preferences, final AbstractCommand loadCmd) {
    StateSpace s = ssProvider.get();
    s.setModel(model, mainComponent);
    List<AbstractCommand> cmds = new ArrayList<>();
    for (Entry<String, String> pref : preferences.entrySet()) {
        cmds.add(new SetPreferenceCommand(pref.getKey(), pref.getValue()));
    }
    try {
        s.execute(new ComposedCommand(cmds));
        s.execute(loadCmd);
        s.execute(new StartAnimationCommand());
    } catch (Exception e) {
        s.kill();
        throw e;
    }
    return s;
}
Also used : StartAnimationCommand(de.prob.animator.command.StartAnimationCommand) StateSpace(de.prob.statespace.StateSpace) AbstractCommand(de.prob.animator.command.AbstractCommand) ArrayList(java.util.ArrayList) SetPreferenceCommand(de.prob.animator.command.SetPreferenceCommand) ComposedCommand(de.prob.animator.command.ComposedCommand)

Aggregations

AbstractCommand (de.prob.animator.command.AbstractCommand)1 ComposedCommand (de.prob.animator.command.ComposedCommand)1 SetPreferenceCommand (de.prob.animator.command.SetPreferenceCommand)1 StartAnimationCommand (de.prob.animator.command.StartAnimationCommand)1 StateSpace (de.prob.statespace.StateSpace)1 ArrayList (java.util.ArrayList)1