mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 06:51:37 -04:00
experimental creation of bidirectional counters in the table dialog
This commit is contained in:
parent
e0d93f2c00
commit
ad6e26fa80
@ -141,6 +141,12 @@ public class TableDialog extends JDialog {
|
||||
sizeMenu.add(sequential);
|
||||
for (int i = 2; i <= 8; i++)
|
||||
sequential.add(new JMenuItem(new SizeSequentialAction(i)));
|
||||
if (Main.enableExperimental()) {
|
||||
JMenu sequentialBiDir = new JMenu(Lang.get("menu_table_new_sequential_bidir"));
|
||||
sizeMenu.add(sequentialBiDir);
|
||||
for (int i = 2; i <= 8; i++)
|
||||
sequentialBiDir.add(new JMenuItem(new SizeSequentialBidirectionalAction(i)));
|
||||
}
|
||||
bar.add(sizeMenu);
|
||||
|
||||
JMenu reorderMenu = new JMenu(Lang.get("menu_table_reorder"));
|
||||
@ -631,6 +637,39 @@ public class TableDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private final class SizeSequentialBidirectionalAction extends AbstractAction {
|
||||
private int n;
|
||||
|
||||
private SizeSequentialBidirectionalAction(int n) {
|
||||
super(Lang.get("menu_table_N_variables", n));
|
||||
this.n = n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
ArrayList<Variable> vars = new ArrayList<>();
|
||||
vars.add(new Variable("dir"));
|
||||
for (int i = n - 1; i >= 0; i--)
|
||||
vars.add(new Variable("Q_" + i + "n"));
|
||||
TruthTable truthTable = new TruthTable(vars);
|
||||
int i = n - 1;
|
||||
int rows = 1 << (n + 1);
|
||||
for (int vi = 1; vi < vars.size(); vi++) {
|
||||
BoolTableByteArray val = new BoolTableByteArray(rows);
|
||||
for (int n = 0; n < rows; n++) {
|
||||
if (n >= rows / 2)
|
||||
val.set(n, ((n - 1) >> i) & 1);
|
||||
else
|
||||
val.set(n, ((n + 1) >> i) & 1);
|
||||
}
|
||||
truthTable.addResult(vars.get(vi).getIdentifier() + "+1", val);
|
||||
i--;
|
||||
}
|
||||
|
||||
setModel(new TruthTableTableModel(truthTable));
|
||||
}
|
||||
}
|
||||
|
||||
private final class CenterDefaultTableCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
@Override
|
||||
|
@ -664,6 +664,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="menu_table_newColumns">Spalten hinzufügen</string>
|
||||
<string name="menu_table_new_combinatorial">Kombintorisch</string>
|
||||
<string name="menu_table_new_sequential">Automat</string>
|
||||
<string name="menu_table_new_sequential_bidir">Automat bidirektional</string>
|
||||
<string name="menu_table_outputs">Ausgänge</string>
|
||||
<string name="menu_table_reorder">Umsortieren</string>
|
||||
<string name="menu_table_set">Setzen</string>
|
||||
|
@ -653,6 +653,7 @@ The names of the variables may not be unique.</string>
|
||||
<string name="menu_table_newColumns">Add Columns</string>
|
||||
<string name="menu_table_new_combinatorial">Combinatorial</string>
|
||||
<string name="menu_table_new_sequential">Sequential</string>
|
||||
<string name="menu_table_new_sequential_bidir">Sequential bidirectional</string>
|
||||
<string name="menu_table_outputs">Outputs</string>
|
||||
<string name="menu_table_reorder">Reorder</string>
|
||||
<string name="menu_table_set">Set</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user