1 package net.mograsim.logic.model.examples;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.ArrayList;
6 import java.util.Collections;
9 import com.google.gson.JsonObject;
11 import net.mograsim.logic.model.SimpleLogicUIStandalone;
12 import net.mograsim.logic.model.am2900.Am2900Loader;
13 import net.mograsim.logic.model.model.components.ModelComponent;
14 import net.mograsim.logic.model.model.components.atomic.ModelTextComponent;
15 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
16 import net.mograsim.logic.model.util.JsonHandler;
18 public class OpenPreviewOfEveryComponent
20 public static void main(String[] args) throws IOException
24 List<String> allComponents = new ArrayList<>();
26 // TODO this is ugly. Is there a better way?
27 try (InputStream resourceAsStream = Am2900Loader.class.getResourceAsStream("standardComponentIDMapping.json"))
29 allComponents.addAll(JsonHandler.readJson(resourceAsStream, JsonObject.class).keySet());
31 try (InputStream resourceAsStream = IndirectModelComponentCreator.class.getResourceAsStream("standardComponentIDMapping.json"))
33 allComponents.addAll(JsonHandler.readJson(resourceAsStream, JsonObject.class).keySet());
36 Collections.sort(allComponents, String::compareToIgnoreCase);
38 SimpleLogicUIStandalone.executeVisualisation(model ->
41 for (String componentID : allComponents)
44 ModelComponent createComponent = IndirectModelComponentCreator.createComponent(model, componentID);
45 createComponent.moveTo(0, y);
46 new ModelTextComponent(model, componentID).moveTo(createComponent.getWidth() + 10, y);
47 y += createComponent.getHeight() + 10;
49 catch (RuntimeException e)
51 new ModelTextComponent(model, "Error creating " + componentID + ": " + e).moveTo(0, y);