Fixed WireCrossPoints disappearing near edges
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 6 Jun 2019 19:50:26 +0000 (21:50 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 6 Jun 2019 19:53:03 +0000 (21:53 +0200)
15 files changed:
net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/RSLatchExample.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIand.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIand41.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdemux2.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch4.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIhalfadder.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUImux1.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUImux1_4.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUInand3.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUInot4.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIor_4.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/WireCrossPoint.java

index 8c0c4ac..084db68 100644 (file)
@@ -41,21 +41,21 @@ public class RSLatchExample
                new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
 
                WireCrossPoint p1 = new WireCrossPoint(model, 1);
-               p1.moveTo(250, 112.5);
+               p1.moveCenterTo(250, 112.5);
                new GUIWire(model, not1.getOutputPin(), p1);
                new GUIWire(model, p1, or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
 
                WireCrossPoint p2 = new WireCrossPoint(model, 1);
-               p2.moveTo(250, 202.5);
+               p2.moveCenterTo(250, 202.5);
                new GUIWire(model, not2.getOutputPin(), p2);
                new GUIWire(model, p2, or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
 
                WireCrossPoint o1 = new WireCrossPoint(model, 1);
-               o1.moveTo(270, 112.5);
+               o1.moveCenterTo(270, 112.5);
                new GUIWire(model, p1, o1);
 
                WireCrossPoint o2 = new WireCrossPoint(model, 1);
-               o2.moveTo(270, 202.5);
+               o2.moveCenterTo(270, 202.5);
                new GUIWire(model, p2, o2);
        }
 }
\ No newline at end of file
index 79315c9..ce56eb8 100644 (file)
@@ -35,8 +35,8 @@ public class GUI_rsLatch extends SimpleRectangularSubmodelComponent
 
                nand1.moveTo(10, 7.5);
                nand2.moveTo(40, 12.5);
-               cp1.moveTo(35, 17.5);
-               cp2.moveTo(65, 37.5);
+               cp1.moveCenterTo(35, 17.5);
+               cp2.moveCenterTo(65, 37.5);
 
                new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0), new Point[0]);
                new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1), new Point(35, 37.5), new Point(35, 27.5));
index 35c47b0..d41228b 100644 (file)
@@ -33,7 +33,7 @@ public class GUIand extends SimpleRectangularSubmodelComponent
 
                nand.moveTo(20, 15);
                not.moveTo(50, 15);
-               cp1.moveTo(45, 25);
+               cp1.moveCenterTo(45, 25);
 
                new GUIWire(submodelModifiable, A, nand.getInputPins().get(0));
                new GUIWire(submodelModifiable, B, nand.getInputPins().get(1));
index 66fbbef..7ec4b49 100644 (file)
@@ -44,9 +44,9 @@ public class GUIand41 extends SimpleRectangularSubmodelComponent
                and2.moveTo(30, 32.5);
                and3.moveTo(30, 57.5);
                and4.moveTo(30, 82.5);
-               cpB2.moveTo(25, 47.5);
-               cpB3.moveTo(25, 72.5);
-               cpB4.moveTo(25, 97.5);
+               cpB2.moveCenterTo(25, 47.5);
+               cpB3.moveCenterTo(25, 72.5);
+               cpB4.moveCenterTo(25, 97.5);
 
                new GUIWire(submodelModifiable, A1, and1.getInputPins().get(0), new Point[0]);
                new GUIWire(submodelModifiable, A2, and2.getInputPins().get(0), new Point[0]);
index 2924c1a..e7d7e21 100644 (file)
@@ -51,14 +51,14 @@ public class GUIdemux2 extends SimpleRectangularSubmodelComponent
                andY01.moveTo(40, 27.5);
                andY10.moveTo(40, 52.5);
                andY11.moveTo(40, 77.5);
-               cpS01.moveTo(7.5, 12.5);
-               cpS11.moveTo(5, 37.5);
-               cpS02.moveTo(7.5, 17.5);
-               cpS12.moveTo(5, 42.5);
-               cpS03.moveTo(37.5, 62.5);
-               cpS13.moveTo(32.5, 67.5);
-               cpNotS0.moveTo(32.5, 12.5);
-               cpNotS1.moveTo(35, 37.5);
+               cpS01.moveCenterTo(7.5, 12.5);
+               cpS11.moveCenterTo(5, 37.5);
+               cpS02.moveCenterTo(7.5, 17.5);
+               cpS12.moveCenterTo(5, 42.5);
+               cpS03.moveCenterTo(37.5, 62.5);
+               cpS13.moveCenterTo(32.5, 67.5);
+               cpNotS0.moveCenterTo(32.5, 12.5);
+               cpNotS1.moveCenterTo(35, 37.5);
 
                new GUIWire(submodelModifiable, S0, cpS01, new Point[0]);
                new GUIWire(submodelModifiable, S1, cpS11, new Point[0]);
index ce4f441..1464b3a 100644 (file)
@@ -41,10 +41,10 @@ public class GUIdff extends SimpleRectangularSubmodelComponent
                nand3.moveTo(40, 40);
                nand2.moveTo(120, 60);
                _rsLatch2.moveTo(120, 30);
-               cp1.moveTo(10, 25);
-               cp2.moveTo(20, 65);
-               cp3.moveTo(100, 35);
-               cp4.moveTo(100, 45);
+               cp1.moveCenterTo(10, 25);
+               cp2.moveCenterTo(20, 65);
+               cp3.moveCenterTo(100, 35);
+               cp4.moveCenterTo(100, 45);
 
                new GUIWire(submodelModifiable, C, cp1, new Point[0]);
                new GUIWire(submodelModifiable, cp1, _rsLatch1.getInputPins().get(1), new Point[0]);
index 3dfb3e8..5fae335 100644 (file)
@@ -37,8 +37,8 @@ public class GUIdlatch extends SimpleRectangularSubmodelComponent
                nand1.moveTo(10, 2.5);
                nand2.moveTo(15, 27.5);
                _rsLatch.moveTo(45, 7.5);
-               cp1.moveTo(5, 37.5);
-               cp2.moveTo(35, 12.5);
+               cp1.moveCenterTo(5, 37.5);
+               cp2.moveCenterTo(35, 12.5);
 
                new GUIWire(submodelModifiable, D, nand1.getInputPins().get(0));
                new GUIWire(submodelModifiable, E, cp1, new Point[0]);
index 426fbf7..672b0ec 100644 (file)
@@ -44,9 +44,9 @@ public class GUIdlatch4 extends SimpleRectangularSubmodelComponent
                dlatch2.moveTo(30, 32.5);
                dlatch3.moveTo(30, 57.5);
                dlatch4.moveTo(30, 82.5);
-               cp2.moveTo(15, 47.5);
-               cp3.moveTo(15, 72.5);
-               cp4.moveTo(15, 97.5);
+               cp2.moveCenterTo(15, 47.5);
+               cp3.moveCenterTo(15, 72.5);
+               cp4.moveCenterTo(15, 97.5);
 
                new GUIWire(submodelModifiable, C, cp4, new Point(15, 112.5));
                new GUIWire(submodelModifiable, cp4, dlatch4.getInputPins().get(1), new Point[0]);
index d183e77..a75d162 100644 (file)
@@ -40,9 +40,9 @@ public class GUIhalfadder extends SimpleRectangularSubmodelComponent
                nandYA.moveTo(40, 2.5);
                nandYB.moveTo(40, 27.5);
                nandY.moveTo(65, 2.5);
-               cpA.moveTo(5, 12.5);
-               cpB.moveTo(5, 37.5);
-               cp_Z.moveTo(35, 25);
+               cpA.moveCenterTo(5, 12.5);
+               cpB.moveCenterTo(5, 37.5);
+               cp_Z.moveCenterTo(35, 25);
 
                new GUIWire(submodelModifiable, A, cpA, new Point[0]);
                new GUIWire(submodelModifiable, cpA, nandYA.getInputPins().get(0), new Point(5, 7.5));
index 19c410e..2c33f44 100644 (file)
@@ -39,8 +39,8 @@ public class GUImux1 extends SimpleRectangularSubmodelComponent
                nandI0.moveTo(35, 22.5);
                nandI1.moveTo(35, 47.5);
                nandY.moveTo(60, 30);
-               cp0.moveTo(5, 12.5);
-               cp1.moveTo(5, 22.5);
+               cp0.moveCenterTo(5, 12.5);
+               cp1.moveCenterTo(5, 22.5);
 
                new GUIWire(submodelModifiable, S0, cp0, new Point[0]);
                new GUIWire(submodelModifiable, cp0, nandS0.getInputPins().get(0), new Point[0]);
index 9d110aa..5ec7f88 100644 (file)
@@ -48,9 +48,9 @@ public class GUImux1_4 extends SimpleRectangularSubmodelComponent
                mux2.moveTo(30, 42.5);
                mux3.moveTo(30, 77.5);
                mux4.moveTo(30, 112.5);
-               cp1.moveTo(25, 12.5);
-               cp2.moveTo(25, 47.5);
-               cp3.moveTo(25, 82.5);
+               cp1.moveCenterTo(25, 12.5);
+               cp2.moveCenterTo(25, 47.5);
+               cp3.moveCenterTo(25, 82.5);
 
                new GUIWire(submodelModifiable, S0, cp1, new Point[0]);
                new GUIWire(submodelModifiable, cp1, mux1.getInputPins().get(0), new Point[0]);
index 0b0a3b5..73dbe28 100644 (file)
@@ -36,7 +36,7 @@ public class GUInand3 extends SimpleRectangularSubmodelComponent
                nandAB.moveTo(10, 15);
                andAB.moveTo(35, 15);
                nandABC.moveTo(62.5, 2.5);
-               cpNandAB.moveTo(32.5, 25);
+               cpNandAB.moveCenterTo(32.5, 25);
 
                new GUIWire(submodelModifiable, A, nandAB.getInputPins().get(0));
                new GUIWire(submodelModifiable, B, nandAB.getInputPins().get(1));
index 3d745fd..6bdeb05 100644 (file)
@@ -45,10 +45,10 @@ public class GUInot4 extends SimpleRectangularSubmodelComponent
                nand2.moveTo(30, 27.5);
                nand3.moveTo(30, 52.5);
                nand4.moveTo(30, 77.5);
-               cp1.moveTo(15, 12.5);
-               cp2.moveTo(15, 37.5);
-               cp3.moveTo(15, 62.5);
-               cp4.moveTo(15, 87.5);
+               cp1.moveCenterTo(15, 12.5);
+               cp2.moveCenterTo(15, 37.5);
+               cp3.moveCenterTo(15, 62.5);
+               cp4.moveCenterTo(15, 87.5);
 
                new GUIWire(submodelModifiable, A1, cp1, new Point[0]);
                new GUIWire(submodelModifiable, A2, cp2, new Point[0]);
index e29848a..95d8642 100644 (file)
@@ -69,14 +69,14 @@ public class GUIor_4 extends SimpleRectangularSubmodelComponent
                nandY2.moveTo(65, 27.5);
                nandY3.moveTo(65, 52.5);
                nandY4.moveTo(65, 77.5);
-               cpA1.moveTo(7.5, 12.5);
-               cpA2.moveTo(7.5, 37.5);
-               cpA3.moveTo(7.5, 62.5);
-               cpA4.moveTo(7.5, 87.5);
-               cpB1.moveTo(7.5, 112.5);
-               cpB2.moveTo(7.5, 137.5);
-               cpB3.moveTo(7.5, 162.5);
-               cpB4.moveTo(7.5, 187.5);
+               cpA1.moveCenterTo(7.5, 12.5);
+               cpA2.moveCenterTo(7.5, 37.5);
+               cpA3.moveCenterTo(7.5, 62.5);
+               cpA4.moveCenterTo(7.5, 87.5);
+               cpB1.moveCenterTo(7.5, 112.5);
+               cpB2.moveCenterTo(7.5, 137.5);
+               cpB3.moveCenterTo(7.5, 162.5);
+               cpB4.moveCenterTo(7.5, 187.5);
 
                new GUIWire(submodelModifiable, A1, cpA1, new Point[0]);
                new GUIWire(submodelModifiable, A2, cpA2, new Point[0]);
index eb3028e..be0f5d5 100644 (file)
@@ -12,6 +12,9 @@ import net.mograsim.logic.ui.model.components.GUIComponent;
 
 public class WireCrossPoint extends GUIComponent
 {
+       private static final int CIRCLE_RADIUS = 1;
+       private static final int CIRCLE_DIAM = CIRCLE_RADIUS * 2;
+
        private final Pin pin;
        private final int logicWidth;
 
@@ -24,8 +27,13 @@ public class WireCrossPoint extends GUIComponent
                logicObs = (i) -> requestRedraw();
 
                this.logicWidth = logicWidth;
-               setSize(0, 0);
-               addPin(this.pin = new Pin(this, logicWidth, 0, 0));
+               setSize(CIRCLE_DIAM, CIRCLE_DIAM);
+               addPin(this.pin = new Pin(this, logicWidth, CIRCLE_RADIUS, CIRCLE_RADIUS));
+       }
+
+       public void moveCenterTo(double x, double y)
+       {
+               moveTo(x - CIRCLE_RADIUS, y - CIRCLE_RADIUS);
        }
 
        @Override
@@ -33,7 +41,7 @@ public class WireCrossPoint extends GUIComponent
        {
                Rectangle bounds = getBounds();
                ColorHelper.executeWithDifferentBackground(gc, BitVectorFormatter.formatAsColor(end),
-                               () -> gc.fillOval(bounds.x - 1, bounds.y - 1, 2, 2));
+                               () -> gc.fillOval(bounds.x, bounds.y, CIRCLE_DIAM, CIRCLE_DIAM));
        }
 
        public void setLogicModelBinding(ReadEnd end)