package net.mograsim.logic.ui.model.wires;
-import java.util.Map;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
import net.haspamelodica.swt.helper.gcs.GeneralGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.types.BitVectorFormatter;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
-import net.mograsim.logic.ui.ColorHelper;
import net.mograsim.logic.ui.model.ViewModelModifiable;
import net.mograsim.logic.ui.model.components.GUIComponent;
-import net.mograsim.logic.ui.model.components.SimpleRectangularGUIGate;
+import net.mograsim.logic.ui.serializing.IndirectGUIComponentCreator;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorManager;
/**
* A {@link GUIComponent} with only one pin. Is used to create wires connecting more than two pins. <br>
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
- ColorHelper.executeWithDifferentBackground(gc, BitVectorFormatter.formatAsColor(end),
- () -> gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM));
+ ColorDefinition wireColor = BitVectorFormatter.formatAsColor(end);
+ if (wireColor != null)
+ gc.setBackground(ColorManager.current().toColor(wireColor));
+ gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM);
}
// logic model binding
// serializing
@Override
- public Map<String, Object> getInstantiationParameters()
+ public JsonElement getParams()
{
- Map<String, Object> m = super.getInstantiationParameters();
- m.put(SimpleRectangularGUIGate.kLogicWidth, pin.logicWidth);
- return m;
+ return new JsonPrimitive(pin.logicWidth);
+ }
+
+ static
+ {
+ IndirectGUIComponentCreator.setComponentSupplier(WireCrossPoint.class.getCanonicalName(),
+ (m, p) -> new WireCrossPoint(m, p.getAsInt()));
}
}
\ No newline at end of file