Search in sources :

Example 56 with Vector

use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.

the class NetListTest method testSimple.

public void testSimple() throws Exception {
    Circuit c = new Circuit();
    c.add(new Wire(new Vector(1, 1), new Vector(1, 2)));
    c.add(new Wire(new Vector(2, 1), new Vector(2, 2)));
    c.add(new Wire(new Vector(1, 2), new Vector(2, 2)));
    c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
    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)

Example 57 with Vector

use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.

the class FragmentVisualElementTest method testBox.

public void testBox() throws Exception {
    ShapeFactory shapeFactory = new ShapeFactory(new ElementLibrary());
    FragmentVisualElement ve = new FragmentVisualElement(FlipflopJK.DESCRIPTION, shapeFactory);
    ve.setPos(new Vector(0, 0));
    Box box = ve.doLayout();
    assertEquals(SIZE * 3, box.getHeight());
    assertEquals(SIZE * 3, box.getWidth());
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Vector(de.neemann.digital.draw.graphics.Vector)

Example 58 with Vector

use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.

the class CircuitBuilder method addFragmentToCircuit.

private void addFragmentToCircuit(Fragment fr, Circuit circuit) {
    fr.setPos(new Vector(0, 0));
    Box b = fr.doLayout();
    fr.addToCircuit(new Vector(0, pos), circuit);
    pos += b.getHeight() + SIZE * 2;
}
Also used : Vector(de.neemann.digital.draw.graphics.Vector)

Example 59 with Vector

use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.

the class CircuitBuilder method checkForOutputBus.

private int checkForOutputBus(int splitterXPos, Circuit circuit) {
    StringBuilder pinString = new StringBuilder();
    int y = 0;
    for (Map.Entry<String, ArrayList<String>> e : mis.getOutputBusMap().entrySet()) {
        pinString.setLength(0);
        int found = 0;
        final ArrayList<String> outputs = e.getValue();
        for (String n : outputs) {
            if (combinatorialOutputs.containsKey(n)) {
                found++;
                String p = mis.getPins().get(n);
                if (p != null) {
                    if (pinString.length() != 0)
                        pinString.append(",");
                    pinString.append(p);
                }
            }
        }
        if (found == outputs.size()) {
            circuit.add(new VisualElement(Splitter.DESCRIPTION.getName()).setAttribute(Keys.OUTPUT_SPLIT, "" + outputs.size()).setAttribute(Keys.INPUT_SPLIT, "1*" + outputs.size()).setPos(new Vector(splitterXPos, y)).setShapeFactory(shapeFactory));
            circuit.add(new VisualElement(Out.DESCRIPTION.getName()).setAttribute(Keys.LABEL, e.getKey()).setAttribute(Keys.BITS, outputs.size()).setAttribute(Keys.PINNUMBER, pinString.toString()).setPos(new Vector(splitterXPos + 3 * SIZE, y)).setShapeFactory(shapeFactory));
            circuit.add(new Wire(new Vector(splitterXPos + 3 * SIZE, y), new Vector(splitterXPos + SIZE, y)));
            for (int i = 0; i < outputs.size(); i++) {
                circuit.add(new VisualElement(Tunnel.DESCRIPTION.getName()).setAttribute(Keys.NETNAME, outputs.get(i)).setRotation(2).setPos(new Vector(splitterXPos - SIZE, y + i * SIZE)).setShapeFactory(shapeFactory));
                circuit.add(new Wire(new Vector(splitterXPos - SIZE, y + i * SIZE), new Vector(splitterXPos, y + i * SIZE)));
                FragmentVisualElement frag = combinatorialOutputs.get(outputs.get(i));
                frag.setVisualElement(new VisualElement(Tunnel.DESCRIPTION.getName()).setShapeFactory(shapeFactory).setAttribute(Keys.NETNAME, outputs.get(i)));
            }
            y += (outputs.size() + 2) * SIZE;
        }
    }
    return y;
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector)

Example 60 with Vector

use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.

the class CircuitBuilder method addClockToFlipFlops.

private void addClockToFlipFlops(Circuit circuit) {
    int x = Integer.MAX_VALUE;
    int yMin = Integer.MAX_VALUE;
    int yMax = Integer.MIN_VALUE;
    for (FragmentVisualElement ff : flipflops) {
        Vector p = ff.getVisualElement().getPos();
        if (p.x < x)
            x = p.x;
        if (p.y < yMin)
            yMin = p.y;
        if (p.y > yMax)
            yMax = p.y;
    }
    x -= SIZE;
    if (useJKff)
        x -= SIZE;
    int yPos = yMin - SIZE * 3;
    if (useJKff)
        yPos = -SIZE;
    circuit.add(new Wire(new Vector(x, yPos), new Vector(x, yMax + SIZE)));
    for (FragmentVisualElement ff : flipflops) {
        Vector p = ff.getVisualElement().getPos();
        circuit.add(new Wire(new Vector(x, p.y + SIZE), new Vector(p.x, p.y + SIZE)));
    }
    VisualElement clock = new VisualElement(Clock.DESCRIPTION.getName()).setShapeFactory(shapeFactory).setPos(new Vector(x, yPos));
    clock.getElementAttributes().set(Keys.LABEL, "C").set(Keys.ROTATE, new Rotation(3)).set(Keys.FREQUENCY, 2).set(Keys.RUN_AT_REAL_TIME, true);
    circuit.add(clock);
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector) Rotation(de.neemann.digital.core.element.Rotation)

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