Search in sources :

Example 6 with ElementLibrary

use of de.neemann.digital.draw.library.ElementLibrary in project Digital by hneemann.

the class CircuitBuilderTest method testBuilderSequential.

public void testBuilderSequential() throws Exception {
    Variable y0 = new Variable("Y_0");
    Variable y1 = new Variable("Y_1");
    // counter
    Expression y0s = not(y0);
    Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
    ElementLibrary library = new ElementLibrary();
    Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
    ModelCreator m = new ModelCreator(circuit, library);
    TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
    te.check(0, 0);
    te.checkC(1, 0);
    te.checkC(0, 1);
    te.checkC(1, 1);
    te.checkC(0, 0);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 7 with ElementLibrary

use of de.neemann.digital.draw.library.ElementLibrary in project Digital by hneemann.

the class CircuitBuilderTest method testBuilderSequentialJK_JequalsK.

public void testBuilderSequentialJK_JequalsK() throws Exception {
    Variable y0 = new Variable("Y_0");
    Variable y1 = new Variable("Y_1");
    // counter
    Expression y0s = not(y0);
    Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
    ElementLibrary library = new ElementLibrary();
    Circuit circuit = new CircuitBuilder(new ShapeFactory(library), true).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
    ModelCreator m = new ModelCreator(circuit, library);
    TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
    te.check(0, 0);
    te.checkC(1, 0);
    te.checkC(0, 1);
    te.checkC(1, 1);
    te.checkC(0, 0);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 8 with ElementLibrary

use of de.neemann.digital.draw.library.ElementLibrary in project Digital by hneemann.

the class FragmentExpressionTest method testBox.

public void testBox() throws Exception {
    ShapeFactory shapeFactory = new ShapeFactory(new ElementLibrary());
    FragmentVisualElement ve = new FragmentVisualElement(FlipflopJK.DESCRIPTION, shapeFactory);
    FragmentExpression fe = new FragmentExpression(ve, new FragmentVisualElement(Tunnel.DESCRIPTION, shapeFactory));
    fe.setPos(new Vector(0, 0));
    Box box = fe.doLayout();
    assertEquals(SIZE * 3, box.getHeight());
    assertEquals(SIZE * 4, 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 9 with ElementLibrary

use of de.neemann.digital.draw.library.ElementLibrary in project Digital by hneemann.

the class TestNesting method createTestExecuterForNesting.

private TestExecuter createTestExecuterForNesting(String file) throws IOException, NodeException, PinException, ElementNotFoundException {
    ElementLibrary library = new ElementLibrary();
    library.setRootFilePath(new File(Resources.getRoot(), "dig"));
    return TestExecuter.createFromFile(file, library);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) File(java.io.File)

Example 10 with ElementLibrary

use of de.neemann.digital.draw.library.ElementLibrary in project Digital by hneemann.

the class TestShapes method useShapes.

private void useShapes(boolean ieee) throws Exception {
    File filename = new File(Resources.getRoot(), "dig/shapes.dig");
    ElementLibrary library = new ElementLibrary();
    library.setRootFilePath(new File(Resources.getRoot(), "dig"));
    ShapeFactory shapeFactory = new ShapeFactory(library, ieee);
    Circuit circuit = Circuit.loadCircuit(filename, shapeFactory);
    // try to write circuit to graphics instance
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new Export(circuit, (out) -> new GraphicsImage(out, "PNG", 1)).export(baos);
    assertTrue(baos.size() > 30000);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) GraphicsImage(de.neemann.digital.draw.graphics.GraphicsImage) ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) TestCase(junit.framework.TestCase) Export(de.neemann.digital.draw.graphics.Export) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) File(java.io.File) Circuit(de.neemann.digital.draw.elements.Circuit) ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) GraphicsImage(de.neemann.digital.draw.graphics.GraphicsImage) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Export(de.neemann.digital.draw.graphics.Export) Circuit(de.neemann.digital.draw.elements.Circuit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File)

Aggregations

ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)15 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)11 Circuit (de.neemann.digital.draw.elements.Circuit)7 ModelCreator (de.neemann.digital.draw.model.ModelCreator)6 TestExecuter (de.neemann.digital.TestExecuter)5 Expression (de.neemann.digital.analyse.expression.Expression)5 Variable (de.neemann.digital.analyse.expression.Variable)4 File (java.io.File)3 Model (de.neemann.digital.core.Model)2 Vector (de.neemann.digital.draw.graphics.Vector)2 Parser (de.neemann.digital.analyse.parser.Parser)1 CircuitBuilder (de.neemann.digital.builder.circuit.CircuitBuilder)1 Node (de.neemann.digital.core.Node)1 DataField (de.neemann.digital.core.memory.DataField)1 VisualElement (de.neemann.digital.draw.elements.VisualElement)1 Export (de.neemann.digital.draw.graphics.Export)1 GraphicsImage (de.neemann.digital.draw.graphics.GraphicsImage)1 LibraryNode (de.neemann.digital.draw.library.LibraryNode)1 ModelEntry (de.neemann.digital.draw.model.ModelEntry)1 BufferedImage (java.awt.image.BufferedImage)1