use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class WireContainsTest method testVertical.
public void testVertical() {
Wire w = new Wire(new Vector(0, 0), new Vector(0, 10));
assertFalse(w.contains(new Vector(0, -5), 5));
assertFalse(w.contains(new Vector(0, 15), 5));
assertFalse(w.contains(new Vector(5, 5), 5));
assertFalse(w.contains(new Vector(-5, 5), 5));
assertTrue(w.contains(new Vector(2, 5), 5));
assertTrue(w.contains(new Vector(-2, 5), 5));
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class WireMergerTest method testMerge2.
public void testMerge2() {
WireMerger wm = new WireMerger(Wire.Orientation.horzontal);
wm.add(new Wire(new Vector(1, 3), new Vector(3, 3)));
wm.add(new Wire(new Vector(6, 3), new Vector(8, 3)));
wm.add(new Wire(new Vector(2, 3), new Vector(7, 3)));
ArrayList<Wire> newWires = new ArrayList<>();
wm.addTo(newWires);
assertEquals(1, newWires.size());
assertTrue(new Wire(new Vector(1, 3), new Vector(8, 3)).equalsContent(newWires.get(0)));
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class WireMergerTest method testMerge1.
public void testMerge1() {
WireMerger wm = new WireMerger(Wire.Orientation.horzontal);
wm.add(new Wire(new Vector(1, 3), new Vector(5, 3)));
wm.add(new Wire(new Vector(5, 3), new Vector(8, 3)));
wm.add(new Wire(new Vector(1, 4), new Vector(5, 4)));
wm.add(new Wire(new Vector(5, 5), new Vector(8, 5)));
wm.add(new Wire(new Vector(1, 6), new Vector(6, 6)));
wm.add(new Wire(new Vector(4, 6), new Vector(8, 6)));
wm.add(new Wire(new Vector(1, 7), new Vector(4, 7)));
wm.add(new Wire(new Vector(5, 7), new Vector(8, 7)));
ArrayList<Wire> newWires = new ArrayList<>();
wm.addTo(newWires);
assertEquals(6, newWires.size());
assertTrue(new Wire(new Vector(1, 3), new Vector(8, 3)).isIncludedIn(newWires));
assertTrue(new Wire(new Vector(1, 4), new Vector(5, 4)).isIncludedIn(newWires));
assertTrue(new Wire(new Vector(5, 5), new Vector(8, 5)).isIncludedIn(newWires));
assertTrue(new Wire(new Vector(1, 6), new Vector(8, 6)).isIncludedIn(newWires));
assertTrue(new Wire(new Vector(1, 7), new Vector(4, 7)).isIncludedIn(newWires));
assertTrue(new Wire(new Vector(5, 7), new Vector(8, 7)).isIncludedIn(newWires));
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class WireMergerTest method testHorizontal.
public void testHorizontal() {
WireMerger.OrientationHandler handler = new WireMerger.OrientationHandlerHorizontal();
assertEquals(1, handler.getS(new Vector(1, 3)));
assertEquals(3, handler.getWireClass(new Vector(1, 3)));
Wire wire = handler.toWire(new WireMerger.SimpleWire(1, 3, 7));
assertEquals(new Vector(3, 1), wire.p1);
assertEquals(new Vector(7, 1), wire.p2);
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class NetListTest method testTunnel3.
public void testTunnel3() throws Exception {
Circuit c = new Circuit();
c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
addTunnel(c, new Vector(2, 1), "A");
c.add(new Wire(new Vector(3, 1), new Vector(4, 1)));
addTunnel(c, new Vector(3, 1), "A");
addTunnel(c, new Vector(4, 1), "C");
c.add(new Wire(new Vector(1, 4), new Vector(2, 4)));
addTunnel(c, new Vector(2, 4), "B");
addTunnel(c, new Vector(1, 4), "C");
c.add(new Wire(new Vector(3, 4), new Vector(4, 4)));
addTunnel(c, new Vector(3, 4), "B");
NetList ns = new NetList(c);
assertEquals(1, ns.size());
}
Aggregations