Renamed core components to have the common prefix Core
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / model / components / submodels / SubmodelComponent.java
index bcf85ae..f67be7d 100644 (file)
@@ -17,12 +17,13 @@ import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.MovablePin;
 import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.serializing.SubmodelComponentParams;
 import net.mograsim.logic.model.serializing.SubmodelComponentSerializer;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.util.JsonHandler;
+import net.mograsim.preferences.Preferences;
 
 /**
  * A {@link GUIComponent} consisting of another model. A <code>SubmodelComponent</code> can have so-called "interface pins" connecting the
@@ -365,7 +366,7 @@ public abstract class SubmodelComponent extends GUIComponent
        public void render(GeneralGC gc, Rectangle visibleRegion)
        {
                GCConfig conf = new GCConfig(gc);
-               TranslatedGC tgc = new TranslatedGC(gc, getPosX(), getPosY(), submodelScale, true);
+               GeneralGC tgc = new TranslatedGC(gc, getPosX(), getPosY(), submodelScale, true);
                conf.reset(tgc);
                double visibleRegionFillRatio = Math.max(getWidth() / visibleRegion.width, getHeight() / visibleRegion.height);
                double alphaFactor = map(visibleRegionFillRatio, maxVisibleRegionFillRatioForAlpha0, minVisibleRegionFillRatioForAlpha1, 0, 1);
@@ -385,6 +386,8 @@ public abstract class SubmodelComponent extends GUIComponent
                        renderSymbol(gc, visibleRegion);
                }
                conf.reset(gc);
+               // reset line width explicitly to avoid rounding errors causing weird glitches
+               gc.setLineWidth(Preferences.current().getDouble("net.mograsim.logic.model.linewidth.default"));
                // draw the outline after all other operations to make interface pins look better
                renderOutline(gc, visibleRegion);
        }
@@ -419,9 +422,15 @@ public abstract class SubmodelComponent extends GUIComponent
        // serializing
 
        @Override
-       public SubmodelComponentParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
        {
-               return SubmodelComponentSerializer.serialize(this, idGetter);
+               return "submodel";// TODO what ID?
+       }
+
+       @Override
+       public SubmodelComponentParams getParamsForSerializing(IdentifyParams idParams)
+       {
+               return SubmodelComponentSerializer.serialize(this, idParams);
        }
 
        // operations no longer supported