use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.
the class ComponentDrawContext method drawPins.
public void drawPins(Component comp) {
Color curColor = g.getColor();
for (EndData e : comp.getEnds()) {
Location pt = e.getLocation();
if (getShowState()) {
CircuitState state = getCircuitState();
g.setColor(state.getValue(pt).getColor());
} else {
g.setColor(Color.BLACK);
}
g.fillOval(pt.getX() - PIN_OFFS, pt.getY() - PIN_OFFS, PIN_RAD, PIN_RAD);
}
g.setColor(curColor);
}
use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.
the class Project method getCircuitState.
public CircuitState getCircuitState(Circuit circuit) {
if (circuitState != null && circuitState.getCircuit() == circuit) {
return circuitState;
} else {
CircuitState ret = stateMap.get(circuit);
if (ret == null) {
ret = new CircuitState(this, circuit);
stateMap.put(circuit, ret);
}
return ret;
}
}
use of com.cburch.logisim.circuit.CircuitState 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);
}
use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.
the class TtyInterface method loadRam.
private static boolean loadRam(CircuitState circState, File loadFile) throws IOException {
if (loadFile == null)
return false;
boolean found = false;
for (Component comp : circState.getCircuit().getNonWires()) {
if (comp.getFactory() instanceof Ram) {
Ram ramFactory = (Ram) comp.getFactory();
InstanceState ramState = circState.getInstanceState(comp);
ramFactory.loadImage(ramState, loadFile);
found = true;
}
}
for (CircuitState sub : circState.getSubstates()) {
found |= loadRam(sub, loadFile);
}
return found;
}
use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.
the class TtyInterface method prepareForTty.
private static boolean prepareForTty(CircuitState circState, ArrayList<InstanceState> keybStates) {
boolean found = false;
for (Component comp : circState.getCircuit().getNonWires()) {
Object factory = comp.getFactory();
if (factory instanceof Tty) {
Tty ttyFactory = (Tty) factory;
InstanceState ttyState = circState.getInstanceState(comp);
ttyFactory.sendToStdout(ttyState);
found = true;
} else if (factory instanceof Keyboard) {
keybStates.add(circState.getInstanceState(comp));
found = true;
}
}
for (CircuitState sub : circState.getSubstates()) {
found |= prepareForTty(sub, keybStates);
}
return found;
}
Aggregations