OpenPreviewOfEveryComponent now no longer simulates components
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 15 Oct 2020 14:44:20 +0000 (16:44 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 15 Oct 2020 14:44:20 +0000 (16:44 +0200)
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/OpenPreviewOfEveryComponent.java

index 7c47a3e..5a9690a 100644 (file)
@@ -8,10 +8,14 @@ import java.util.List;
 
 import com.google.gson.JsonObject;
 
-import net.mograsim.logic.model.SimpleLogicUIStandalone;
+import net.mograsim.logic.model.LogicUIStandaloneGUI;
 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.model.components.atomic.ModelTextComponent;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
+import net.mograsim.logic.model.preferences.DefaultRenderPreferences;
 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
 import net.mograsim.logic.model.util.JsonHandler;
 
@@ -35,22 +39,25 @@ public class OpenPreviewOfEveryComponent
 
                Collections.sort(allComponents, String::compareToIgnoreCase);
 
-               SimpleLogicUIStandalone.executeVisualisation(model ->
-               {
-                       int y = 0;
-                       for (String componentID : allComponents)
-                               try
-                               {
-                                       ModelComponent createComponent = IndirectModelComponentCreator.createComponent(model, componentID);
-                                       createComponent.moveTo(0, y);
-                                       new ModelTextComponent(model, componentID).moveTo(createComponent.getWidth() + 10, y);
-                                       y += createComponent.getHeight() + 10;
-                               }
-                               catch (RuntimeException e)
-                               {
-                                       new ModelTextComponent(model, "Error creating " + componentID + ": " + e).moveTo(0, y);
-                                       y += 20;
-                               }
-               });
+               LogicModelModifiable model = new LogicModelModifiable();
+               int y = 0;
+               for (String componentID : allComponents)
+                       try
+                       {
+                               ModelComponent createComponent = IndirectModelComponentCreator.createComponent(model, componentID);
+                               createComponent.moveTo(0, y);
+                               new ModelTextComponent(model, componentID).moveTo(createComponent.getWidth() + 10, y);
+                               y += createComponent.getHeight() + 10;
+                       }
+                       catch (RuntimeException e)
+                       {
+                               new ModelTextComponent(model, "Error creating " + componentID + ": " + e).moveTo(0, y);
+                               y += 20;
+                       }
+
+               // give the wires color
+               LogicCoreAdapter.convert(model, CoreModelParameters.builder().build());
+
+               new LogicUIStandaloneGUI(model, new DefaultRenderPreferences()).run();
        }
 }