Improved usage of CoreModelParametersBuilder
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 15 Oct 2020 14:43:52 +0000 (16:43 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 15 Oct 2020 14:43:52 +0000 (16:43 +0200)
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/CountGatesPerComponent.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/SimpleLogicUIStandalone.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/CoreModelParameters.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/util/TestEnvironmentHelper.java

index 3d3d6c3..70f6a73 100644 (file)
@@ -57,7 +57,7 @@ public class Am2900Machine implements Machine
                                "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json", "Am2900");
                this.amicListeners = new HashSet<>();
 
-               CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+               CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder();
                paramsBuilder.gateProcessTime = 50;
                paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
                paramsBuilder.wireTravelTime = 10;
index b9c7398..679f9d9 100755 (executable)
@@ -8,7 +8,7 @@ import java.util.Map.Entry;
 import net.mograsim.logic.model.am2900.Am2900Loader;
 import net.mograsim.logic.model.model.LogicModelModifiable;
 import net.mograsim.logic.model.model.components.ModelComponent;
-import net.mograsim.logic.model.modeladapter.CoreModelParameters.CoreModelParametersBuilder;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
 
@@ -29,7 +29,7 @@ public class CountGatesPerComponent
                IndirectModelComponentCreator.createComponent(model, componentID);
 
                LogicCoreAdapter.gateCountsPerComponentClass.clear();
-               LogicCoreAdapter.convert(model, new CoreModelParametersBuilder().build());
+               LogicCoreAdapter.convert(model, CoreModelParameters.builder().build());
 
                System.out.println(componentID + ':');
                for (Entry<Class<? extends ModelComponent>, Integer> e : LogicCoreAdapter.gateCountsPerComponentClass.entrySet())
index dab4584..20bfccc 100644 (file)
@@ -18,7 +18,7 @@ public class SimpleLogicUIStandalone
 
        public static void executeVisualisation(Consumer<LogicModelModifiable> setupLogicModel, Consumer<VisualisationObjects> beforeRun)
        {
-               CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+               CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder();
                paramsBuilder.gateProcessTime = 50;
                paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
                paramsBuilder.wireTravelTime = 10;
index 6111e0b..181f6ef 100644 (file)
@@ -20,12 +20,21 @@ public class CoreModelParameters
                this.hardcodedComponentProcessTime = builder.hardcodedComponentProcessTime;
        }
 
+       public static CoreModelParametersBuilder builder()
+       {
+               return new CoreModelParametersBuilder();
+       }
+
        public static class CoreModelParametersBuilder
        {
                public int wireTravelTime;
                public int gateProcessTime;
                public int hardcodedComponentProcessTime;
 
+               private CoreModelParametersBuilder()
+               {
+               }
+
                public CoreModelParametersBuilder wireTravelTime(int wireTravelTime)
                {
                        this.wireTravelTime = wireTravelTime;
index 45d5540..7b131d5 100644 (file)
@@ -35,7 +35,7 @@ public class SimulationPreview implements IThemePreview
 
                LogicModelModifiable model = new LogicModelModifiable();
 
-               CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+               CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder();
                paramsBuilder.gateProcessTime = 50;
                paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
                paramsBuilder.wireTravelTime = 10;
index 5adf93d..aeb1bec 100644 (file)
@@ -27,6 +27,7 @@ import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
 import net.mograsim.logic.model.model.wires.ModelWire;
 import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
 import net.mograsim.logic.model.modeladapter.CoreModelParameters.CoreModelParametersBuilder;
 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
 import net.mograsim.logic.model.preferences.DefaultRenderPreferences;
@@ -89,7 +90,7 @@ public class TestEnvironmentHelper
                component.getPins().values().forEach(this::extendModelPin);
 
                // Create core model
-               CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+               CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder();
                paramsBuilder.gateProcessTime = 50;
                paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
                paramsBuilder.wireTravelTime = 10;