mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 00:15:01 -04:00
added inverted inputs to stats
This commit is contained in:
parent
7e7d7fe004
commit
4dab5e4bca
@ -731,19 +731,6 @@
|
||||
</elementAttributes>
|
||||
<pos x="1800" y="620"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Or</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>inverterConfig</string>
|
||||
<inverterConfig>
|
||||
<string>In_1</string>
|
||||
<string>In_2</string>
|
||||
</inverterConfig>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="1620" y="160"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>NOr</elementName>
|
||||
<elementAttributes>
|
||||
@ -1590,6 +1577,11 @@ end loop
|
||||
</elementAttributes>
|
||||
<pos x="-520" y="1500"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>NAnd</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="1600" y="160"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
|
@ -113,6 +113,7 @@ public class Stats {
|
||||
|
||||
private final ElementLibrary library;
|
||||
private TreeMap<EntryKey, Entry> map;
|
||||
private int invertedInputs;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
@ -144,6 +145,8 @@ public class Stats {
|
||||
}
|
||||
|
||||
private void add(ElementTypeDescription description, ElementAttributes attr) throws ElementNotFoundException {
|
||||
invertedInputs += attr.get(Keys.INVERTER_CONFIG).size();
|
||||
|
||||
int transistors = 0;
|
||||
Circuit childCircuit = null;
|
||||
if (description instanceof ElementLibrary.ElementTypeDescriptionCustom) {
|
||||
@ -175,31 +178,10 @@ public class Stats {
|
||||
*/
|
||||
public TableModel getTableModel() {
|
||||
final ArrayList<Row> entries = new ArrayList<>(map.values());
|
||||
entries.add(new Row() {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("stat_sum");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransistorsEach() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransistorsEach(int transistors) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return false;
|
||||
}
|
||||
if (invertedInputs > 0)
|
||||
entries.add(new Entry(Lang.get("key_inverterConfig"), invertedInputs, true, 2));
|
||||
|
||||
entries.add(new Entry(Lang.get("stat_sum"), 0, false, 0) {
|
||||
@Override
|
||||
public int getTransistors() {
|
||||
int tr = 0;
|
||||
@ -317,64 +299,11 @@ public class Stats {
|
||||
|
||||
}
|
||||
|
||||
private static final class Entry implements Row {
|
||||
private final EntryKey key;
|
||||
private int transistors;
|
||||
private final boolean editable;
|
||||
private int count;
|
||||
|
||||
private Entry(EntryKey key, boolean editable) {
|
||||
this.key = key;
|
||||
transistors = key.transistors;
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
private void addOne() {
|
||||
count++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return count + " x " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return key.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransistorsEach(int t) {
|
||||
transistors = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransistorsEach() {
|
||||
return transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransistors() {
|
||||
return count * transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
}
|
||||
|
||||
private interface TransistorCalculator {
|
||||
int transistors(ElementAttributes attr);
|
||||
}
|
||||
|
||||
private interface Row {
|
||||
|
||||
int getCount();
|
||||
|
||||
String getDescription();
|
||||
@ -388,6 +317,61 @@ public class Stats {
|
||||
boolean isEditable();
|
||||
}
|
||||
|
||||
//Entry can not be final because its overridden. Maybe checkstyle has a bug?
|
||||
//CHECKSTYLE.OFF: FinalClass
|
||||
private static class Entry implements Row {
|
||||
private final String description;
|
||||
private final boolean editable;
|
||||
private int count;
|
||||
private int transistors;
|
||||
|
||||
private Entry(EntryKey key, boolean editable) {
|
||||
this(key.getDescription(), 0, editable, key.transistors);
|
||||
}
|
||||
|
||||
private Entry(String description, int count, boolean editable, int transistors) {
|
||||
this.description = description;
|
||||
this.count = count;
|
||||
this.editable = editable;
|
||||
this.transistors = transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransistorsEach() {
|
||||
return transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransistorsEach(int transistors) {
|
||||
this.transistors = transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransistors() {
|
||||
return count * transistors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
|
||||
private void addOne() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
//CHECKSTYLE.ON: FinalClass
|
||||
|
||||
private static final class MyTableModel implements TableModel {
|
||||
private final List<Row> entries;
|
||||
private ArrayList<TableModelListener> listeners = new ArrayList<>();
|
||||
|
@ -110,4 +110,13 @@ public class InverterConfig {
|
||||
public int hashCode() {
|
||||
return inputs != null ? inputs.hashCode() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of inverted inputs
|
||||
*/
|
||||
public int size() {
|
||||
if (inputs == null)
|
||||
return 0;
|
||||
return inputs.size();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user