Search in sources :

Example 51 with Vector

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));
}
Also used : Vector(de.neemann.digital.draw.graphics.Vector)

Example 52 with Vector

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)));
}
Also used : ArrayList(java.util.ArrayList) Vector(de.neemann.digital.draw.graphics.Vector)

Example 53 with Vector

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));
}
Also used : ArrayList(java.util.ArrayList) Vector(de.neemann.digital.draw.graphics.Vector)

Example 54 with Vector

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);
}
Also used : Vector(de.neemann.digital.draw.graphics.Vector)

Example 55 with Vector

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());
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector)

Aggregations

Vector (de.neemann.digital.draw.graphics.Vector)63 Wire (de.neemann.digital.draw.elements.Wire)13 Polygon (de.neemann.digital.draw.graphics.Polygon)12 VisualElement (de.neemann.digital.draw.elements.VisualElement)9 Style (de.neemann.digital.draw.graphics.Style)8 Circuit (de.neemann.digital.draw.elements.Circuit)6 Pin (de.neemann.digital.draw.elements.Pin)3 Pins (de.neemann.digital.draw.elements.Pins)3 ArrayList (java.util.ArrayList)3 Rotation (de.neemann.digital.core.element.Rotation)2 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)2 ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)2 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)2 IOException (java.io.IOException)2 NodeException (de.neemann.digital.core.NodeException)1 ObservableValue (de.neemann.digital.core.ObservableValue)1 Movable (de.neemann.digital.draw.elements.Movable)1 GraphicMinMax (de.neemann.digital.draw.graphics.GraphicMinMax)1 Orientation (de.neemann.digital.draw.graphics.Orientation)1 Transform (de.neemann.digital.draw.graphics.Transform)1