mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-12 06:15:32 -04:00
removed the observer from the applyStateMonitor method
This commit is contained in:
parent
dfd9fb8ac7
commit
395c3dd47d
@ -333,7 +333,7 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
interactor = null;
|
||||
resetShape();
|
||||
} else
|
||||
interactor = getShape().applyStateMonitor(ioState, null);
|
||||
interactor = getShape().applyStateMonitor(ioState);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,13 +344,10 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
* @param pos the position
|
||||
* @param posInComponent position in CircuitComponent
|
||||
* @param modelSync used to access the running model
|
||||
* @return true if model is changed
|
||||
*/
|
||||
public boolean elementClicked(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
public void elementClicked(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
if (interactor != null)
|
||||
return interactor.clicked(cc, pos, ioState, element, modelSync);
|
||||
else
|
||||
return false;
|
||||
interactor.clicked(cc, pos, ioState, element, modelSync);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,13 +358,10 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
* @param pos the position
|
||||
* @param posInComponent position in CircuitComponent
|
||||
* @param modelSync used to access the running model
|
||||
* @return true if model is changed
|
||||
*/
|
||||
public boolean elementPressed(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
public void elementPressed(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
if (interactor != null)
|
||||
return interactor.pressed(cc, pos, ioState, element, modelSync);
|
||||
else
|
||||
return false;
|
||||
interactor.pressed(cc, pos, ioState, element, modelSync);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,13 +372,10 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
* @param pos the position
|
||||
* @param posInComponent position in CircuitComponent
|
||||
* @param modelSync used to access the running model
|
||||
* @return true if model is changed
|
||||
*/
|
||||
public boolean elementReleased(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
public void elementReleased(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
if (interactor != null)
|
||||
return interactor.released(cc, pos, ioState, element, modelSync);
|
||||
else
|
||||
return false;
|
||||
interactor.released(cc, pos, ioState, element, modelSync);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,13 +386,10 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
* @param pos the position
|
||||
* @param posInComponent position in CircuitComponent
|
||||
* @param modelSync used to access the running model
|
||||
* @return true if model is changed
|
||||
*/
|
||||
public boolean elementDragged(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
public void elementDragged(CircuitComponent cc, Point pos, Vector posInComponent, SyncAccess modelSync) {
|
||||
if (interactor != null)
|
||||
return interactor.dragged(cc, pos, posInComponent, getTransform(), ioState, element, modelSync);
|
||||
else
|
||||
return false;
|
||||
interactor.dragged(cc, pos, posInComponent, getTransform(), ioState, element, modelSync);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -43,7 +42,7 @@ public class AsyncClockShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -50,7 +49,7 @@ public class BitSelShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -51,7 +50,7 @@ public class BreakShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.BitsException;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -56,7 +55,7 @@ public class BusSplitterShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -56,10 +55,10 @@ public class ButtonLEDShape extends ButtonShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
inputValue = ioState.getInput(0);
|
||||
button = (ButtonLED) ioState.getElement();
|
||||
return super.applyStateMonitor(ioState, guiObserver);
|
||||
return super.applyStateMonitor(ioState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
@ -51,30 +50,25 @@ public class ButtonShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
this.button = (Button) ioState.getElement();
|
||||
ioState.getOutput(0).addObserverToValue(guiObserver);
|
||||
return new InteractorInterface() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
modelSync.modify(() -> button.setPressed(true));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
modelSync.modify(() -> button.setPressed(false));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform trans, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform trans, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
@ -56,17 +55,13 @@ public class ClockShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
ioState.getOutput(0).addObserverToValue(guiObserver); // necessary to replot wires also if component itself does not depend on state
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return new Interactor() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
ObservableValue value = ioState.getOutput(0);
|
||||
if (value.getBits() == 1) {
|
||||
if (value.getBits() == 1)
|
||||
modelSync.modify(() -> value.setValue(1 - value.getValue()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -47,7 +46,7 @@ public class ConstShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
@ -66,7 +65,7 @@ public class DILShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Signal;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -54,7 +53,7 @@ public class DataShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pin;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
@ -39,7 +38,7 @@ public class DelayShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -63,7 +62,7 @@ public class DemuxerShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -50,7 +49,7 @@ public class DiodeBackwardShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -50,7 +49,7 @@ public class DiodeForewardShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -48,7 +47,7 @@ public class DiodeShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
@ -75,15 +74,13 @@ public class DipSwitchShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getOutput(0).addObserverToValue(guiObserver);
|
||||
return new Interactor() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
ObservableValue value = ioState.getOutput(0);
|
||||
modelSync.modify(() -> value.setValue(1 - value.getValue()));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -68,7 +67,7 @@ public class DriverShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.core.switching.NFET;
|
||||
@ -49,9 +48,8 @@ public abstract class FETShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
fet = (NFET) ioState.getElement();
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -63,7 +62,7 @@ public class FuseShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pin;
|
||||
@ -195,7 +194,7 @@ public class GenericShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -41,7 +40,7 @@ public class GroundShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,8 @@ public class InputShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getOutput(0).addObserverToValue(guiObserver);
|
||||
return new InputInteractor();
|
||||
}
|
||||
|
||||
@ -148,7 +147,7 @@ public class InputShape implements Shape {
|
||||
private long lastValueSet;
|
||||
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
ObservableValue value = ioState.getOutput(0);
|
||||
if (bits == 1) {
|
||||
modelSync.modify(() -> {
|
||||
@ -163,7 +162,6 @@ public class InputShape implements Shape {
|
||||
} else
|
||||
value.setValue(1 - value.getValue());
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
if (dialog == null || !dialog.isVisible()) {
|
||||
Model model = ((In) element).getModel();
|
||||
@ -172,18 +170,16 @@ public class InputShape implements Shape {
|
||||
} else
|
||||
dialog.requestFocus();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
isDrag = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
ObservableValue value = ioState.getOutput(0);
|
||||
if (bits > 1 && !value.isHighZ()) {
|
||||
if (!isDrag) {
|
||||
@ -198,11 +194,9 @@ public class InputShape implements Shape {
|
||||
if (val != lastValueSet) {
|
||||
modelSync.modify(() -> value.setValue(val));
|
||||
lastValueSet = val;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,17 +23,14 @@ import java.awt.*;
|
||||
public abstract class Interactor implements InteractorInterface {
|
||||
|
||||
@Override
|
||||
public boolean pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,8 @@ public interface InteractorInterface {
|
||||
* @param ioState the state of the element
|
||||
* @param element the element which is clicked
|
||||
* @param modelSync used to sync model access
|
||||
* @return true if model is changed
|
||||
*/
|
||||
boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
|
||||
/**
|
||||
* Called if mouse is pressed on running model
|
||||
@ -42,9 +41,8 @@ public interface InteractorInterface {
|
||||
* @param ioState the state of the element
|
||||
* @param element the element on which the mouse is pressed
|
||||
* @param modelSync used to sync model access
|
||||
* @return true if model is changed
|
||||
*/
|
||||
boolean pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
void pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
|
||||
/**
|
||||
* Called if mouse is released on running model
|
||||
@ -54,9 +52,8 @@ public interface InteractorInterface {
|
||||
* @param ioState the state of the element
|
||||
* @param element the element on which the mouse is released
|
||||
* @param modelSync used to sync model access
|
||||
* @return true if model is changed
|
||||
*/
|
||||
boolean released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
void released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync);
|
||||
|
||||
/**
|
||||
* Called if mouse is dragged on running model
|
||||
@ -68,8 +65,7 @@ public interface InteractorInterface {
|
||||
* @param ioState the state of the element
|
||||
* @param element the element on which the mouse is dragged
|
||||
* @param modelSync used to sync model access
|
||||
* @return true if model is changed
|
||||
*/
|
||||
boolean dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync);
|
||||
void dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform transform, IOState ioState, Element element, SyncAccess modelSync);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -53,9 +52,8 @@ public class LEDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
@ -131,7 +130,7 @@ public class LayoutShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -54,9 +53,9 @@ public class LightBulbShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
aValue = ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
bValue = ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
aValue = ioState.getInput(0);
|
||||
bValue = ioState.getInput(1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
import de.neemann.digital.draw.graphics.Graphic;
|
||||
@ -40,7 +39,7 @@ public class MissingShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -58,7 +57,7 @@ public class MuxerShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -70,9 +69,8 @@ public class OutputShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -48,7 +47,7 @@ public class PinControlShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -60,9 +59,9 @@ public class PolarityAwareLEDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
aValue = ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
cValue = ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
aValue = ioState.getInput(0);
|
||||
cValue = ioState.getInput(1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.IntFormat;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -52,9 +51,8 @@ public class ProbeShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
inValue = ioState.getInput(0);
|
||||
inValue.addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -52,7 +51,7 @@ public class PullDownShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -46,7 +45,7 @@ public class PullUpShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.*;
|
||||
import de.neemann.digital.core.memory.DataField;
|
||||
@ -66,17 +65,16 @@ public class RAMShape extends GenericShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return new Interactor() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
if (element instanceof RAMInterface) {
|
||||
RAMInterface ram = (RAMInterface) element;
|
||||
DataField dataField = ram.getMemory();
|
||||
DataEditor dataEditor = new DataEditor(cc, dataField, dataBits, addrBits, true, modelSync, ram.getIntFormat());
|
||||
dataEditor.showDialog(dialogTitle, model);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Bits;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -60,11 +59,8 @@ public class RGBLEDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
ioState.getInput(2).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -58,7 +57,7 @@ public class RectShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -63,10 +62,8 @@ public class RelayDTShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
relay = (RelayDT) ioState.getElement();
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -65,10 +64,8 @@ public class RelayShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
relay = (Relay) ioState.getElement();
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -45,7 +44,7 @@ public class ResetShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
//ioState.getOutput(0).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
@ -54,31 +53,27 @@ public class RotEncoderShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
ioState.getOutput(0).addObserverToValue(guiObserver);
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return new InteractorInterface() {
|
||||
|
||||
private int initialState;
|
||||
private boolean initial;
|
||||
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void pressed(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
initial = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
return false;
|
||||
public void released(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform trans, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void dragged(CircuitComponent cc, Point posOnScreen, Vector pos, Transform trans, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
if (ioState != null) {
|
||||
Vector p = pos.sub(trans.transform(CENTER));
|
||||
final int dist = p.x * p.x + p.y * p.y;
|
||||
@ -97,13 +92,11 @@ public class RotEncoderShape implements Shape {
|
||||
ioState.getOutput(0).setBool(a);
|
||||
ioState.getOutput(1).setBool(b);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
initial = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -72,10 +71,8 @@ public class SevenSegHexShape extends SevenShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
this.ioState = ioState;
|
||||
ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,7 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.ObservableValues;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -72,10 +70,8 @@ public class SevenSegShape extends SevenShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
inputValues = ioState.getInputs();
|
||||
for (ObservableValue o : inputValues)
|
||||
o.addObserverToValue(guiObserver);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
import de.neemann.digital.draw.model.ModelCreator;
|
||||
@ -29,20 +28,15 @@ public interface Shape extends Drawable, ObservableValueReader {
|
||||
|
||||
/**
|
||||
* This method call connects the created model element to the shape which represents the model node.
|
||||
* If the look of the shape depends on an inputs state, the shape has to register the guiObserver
|
||||
* to all of the inputs ObservableValues it depends on.
|
||||
* To access the actual state while drawing, the Shape needs to store the IOState or the needed inputs
|
||||
* in a member variable.
|
||||
* If the shape returns an interactor, this interactors clicked method is called if the
|
||||
* shape is clicked in running mode. If the shape is not interactive simply return null.
|
||||
*
|
||||
* @param ioState the state of the element, never null
|
||||
* @param guiObserver can be used to update the GUI by calling hasChanged, Is maybe null.
|
||||
* If the shape depends on a signal value, you can add this observer to
|
||||
* the signal. In this case a repaint is initiated, if the signal changes.
|
||||
* @param ioState the state of the element, never null
|
||||
* @return The interactor which is used to interact with the shape while the simulation runs.
|
||||
*/
|
||||
InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver);
|
||||
InteractorInterface applyStateMonitor(IOState ioState);
|
||||
|
||||
/**
|
||||
* Allows the shape to make its drawing dependent of the model by registering a Observer to the model.
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -80,9 +79,9 @@ public class SixteenShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
input = ioState.getInput(0).addObserverToValue(guiObserver);
|
||||
dp = ioState.getInput(1).addObserverToValue(guiObserver);
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
input = ioState.getInput(0);
|
||||
dp = ioState.getInput(1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.BitsException;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -56,7 +55,7 @@ public class SplitterShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.core.io.StepperMotorUnipolar;
|
||||
@ -57,9 +56,7 @@ public class StepperMotorShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
ioState.getInput(i).addObserver(guiObserver);
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
motor = (StepperMotorUnipolar) ioState.getElement();
|
||||
return null;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
@ -64,15 +63,13 @@ public class SwitchDTShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return new Interactor() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
closed = !closed;
|
||||
if (ioState != null) {
|
||||
if (ioState != null)
|
||||
modelSync.modify(() -> ((SwitchDT) element).setClosed(closed));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
@ -63,15 +62,13 @@ public class SwitchShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return new Interactor() {
|
||||
@Override
|
||||
public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
public void clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, SyncAccess modelSync) {
|
||||
closed = !closed;
|
||||
if (ioState != null) {
|
||||
if (ioState != null)
|
||||
modelSync.modify(() -> ((Switch) element).setClosed(closed));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -43,7 +42,7 @@ public class TestCaseShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -57,7 +56,7 @@ public class TextShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.core.switching.TransGate;
|
||||
@ -65,7 +64,7 @@ public class TransGateShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
transGate = (TransGate) ioState.getElement();
|
||||
return null;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
@ -46,7 +45,7 @@ public class TunnelShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -43,7 +42,7 @@ public class VDDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes.custom;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
@ -61,7 +60,7 @@ public class CustomShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes.ieee;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -57,7 +56,7 @@ public abstract class IEEEGenericShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public InteractorInterface applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes.ieee;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -58,7 +57,7 @@ public class IEEENotShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
public Interactor applyStateMonitor(IOState ioState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class SevenSegShapeTest extends TestCase {
|
||||
PinDescriptions inputs = new PinDescriptions(observableValues);
|
||||
SevenSegShape ss = new SevenSegShape(attr, inputs, new PinDescriptions());
|
||||
IOState state = new IOState(observableValues, null, null);
|
||||
ss.applyStateMonitor(state, null);
|
||||
ss.applyStateMonitor(state);
|
||||
|
||||
checkValue(false, ss, 0, a, 0, 1, cc, 0, 1);
|
||||
checkValue(false, ss, 0, a, 0, 1, cc, 1, 1);
|
||||
@ -95,7 +95,7 @@ public class SevenSegShapeTest extends TestCase {
|
||||
PinDescriptions inputs = new PinDescriptions(observableValues);
|
||||
SevenSegShape ss = new SevenSegShape(attr, inputs, new PinDescriptions());
|
||||
IOState state = new IOState(observableValues, null, null);
|
||||
ss.applyStateMonitor(state, null);
|
||||
ss.applyStateMonitor(state);
|
||||
|
||||
checkValue(false, ss, 0, a, 0, 1, cc, 0, 1);
|
||||
checkValue(false, ss, 0, a, 0, 1, cc, 1, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user