better color model, passed tests are green

This commit is contained in:
hneemann 2016-07-07 15:40:36 +02:00
parent 8c2742b392
commit 141c4c4635
5 changed files with 23 additions and 14 deletions

View File

@ -22,7 +22,7 @@ public class TestResult implements TableModel {
private final ArrayList<String> names;
private final ArrayList<Value[]> lines;
private final ArrayList<MatchedValue[]> results;
private final ArrayList<Value[]> results;
private boolean allPassed;
/**
@ -60,11 +60,11 @@ public class TestResult implements TableModel {
for (Value[] row : lines) {
MatchedValue[] res = new MatchedValue[row.length];
Value[] res = new Value[row.length];
for (TestSignal in : inputs) {
row[in.index].setTo(in.value);
res[in.index] = new MatchedValue(row[in.index], in.value);
res[in.index] = row[in.index];
}
model.doStep();
@ -89,6 +89,9 @@ public class TestResult implements TableModel {
}
private int getIndexOf(String name) throws DataException {
if (name==null || name.length()==0)
throw new DataException(Lang.get("err_unnamedSignal", name));
for (int i = 0; i < names.size(); i++) {
String n = names.get(i);
if (n.equals(name))
@ -144,7 +147,7 @@ public class TestResult implements TableModel {
* @param columnIndex columnIndex
* @return the value
*/
public MatchedValue getValue(int rowIndex, int columnIndex) {
public Value getValue(int rowIndex, int columnIndex) {
return results.get(rowIndex)[columnIndex];
}

View File

@ -21,6 +21,7 @@ import java.util.Collections;
*/
public class TestResultDialog extends JDialog {
private static final Color FAILED_COLOR = new Color(255, 200, 200);
private static final Color PASSED_COLOR = new Color(200, 255, 200);
/**
* Creates a new result dialog.
@ -31,7 +32,7 @@ public class TestResultDialog extends JDialog {
* @param library the library to use
* @throws NodeException NodeException
* @throws DataException DataException
* @throws PinException PinException
* @throws PinException PinException
*/
public TestResultDialog(JFrame owner, ArrayList<TestSet> tsl, Circuit circuit, ElementLibrary library) throws NodeException, DataException, PinException {
super(owner, Lang.get("msg_testResult"), false);
@ -92,15 +93,18 @@ public class TestResultDialog extends JDialog {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
MatchedValue v = (MatchedValue) value;
Value v = (Value) value;
comp.setText(v.toString());
comp.setHorizontalAlignment(JLabel.CENTER);
if (v.isPassed())
if (v instanceof MatchedValue) {
if (((MatchedValue) v).isPassed())
comp.setBackground(PASSED_COLOR);
else
comp.setBackground(FAILED_COLOR);
} else
comp.setBackground(Color.WHITE);
else
comp.setBackground(FAILED_COLOR);
return comp;
}

View File

@ -168,8 +168,9 @@ Zur Analyse können Sie die Schaltung im Gatterschrittmodus ausführen.</string>
<string name="err_parserUnexpectedEndOfExpression">Unerwartetes Ende des Ausdrucks</string>
<string name="err_notANumber_N0_inLine_N1">Wert {0} in Zeile {1} ist keine Zahl!</string>
<string name="err_testDataExpected_N0_found_N1_numbersInLine_N2">Erwarte {0} anstelle von {1} Werten in Zeile {2}!</string>
<string name="err_signal_N_notInTextVector">Signal {0} ist im Testvector nicht vorhanden!</string>
<string name="err_signal_N_notInTextVector">Signal {0} ist im Testvektor nicht vorhanden!</string>
<string name="err_noTestData">Keine Testdaten vorhanden.</string>
<string name="err_unnamedSignal">Es gibt ein unbenanntes Signal</string>
<string name="key_AddrBits">Adress Bits</string>
<string name="key_Bits">Datenbits</string>
<string name="key_Color">Farbe</string>

View File

@ -170,6 +170,7 @@ To analyse you can run the circuit in single gate step mode.</string>
<string name="err_testDataExpected_N0_found_N1_numbersInLine_N2">Expected {0} but found {1} values in line {2}!</string>
<string name="err_signal_N_notInTextVector">Signal {0} is not present in test vector!</string>
<string name="err_noTestData">Not test data found.</string>
<string name="err_unnamedSignal">There is a unnamed signal!</string>
<string name="key_AddrBits">Address Bits</string>
<string name="key_Bits">Data Bits</string>
<string name="key_Color">Color</string>

View File

@ -55,10 +55,10 @@ public class TestResultTest extends TestCase {
+ "1 1 0\n");
TestResult tr = new TestResult(data).create(model);
assertFalse(tr.allPassed());
assertEquals(true, tr.getValue(0,2).isPassed());
assertEquals(true, tr.getValue(1,2).isPassed());
assertEquals(true, tr.getValue(2,2).isPassed());
assertEquals(false, tr.getValue(3,2).isPassed());
assertEquals(true, ((MatchedValue)tr.getValue(0,2)).isPassed());
assertEquals(true, ((MatchedValue)tr.getValue(1,2)).isPassed());
assertEquals(true, ((MatchedValue)tr.getValue(2,2)).isPassed());
assertEquals(false, ((MatchedValue)tr.getValue(3,2)).isPassed());
}
public void testResultErrorDC() throws Exception {