X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodeladapter%2FViewLogicModelAdapter.java;h=8c337cd25d57dd5596d26641e20b7b06da6bf62a;hb=0a04a4ed66ecebd4254541c4977599f6052c115a;hp=6e722a0cd8a7d7da6d8a639ca089059817dec755;hpb=9b4850366c29fbd800ee8df1858c398d8c35a0c0;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java index 6e722a0c..8c337cd2 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/ViewLogicModelAdapter.java @@ -11,8 +11,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import net.mograsim.logic.core.timeline.Timeline; -import net.mograsim.logic.core.wires.Wire; -import net.mograsim.logic.core.wires.Wire.ReadEnd; +import net.mograsim.logic.core.wires.CoreWire; +import net.mograsim.logic.core.wires.CoreWire.ReadEnd; import net.mograsim.logic.model.model.ViewModel; import net.mograsim.logic.model.model.components.GUIComponent; import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; @@ -41,11 +41,11 @@ public class ViewLogicModelAdapter return timeline; } - private static void convert(ViewModel viewModel, LogicModelParameters params, Timeline timeline, Map externalWires) + private static void convert(ViewModel viewModel, LogicModelParameters params, Timeline timeline, Map externalWires) { - Map logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWiresByName().values(), externalWires, params, + Map logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWiresByName().values(), externalWires, params, timeline); - Map logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin); + Map logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin); for (GUIComponent guiComp : viewModel.getComponentsByName().values()) { @@ -53,7 +53,7 @@ public class ViewLogicModelAdapter { SubmodelComponent guiCompCasted = (SubmodelComponent) guiComp; Map supermodelPins = guiCompCasted.getSupermodelPins(); - Map externalWiresForSubmodel = supermodelPins.entrySet().stream() + Map externalWiresForSubmodel = supermodelPins.entrySet().stream() .collect(Collectors.toMap(e -> guiCompCasted.getSubmodelPin(e.getKey()), e -> logicWiresPerPin.get(e.getValue()))); convert(guiCompCasted.submodel, params, timeline, externalWiresForSubmodel); } else if (guiComp instanceof WireCrossPoint) @@ -71,45 +71,45 @@ public class ViewLogicModelAdapter .collect(Collectors.toSet()); } - private static Map convertWires(Set allPins, Collection wires, Map externalWires, + private static Map convertWires(Set allPins, Collection wires, Map externalWires, LogicModelParameters params, Timeline timeline) { Map> connectedPinGroups = getConnectedPinGroups(allPins, wires); - Map logicWiresPerPin = createLogicWires(params, timeline, connectedPinGroups, externalWires); + Map logicWiresPerPin = createLogicWires(params, timeline, connectedPinGroups, externalWires); setGUIWiresLogicModelBinding(wires, logicWiresPerPin); return logicWiresPerPin; } - private static Map createLogicWires(LogicModelParameters params, Timeline timeline, Map> connectedPinGroups, - Map externalWires) + private static Map createLogicWires(LogicModelParameters params, Timeline timeline, Map> connectedPinGroups, + Map externalWires) { - Map logicWiresPerPin = new HashMap<>(); - Map, Wire> logicWiresPerPinGroup = new HashMap<>(); + Map logicWiresPerPin = new HashMap<>(); + Map, CoreWire> logicWiresPerPinGroup = new HashMap<>(); for (Entry> e : connectedPinGroups.entrySet()) logicWiresPerPin.put(e.getKey(), logicWiresPerPinGroup.computeIfAbsent(e.getValue(), set -> { - Wire externalWire = null; + CoreWire externalWire = null; for (Pin p : set) { - Wire externalWireCandidate = externalWires.get(p); + CoreWire externalWireCandidate = externalWires.get(p); if (externalWireCandidate != null) if (externalWire == null) externalWire = externalWireCandidate; else if (externalWire.width == externalWireCandidate.width) - Wire.fuse(externalWire, externalWireCandidate); + CoreWire.fuse(externalWire, externalWireCandidate); else throw new IllegalArgumentException( "Two pins to external wires with different logicWidths can't be connected directly"); } - return externalWire == null ? new Wire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire; + return externalWire == null ? new CoreWire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire; })); return logicWiresPerPin; } - private static void setGUIWiresLogicModelBinding(Collection wires, Map logicWiresPerPin) + private static void setGUIWiresLogicModelBinding(Collection wires, Map logicWiresPerPin) { - Map guiWireSharedReadEnd = logicWiresPerPin.values().stream().distinct() - .collect(Collectors.toMap(Function.identity(), Wire::createReadOnlyEnd)); + Map guiWireSharedReadEnd = logicWiresPerPin.values().stream().distinct() + .collect(Collectors.toMap(Function.identity(), CoreWire::createReadOnlyEnd)); for (GUIWire guiWire : wires) guiWire.setLogicModelBinding(guiWireSharedReadEnd.get(logicWiresPerPin.get(guiWire.getPin1()))); } @@ -144,7 +144,7 @@ public class ViewLogicModelAdapter @SuppressWarnings("unchecked") private static void createAndLinkComponent(Timeline timeline, LogicModelParameters params, - GUIComponent guiComponent, Map logicWiresPerPin) + GUIComponent guiComponent, Map logicWiresPerPin) { Class cls = guiComponent.getClass(); ComponentAdapter adapter = null;