mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
renamed a method
This commit is contained in:
parent
dce75d9667
commit
173a2172cf
@ -326,6 +326,20 @@ public class Circuit implements Copyable<Circuit> {
|
|||||||
return visualElements;
|
return visualElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find specific visual elements
|
||||||
|
*
|
||||||
|
* @param filter the filter
|
||||||
|
* @return the elements
|
||||||
|
*/
|
||||||
|
public List<VisualElement> getElements(Circuit.ElementFilter filter) {
|
||||||
|
ArrayList<VisualElement> found = new ArrayList<>();
|
||||||
|
for (VisualElement v : visualElements)
|
||||||
|
if (filter.accept(v))
|
||||||
|
found.add(v);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all Moveables in the given rectangle.
|
* Returns a list of all Moveables in the given rectangle.
|
||||||
*
|
*
|
||||||
@ -588,20 +602,6 @@ public class Circuit implements Copyable<Circuit> {
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find specific visual elements
|
|
||||||
*
|
|
||||||
* @param filter the filter
|
|
||||||
* @return the elements
|
|
||||||
*/
|
|
||||||
public List<VisualElement> findElements(Circuit.ElementFilter filter) {
|
|
||||||
ArrayList<VisualElement> found = new ArrayList<>();
|
|
||||||
for (VisualElement v : visualElements)
|
|
||||||
if (filter.accept(v))
|
|
||||||
found.add(v);
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the references to the ObservableValues representing the elements or wire state.
|
* Deletes the references to the ObservableValues representing the elements or wire state.
|
||||||
* So this circuit is detached from a generated model.
|
* So this circuit is detached from a generated model.
|
||||||
|
@ -1139,13 +1139,11 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
private Modification<Circuit> checkNetRename(VisualElement element, ElementAttributes modified, Modification<Circuit> mod) {
|
private Modification<Circuit> checkNetRename(VisualElement element, ElementAttributes modified, Modification<Circuit> mod) {
|
||||||
String oldName = element.getElementAttributes().get(Keys.NETNAME);
|
String oldName = element.getElementAttributes().get(Keys.NETNAME);
|
||||||
if (element.equalsDescription(Tunnel.DESCRIPTION) && modified.contains(Keys.NETNAME) && !oldName.isEmpty()) {
|
if (element.equalsDescription(Tunnel.DESCRIPTION) && modified.contains(Keys.NETNAME) && !oldName.isEmpty()) {
|
||||||
ArrayList<VisualElement> others = new ArrayList<>();
|
|
||||||
for (VisualElement el : getCircuit().getElements())
|
List<VisualElement> others = getCircuit().getElements(el -> el != element
|
||||||
if (el != element
|
&& el.equalsDescription(Tunnel.DESCRIPTION)
|
||||||
&& el.equalsDescription(Tunnel.DESCRIPTION)
|
&& el.getElementAttributes().get(Keys.NETNAME).equals(oldName));
|
||||||
&& el.getElementAttributes().get(Keys.NETNAME).equals(oldName)) {
|
|
||||||
others.add(el);
|
|
||||||
}
|
|
||||||
if (others.size() > 0) {
|
if (others.size() > 0) {
|
||||||
String newName = modified.get(Keys.NETNAME);
|
String newName = modified.get(Keys.NETNAME);
|
||||||
int res = JOptionPane.showConfirmDialog(this,
|
int res = JOptionPane.showConfirmDialog(this,
|
||||||
|
@ -411,7 +411,7 @@ public final class Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getFrequency() throws HGSEvalException {
|
private int getFrequency() throws HGSEvalException {
|
||||||
List<VisualElement> l = circuitProvider.getCurrentCircuit().findElements(v -> v.equalsDescription(Clock.DESCRIPTION));
|
List<VisualElement> l = circuitProvider.getCurrentCircuit().getElements(v -> v.equalsDescription(Clock.DESCRIPTION));
|
||||||
if (l.isEmpty())
|
if (l.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
if (l.size() > 1)
|
if (l.size() > 1)
|
||||||
|
@ -216,12 +216,12 @@ public class CircuitBuilderTest extends TestCase {
|
|||||||
Circuit circuit = circuitBuilder.createCircuit();
|
Circuit circuit = circuitBuilder.createCircuit();
|
||||||
|
|
||||||
// check
|
// check
|
||||||
List<VisualElement> in = circuit.findElements(v -> v.equalsDescription(In.DESCRIPTION));
|
List<VisualElement> in = circuit.getElements(v -> v.equalsDescription(In.DESCRIPTION));
|
||||||
assertEquals(2, in.size());
|
assertEquals(2, in.size());
|
||||||
checkPin(in.get(0), "A", "1,2,3,4");
|
checkPin(in.get(0), "A", "1,2,3,4");
|
||||||
checkPin(in.get(1), "B", "5,6,7,8");
|
checkPin(in.get(1), "B", "5,6,7,8");
|
||||||
|
|
||||||
List<VisualElement> out = circuit.findElements(v -> v.equalsDescription(Out.DESCRIPTION));
|
List<VisualElement> out = circuit.getElements(v -> v.equalsDescription(Out.DESCRIPTION));
|
||||||
assertEquals(2, out.size());
|
assertEquals(2, out.size());
|
||||||
checkPin(out.get(0), "S", "9,10,11,12");
|
checkPin(out.get(0), "S", "9,10,11,12");
|
||||||
checkPin(out.get(1), "U", "13,14,15,16");
|
checkPin(out.get(1), "U", "13,14,15,16");
|
||||||
|
@ -964,6 +964,7 @@ public class TestInGUI extends TestCase {
|
|||||||
.press("ENTER")
|
.press("ENTER")
|
||||||
.delay(200)
|
.delay(200)
|
||||||
.add(new GuiTester.CheckTextInWindow<>(JDialog.class, "'net'"))
|
.add(new GuiTester.CheckTextInWindow<>(JDialog.class, "'net'"))
|
||||||
|
.add(new GuiTester.CheckTextInWindow<>(JDialog.class, " 2 "))
|
||||||
.delay(200)
|
.delay(200)
|
||||||
.press("ENTER")
|
.press("ENTER")
|
||||||
.delay(200)
|
.delay(200)
|
||||||
@ -971,7 +972,7 @@ public class TestInGUI extends TestCase {
|
|||||||
@Override
|
@Override
|
||||||
public void checkWindow(GuiTester guiTester, Main main) {
|
public void checkWindow(GuiTester guiTester, Main main) {
|
||||||
List<VisualElement> e = main.getCircuitComponent().getCircuit()
|
List<VisualElement> e = main.getCircuitComponent().getCircuit()
|
||||||
.findElements(v -> v.equalsDescription(Tunnel.DESCRIPTION));
|
.getElements(v -> v.equalsDescription(Tunnel.DESCRIPTION));
|
||||||
assertEquals(3, e.size());
|
assertEquals(3, e.size());
|
||||||
for (VisualElement v : e)
|
for (VisualElement v : e)
|
||||||
assertEquals("net", v.getElementAttributes().get(Keys.NETNAME));
|
assertEquals("net", v.getElementAttributes().get(Keys.NETNAME));
|
||||||
@ -1189,7 +1190,7 @@ public class TestInGUI extends TestCase {
|
|||||||
List<VisualElement> el = main
|
List<VisualElement> el = main
|
||||||
.getCircuitComponent()
|
.getCircuitComponent()
|
||||||
.getCircuit()
|
.getCircuit()
|
||||||
.findElements(v -> v.equalsDescription(description));
|
.getElements(v -> v.equalsDescription(description));
|
||||||
|
|
||||||
assertEquals("not exact one " + description.getName() + " found in circuit", 1, el.size());
|
assertEquals("not exact one " + description.getName() + " found in circuit", 1, el.size());
|
||||||
|
|
||||||
@ -1218,7 +1219,7 @@ public class TestInGUI extends TestCase {
|
|||||||
List<VisualElement> el = main
|
List<VisualElement> el = main
|
||||||
.getCircuitComponent()
|
.getCircuitComponent()
|
||||||
.getCircuit()
|
.getCircuit()
|
||||||
.findElements(filter);
|
.getElements(filter);
|
||||||
|
|
||||||
assertEquals("not exact one element found in circuit", 1, el.size());
|
assertEquals("not exact one element found in circuit", 1, el.size());
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class RegressionTest extends TestCase {
|
|||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
ioInterface = new ConfigurationTest.TestIOInterface();
|
ioInterface = new ConfigurationTest.TestIOInterface();
|
||||||
br = new ToBreakRunner(new File(Resources.getRoot(), "toolchain/ff.dig"));
|
br = new ToBreakRunner(new File(Resources.getRoot(), "toolchain/ff.dig"));
|
||||||
clock = br.getCircuit().findElements(v -> v.equalsDescription(Clock.DESCRIPTION)).get(0);
|
clock = br.getCircuit().getElements(v -> v.equalsDescription(Clock.DESCRIPTION)).get(0);
|
||||||
File root = new File(Resources.getRoot(), "../../main/dig/hdl");
|
File root = new File(Resources.getRoot(), "../../main/dig/hdl");
|
||||||
int fc = new FileScanner(this::doCheck).setSuffix(".config").scan(root);
|
int fc = new FileScanner(this::doCheck).setSuffix(".config").scan(root);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user