use of de.neemann.digital.draw.shapes.ShapeFactory 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);
}
use of de.neemann.digital.draw.shapes.ShapeFactory 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());
}
use of de.neemann.digital.draw.shapes.ShapeFactory 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);
}
use of de.neemann.digital.draw.shapes.ShapeFactory in project Digital by hneemann.
the class TestResultTest method getModel.
private Model getModel(String func) throws IOException, ParseException, BuilderException, PinException, NodeException, ElementNotFoundException {
ArrayList<Expression> exp = new Parser(func).parse();
ElementLibrary library = new ElementLibrary();
CircuitBuilder cb = new CircuitBuilder(new ShapeFactory(library));
cb.addCombinatorial("Y", exp.get(0));
Circuit circ = cb.createCircuit();
Model model = new ModelCreator(circ, library).createModel(false);
model.init();
return model;
}
use of de.neemann.digital.draw.shapes.ShapeFactory in project Digital by hneemann.
the class TestExecuter method createFromFile.
public static TestExecuter createFromFile(String name, ElementLibrary library) throws IOException, NodeException, PinException, ElementNotFoundException {
File filename = new File(Resources.getRoot(), name);
Circuit circuit = Circuit.loadCircuit(filename, new ShapeFactory(library));
ModelCreator mb = new ModelCreator(circuit, library);
return new TestExecuter(mb.createModel(false), true).setUp(mb);
}
Aggregations