Search in sources :

Example 51 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class TableReorderManager method checkReorder.

private void checkReorder(TruthTableTableModel model) {
    ArrayList<Variable> varList = model.getTable().getVars();
    ArrayList<String> vars = new ArrayList<>();
    ArrayList<String> results = new ArrayList<>();
    boolean wasChange = false;
    for (int i = 0; i < model.getColumnCount(); i++) {
        String name = table.getTableHeader().getColumnModel().getColumn(i).getHeaderValue().toString();
        if (!name.equals(table.getModel().getColumnName(i)))
            wasChange = true;
        BoolTable r = model.getTable().getResult(name);
        if (r != null && varList.contains(new Variable(name)))
            return;
        if (r != null)
            results.add(name);
        else
            vars.add(name);
    }
    if (wasChange) {
        if (isVarChange(varList, vars)) {
            try {
                TruthTable tt = new ReorderInputs(model.getTable(), vars).reorder();
                tableDialog.setModel(new TruthTableTableModel(tt));
            } catch (ExpressionException e) {
                // can't happen because no columns are removed
                e.printStackTrace();
            }
        } else if (isResultChange(model.getTable(), results)) {
            try {
                TruthTable tt = new ReorderOutputs(model.getTable(), results).reorder();
                tableDialog.setModel(new TruthTableTableModel(tt));
            } catch (ExpressionException e) {
                // can't happen because no columns are removed
                e.printStackTrace();
            }
        } else
            tableDialog.setModel(new TruthTableTableModel(model.getTable()));
    }
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) ArrayList(java.util.ArrayList) ExpressionException(de.neemann.digital.analyse.expression.ExpressionException) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TruthTable(de.neemann.digital.analyse.TruthTable) TruthTableTableModel(de.neemann.digital.analyse.TruthTableTableModel)

Aggregations

Variable (de.neemann.digital.analyse.expression.Variable)51 Expression (de.neemann.digital.analyse.expression.Expression)34 ContextFiller (de.neemann.digital.analyse.expression.ContextFiller)10 NamedExpression (de.neemann.digital.analyse.expression.NamedExpression)8 ArrayList (java.util.ArrayList)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)6 FormatToExpression (de.neemann.digital.analyse.expression.format.FormatToExpression)5 TestExecuter (de.neemann.digital.TestExecuter)4 Circuit (de.neemann.digital.draw.elements.Circuit)4 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)4 ModelCreator (de.neemann.digital.draw.model.ModelCreator)4 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)4 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)3 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)3 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)3 TruthTable (de.neemann.digital.analyse.TruthTable)2 FormatterException (de.neemann.digital.analyse.expression.format.FormatterException)2 FuseMapFillerException (de.neemann.digital.builder.jedec.FuseMapFillerException)2 JedecWriter (de.neemann.digital.builder.jedec.JedecWriter)2