X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FWireCrossPoint.java;h=ea79cc72d7cc3e1be52bc6e3287be8bfac8d8aba;hb=5897a6d81c418d27ca5bb402e5f1038e10a191fb;hp=de5ba4ac5026bb1eeedfec536434acbd5ddf64da;hpb=67c7e16eac6ef555f7ebe0cbe6048598d7f1187e;p=Mograsim.git
diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java
index de5ba4ac..ea79cc72 100644
--- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java
+++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java
@@ -1,16 +1,15 @@
package net.mograsim.logic.ui.model.wires;
-import java.util.Map;
-
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.
@@ -21,7 +20,7 @@ import net.mograsim.logic.ui.model.components.SimpleRectangularGUIGate;
*
* @author Daniel Kirschten
*/
-public class WireCrossPoint extends GUIComponent
+public class WireCrossPoint extends GUIComponent implements ConnectionPoint
{
private static final int CIRCLE_RADIUS = 1;
private static final int CIRCLE_DIAM = CIRCLE_RADIUS * 2;
@@ -53,6 +52,7 @@ public class WireCrossPoint extends GUIComponent
// pins
+ @Override
public Pin getPin()
{
return pin;
@@ -73,8 +73,10 @@ public class WireCrossPoint extends GUIComponent
@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
@@ -103,13 +105,9 @@ public class WireCrossPoint extends GUIComponent
return end != null;
}
- // serializing
-
- @Override
- public Map getInstantiationParameters()
+ static
{
- Map m = super.getInstantiationParameters();
- m.put(SimpleRectangularGUIGate.kLogicWidth, pin.logicWidth);
- return m;
+ // TODO read params
+ IndirectGUIComponentCreator.setComponentProvider(WireCrossPoint.class.getCanonicalName(), (m, p) -> new WireCrossPoint(m, 1));
}
}
\ No newline at end of file