fixed a bug in the state management

This commit is contained in:
hneemann 2017-09-11 16:42:50 +02:00
parent d2ec993056
commit adec19bc5c
3 changed files with 17 additions and 5 deletions

View File

@ -1042,6 +1042,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
circuitComponent.setManualChangeObserver(new MicroStepObserver(model)); circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
} }
}); });
stateManager.setActualState(stoppedState);
} }
private void clearModelDescription() { private void clearModelDescription() {

View File

@ -43,13 +43,15 @@ public class ModifyMoveSelected implements Modification {
@Override @Override
public void modify(Circuit circuit, ElementLibrary library) { public void modify(Circuit circuit, ElementLibrary library) {
ArrayList<Movable> list = circuit.getElementsToMove(min, max); ArrayList<Movable> list = circuit.getElementsToMove(min, max);
for (Movable m : list) if (list != null) {
m.move(accumulatedDelta); for (Movable m : list)
m.move(accumulatedDelta);
for (int i = 0; i < accumulatedRotate; i++) for (int i = 0; i < accumulatedRotate; i++)
rotateElements(list, center); rotateElements(list, center);
circuit.elementsMoved(); circuit.elementsMoved();
}
} }
/** /**

View File

@ -48,4 +48,13 @@ public class StateManager {
public boolean isActive(State state) { public boolean isActive(State state) {
return actualState == state; return actualState == state;
} }
/**
* Sets the actual state. Ony used to init the state manager
*
* @param active the state which is active.
*/
public void setActualState(State active) {
this.actualState = active;
}
} }