X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2FViewModel.java;h=b0d6a3cfcf1a050ba27df4950f7cdc9574a1c453;hb=93b398d6271a538a2a4c9f4de07a3b4a8a2a7fd4;hp=cf679cd1042cab9989438c8358ff8d6866443223;hpb=0a04a4ed66ecebd4254541c4977599f6052c115a;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/ViewModel.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/ViewModel.java index cf679cd1..b0d6a3cf 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/ViewModel.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/ViewModel.java @@ -7,22 +7,22 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import net.mograsim.logic.model.model.components.GUIComponent; -import net.mograsim.logic.model.model.wires.GUIWire; +import net.mograsim.logic.model.model.components.ModelComponent; +import net.mograsim.logic.model.model.wires.ModelWire; public class ViewModel { - private final Map components; + private final Map components; private final Map componentDestroyFunctions; - private final Map componentsUnmodifiable; - private final Map wires; + private final Map componentsUnmodifiable; + private final Map wires; private final Map wireDestroyFunctions; - private final Map wiresUnmodifiable; + private final Map wiresUnmodifiable; - private final List> componentAddedListeners; - private final List> componentRemovedListeners; - private final List> wireAddedListeners; - private final List> wireRemovedListeners; + private final List> componentAddedListeners; + private final List> componentRemovedListeners; + private final List> wireAddedListeners; + private final List> wireRemovedListeners; private final List> redrawHandlerChangedListeners; private Runnable redrawHandler; @@ -45,11 +45,11 @@ public class ViewModel /** * Adds the given component to the list of components and calls all componentAddedListeners. Don't call this method from application - * code as it is automatically called in {@link GUIComponent}'s constructor. + * code as it is automatically called in {@link ModelComponent}'s constructor. * * @author Daniel Kirschten */ - protected void componentCreated(GUIComponent component, Runnable destroyed) + protected void componentCreated(ModelComponent component, Runnable destroyed) { if (components.containsKey(component.name)) throw new IllegalStateException("Don't add the same component twice!"); @@ -64,7 +64,7 @@ public class ViewModel * * @author Daniel Kirschten */ - protected void destroyComponent(GUIComponent component) + protected void destroyComponent(ModelComponent component) { componentDestroyFunctions.get(component.name).run(); if (!components.containsKey(component.name)) @@ -79,7 +79,7 @@ public class ViewModel * * @author Daniel Kirschten */ - protected void wireCreated(GUIWire wire, Runnable destroyed) + protected void wireCreated(ModelWire wire, Runnable destroyed) { if (wires.containsKey(wire.name)) throw new IllegalStateException("Don't add the same wire twice!"); @@ -94,7 +94,7 @@ public class ViewModel * * @author Daniel Kirschten */ - protected void destroyWire(GUIWire wire) + protected void destroyWire(ModelWire wire) { wireDestroyFunctions.get(wire.name).run(); if (!wires.containsKey(wire.name)) @@ -104,33 +104,33 @@ public class ViewModel requestRedraw(); } - public Map getComponentsByName() + public Map getComponentsByName() { return componentsUnmodifiable; } - public Map getWiresByName() + public Map getWiresByName() { return wiresUnmodifiable; } // @formatter:off - public void addComponentAddedListener (Consumer listener) {componentAddedListeners .add (listener);} - public void addComponentRemovedListener (Consumer listener) {componentRemovedListeners .add (listener);} - public void addWireAddedListener (Consumer listener) {wireAddedListeners .add (listener);} - public void addWireRemovedListener (Consumer listener) {wireRemovedListeners .add (listener);} + public void addComponentAddedListener (Consumer listener) {componentAddedListeners .add (listener);} + public void addComponentRemovedListener (Consumer listener) {componentRemovedListeners .add (listener);} + public void addWireAddedListener (Consumer listener) {wireAddedListeners .add (listener);} + public void addWireRemovedListener (Consumer listener) {wireRemovedListeners .add (listener);} public void addRedrawHandlerChangedListener (Consumer listener) {redrawHandlerChangedListeners.add (listener);} - public void removeComponentAddedListener (Consumer listener) {componentAddedListeners .remove(listener);} - public void removeComponentRemovedListener (Consumer listener) {componentRemovedListeners .remove(listener);} - public void removeWireAddedListener (Consumer listener) {wireAddedListeners .remove(listener);} - public void removeWireRemovedListener (Consumer listener) {wireRemovedListeners .remove(listener);} + public void removeComponentAddedListener (Consumer listener) {componentAddedListeners .remove(listener);} + public void removeComponentRemovedListener (Consumer listener) {componentRemovedListeners .remove(listener);} + public void removeWireAddedListener (Consumer listener) {wireAddedListeners .remove(listener);} + public void removeWireRemovedListener (Consumer listener) {wireRemovedListeners .remove(listener);} public void removeRedrawHandlerChangedListener(Consumer listener) {redrawHandlerChangedListeners.remove(listener);} - private void callComponentAddedListeners (GUIComponent c) {componentAddedListeners .forEach(l -> l.accept(c));} - private void callComponentRemovedListeners (GUIComponent c) {componentRemovedListeners .forEach(l -> l.accept(c));} - private void callWireAddedListeners (GUIWire w) {wireAddedListeners .forEach(l -> l.accept(w));} - private void callWireRemovedListeners (GUIWire w) {wireRemovedListeners .forEach(l -> l.accept(w));} + private void callComponentAddedListeners (ModelComponent c) {componentAddedListeners .forEach(l -> l.accept(c));} + private void callComponentRemovedListeners (ModelComponent c) {componentRemovedListeners .forEach(l -> l.accept(c));} + private void callWireAddedListeners (ModelWire w) {wireAddedListeners .forEach(l -> l.accept(w));} + private void callWireRemovedListeners (ModelWire w) {wireRemovedListeners .forEach(l -> l.accept(w));} private void callRedrawHandlerChangedListener(Runnable r) {redrawHandlerChangedListeners.forEach(l -> l.accept(r));} // @formatter:on