44
44
states = Sets.newHashSet();
46
public void addState(State s){
47
Preconditions.checkNotNull(s);
49
observable.notifyObservers();
51
public ImmutableSet<State> getStates() {
52
return ImmutableSet.copyOf(states);
54
public void removeState(State stateModel) {
55
stateModel.disconnectAll();
56
states.remove(stateModel);
57
observable.notifyObservers();
60
public BoxCopyResult deepCopy(){
61
FSMBox newBox = new FSMBox();
62
newBox.setName(getName());
63
newBox.setBounds(new Rectangle(getBounds()));
46
public FSMBox(FSMBox toCopy){
48
states = Sets.newHashSet();
64
49
HashBiMap<State, State> oldToNew = HashBiMap.create();
65
for (State s : states){
66
State newState = new State(s.getName(),s.getPosition().getCopy(),newBox);
67
newState.setEntryActions(s.getEntryActions());
68
newState.setExitActions(s.getExitActions());
69
newState.setInitial(s.isInitial());
50
for (State s : toCopy.states){
51
State newState = new State(s, this);
70
52
oldToNew.put(s, newState);
71
newBox.addState(newState);
73
54
for (Entry<State, State> e : oldToNew.entrySet()){
74
55
State oldfrom = e.getKey();
78
59
State newTo = oldToNew.get(oldTo);
79
60
Transition transition = Transition.create(newfrom, newTo);
80
61
transition.setCondition(trans.getCondition());
84
return copyPorts(newBox);
67
protected void addStateInternal(State s){
69
observable.notifyObservers();
71
public void restoreState(State s){
72
Preconditions.checkArgument(s.getBox()==this);
75
public ImmutableSet<State> getStates() {
76
return ImmutableSet.copyOf(states);
78
public void removeState(State stateModel) {
79
stateModel.disconnectAll();
80
states.remove(stateModel);
81
observable.notifyObservers();
84
public Box deepCopy(){
85
return new FSMBox(this);
87
88
public BoxDescriptor getDescriptor() {