use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.
the class ModifyAttribute method modify.
@Override
public void modify(Circuit circuit, ElementLibrary library) {
VisualElement ve = getVisualElement(circuit);
ve.getElementAttributes().set(key, value);
}
use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.
the class ModifyAttributes method modify.
@Override
public void modify(Circuit circuit, ElementLibrary library) {
VisualElement ve = getVisualElement(circuit);
ve.getElementAttributes().getValuesFrom(attributes);
}
use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.
the class TestInGUI method testShortcutsPlusMinus.
public void testShortcutsPlusMinus() {
new GuiTester().mouseMove(100 + SIZE * 2, 100 + SIZE * 2).add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
final CircuitComponent cc = main.getCircuitComponent();
final VisualElement ve = new VisualElement(And.DESCRIPTION.getName()).setShapeFactory(cc.getLibrary().getShapeFactory());
cc.setPartToInsert(ve);
})).mouseClick(InputEvent.BUTTON1_MASK).mouseMove(100, 100).press("PLUS").press("PLUS").add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
final Circuit c = main.getCircuitComponent().getCircuit();
assertEquals(1, c.getElements().size());
assertEquals(4, (int) c.getElements().get(0).getElementAttributes().get(Keys.INPUT_COUNT));
})).press("MINUS").press("MINUS").add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
final Circuit c = main.getCircuitComponent().getCircuit();
assertEquals(1, c.getElements().size());
assertEquals(2, (int) c.getElements().get(0).getElementAttributes().get(Keys.INPUT_COUNT));
})).execute();
}
use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.
the class TestInGUI method test74xxFunctions.
public void test74xxFunctions() {
new GuiTester("dig/manualError/10_74xx.dig").press("F10").press("RIGHT", 2).press("DOWN", 4).press("RIGHT").press("DOWN", 2).press("ENTER").add(new ClickInputsAndOutputs()).press("ESCAPE").add(new GuiTester.WindowCheck<>(Main.class, (guiTester, main) -> {
final CircuitComponent cc = main.getCircuitComponent();
ArrayList<VisualElement> el = cc.getCircuit().getElements();
int n = 0;
for (VisualElement ve : el) if (ve.equalsDescription(In.DESCRIPTION) || ve.equalsDescription(Out.DESCRIPTION)) {
n++;
assertEquals("" + n, ve.getElementAttributes().get(Keys.PINNUMBER));
}
})).add(new SelectAll()).press("F10").press("RIGHT", 2).press("DOWN", 5).press("RIGHT").press("ENTER").type("U").press("ENTER").add(new PinNameChecker("UC")).press("F10").press("RIGHT", 2).press("DOWN", 5).press("RIGHT").press("DOWN").press("ENTER").add(new PinNameChecker("C")).press("F10").press("RIGHT", 2).press("DOWN", 5).press("RIGHT").press("DOWN", 3).press("ENTER").add(new GuiTester.WindowCheck<>(Main.class, (guiTester, main) -> {
final CircuitComponent cc = main.getCircuitComponent();
ArrayList<VisualElement> el = cc.getCircuit().getElements();
for (VisualElement ve : el) if (ve.equalsDescription(In.DESCRIPTION) || ve.equalsDescription(Out.DESCRIPTION))
assertEquals("", ve.getElementAttributes().get(Keys.PINNUMBER));
})).press("F10").press("RIGHT", 2).press("DOWN", 5).press("RIGHT").press("DOWN", 4).press("ENTER").mouseClick(InputEvent.BUTTON1_MASK).add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> assertEquals(7, main.getCircuitComponent().getCircuit().getElements().size()))).execute();
}
use of de.neemann.digital.draw.elements.VisualElement in project Digital by hneemann.
the class TestLib method check.
private void check(File dig) throws PinException, NodeException, ElementNotFoundException, IOException {
Circuit circuit = new ToBreakRunner(dig).getCircuit();
boolean is74xx = dig.getPath().contains("74xx") && !dig.getName().endsWith("-inc.dig");
if (is74xx) {
assertTrue("is not DIL", circuit.getAttributes().get(Keys.IS_DIL));
count74xx++;
}
assertTrue("is not locked", circuit.getAttributes().get(Keys.LOCKED_MODE));
final String descr = circuit.getAttributes().get(Keys.DESCRIPTION);
assertTrue("missing description", descr.length() > 0);
File f = descrMap.get(descr);
if (f != null)
fail("duplicate description '" + descr + "' in " + f + " and " + dig);
descrMap.put(descr, dig);
PinChecker pc = new PinChecker(is74xx);
for (VisualElement e : circuit.getElements()) {
if (e.equalsDescription(In.DESCRIPTION))
pc.checkPin(e);
if (e.equalsDescription(Out.DESCRIPTION))
pc.checkPin(e);
if (e.equalsDescription(Clock.DESCRIPTION))
pc.checkPin(e);
if (e.equalsDescription(ROM.DESCRIPTION) || e.equalsDescription(EEPROM.DESCRIPTION))
assertEquals("*", e.getElementAttributes().getLabel());
}
if (is74xx) {
assertTrue("GND is missing", pc.isGND);
assertTrue("VCC is missing", pc.isVCC);
}
}
Aggregations