Search in sources :

Example 16 with Circuit

use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.

the class TestSelect method testSelect.

public void testSelect() throws Exception {
    Circuit c = new ToBreakRunner("dig/selectOuter.dig").getCircuit();
    // don't select by clicking in label size bounding box
    VisualElement el = c.getElementAt(new Vector(65, 15));
    assertNull(el);
    // select by clicking in shape size bounding box
    el = c.getElementAt(new Vector(55, 15));
    assertNotNull(el);
    assertEquals("selectInnerLongName.dig", el.getElementName());
    // select output by clicking in shape size bounding box
    el = c.getElementAt(new Vector(195, 20));
    assertNotNull(el);
    assertEquals(Out.DESCRIPTION.getName(), el.getElementName());
    // don't select output by clicking in label text
    el = c.getElementAt(new Vector(250, 20));
    assertNull(el);
    // select text by clicking in text size bounding box
    el = c.getElementAt(new Vector(20, 110));
    assertNotNull(el);
    assertEquals(DummyElement.TEXTDESCRIPTION.getName(), el.getElementName());
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) VisualElement(de.neemann.digital.draw.elements.VisualElement) Vector(de.neemann.digital.draw.graphics.Vector)

Example 17 with Circuit

use of de.neemann.digital.draw.elements.Circuit 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)

Example 18 with Circuit

use of de.neemann.digital.draw.elements.Circuit 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;
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Expression(de.neemann.digital.analyse.expression.Expression) Model(de.neemann.digital.core.Model) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) ModelCreator(de.neemann.digital.draw.model.ModelCreator) Parser(de.neemann.digital.analyse.parser.Parser) CircuitBuilder(de.neemann.digital.builder.circuit.CircuitBuilder)

Example 19 with Circuit

use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.

the class ExportZipAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JFileChooser fc = new JFileChooser(main.getBaseFileName());
    fc.setFileFilter(new FileNameExtensionFilter("ZIP", "zip"));
    new SaveAsHelper(main, fc, "zip").checkOverwrite(file -> {
        try (ZipOutputStream zip = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
            Circuit circuit = main.getCircuitComponent().getCircuit();
            lib = main.getCircuitComponent().getLibrary();
            File origin = circuit.getOrigin();
            elementSet = new HashSet<>();
            addFile(zip, origin, circuit);
            addToZip(zip, "MANIFEST.TXT", "Main-Circuit: " + origin.getName() + "\n");
        } catch (ElementNotFoundException e1) {
            throw new IOException(Lang.get("err_errorExportingZip"), e1);
        }
    });
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) Circuit(de.neemann.digital.draw.elements.Circuit) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter)

Example 20 with Circuit

use of de.neemann.digital.draw.elements.Circuit 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);
}
Also used : ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) File(java.io.File) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Aggregations

Circuit (de.neemann.digital.draw.elements.Circuit)26 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)9 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)8 Vector (de.neemann.digital.draw.graphics.Vector)7 ModelCreator (de.neemann.digital.draw.model.ModelCreator)7 Expression (de.neemann.digital.analyse.expression.Expression)6 VisualElement (de.neemann.digital.draw.elements.VisualElement)6 File (java.io.File)6 TestExecuter (de.neemann.digital.TestExecuter)5 Wire (de.neemann.digital.draw.elements.Wire)5 Variable (de.neemann.digital.analyse.expression.Variable)4 IOException (java.io.IOException)4 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)3 Main (de.neemann.digital.gui.Main)3 CircuitBuilder (de.neemann.digital.builder.circuit.CircuitBuilder)2 Model (de.neemann.digital.core.Model)2 ExpressionListenerStore (de.neemann.digital.gui.components.table.ExpressionListenerStore)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1