use of com.cburch.logisim.circuit.CircuitListener in project logisim-evolution by reds-heig.
the class Project method setCircuitState.
public void setCircuitState(CircuitState value) {
if (value == null || circuitState == value)
return;
CircuitState old = circuitState;
Circuit oldCircuit = old == null ? null : old.getCircuit();
Circuit newCircuit = value.getCircuit();
boolean circuitChanged = old == null || oldCircuit != newCircuit;
if (circuitChanged) {
Canvas canvas = frame == null ? null : frame.getCanvas();
if (canvas != null) {
if (tool != null)
tool.deselect(canvas);
Selection selection = canvas.getSelection();
if (selection != null) {
Action act = SelectionActions.dropAll(selection);
if (act != null) {
doAction(act);
}
}
if (tool != null)
tool.select(canvas);
}
if (oldCircuit != null) {
for (CircuitListener l : circuitListeners) {
oldCircuit.removeCircuitListener(l);
}
}
}
circuitState = value;
stateMap.put(circuitState.getCircuit(), circuitState);
simulator.setCircuitState(circuitState);
if (circuitChanged) {
fireEvent(ProjectEvent.ACTION_SET_CURRENT, oldCircuit, newCircuit);
if (newCircuit != null) {
for (CircuitListener l : circuitListeners) {
newCircuit.addCircuitListener(l);
}
}
}
fireEvent(ProjectEvent.ACTION_SET_STATE, old, circuitState);
}
Aggregations